]> zdv2.bktei.com Git - BK-2020-03.git/blobdiff - user/htmlz_to_cbz.sh
fix(user/bkdatev):Make tzdata-legacy 'right/UTC' TZ optional
[BK-2020-03.git] / user / htmlz_to_cbz.sh
index b1c450e870a82db15134ddbd427a23186ac71263..de313f080e7febfac964039494ceaa64a422ea61 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # Desc: Collects .jpg/jpeg files from a Calibre .htmlz file into .cbz files
 #!/bin/bash
 # Desc: Collects .jpg/jpeg files from a Calibre .htmlz file into .cbz files
-# Version: 0.1.0
+# Version: 0.1.2
 # Depends: jdupes 1.27.3
 
 for fin in ./*.htmlz; do
 # Depends: jdupes 1.27.3
 
 for fin in ./*.htmlz; do
@@ -8,31 +8,31 @@ for fin in ./*.htmlz; do
         dout="${fin%.*}";
         unzip "$fin" -x / -d "$dout";
         pushd "$dout";
         dout="${fin%.*}";
         unzip "$fin" -x / -d "$dout";
         pushd "$dout";
-        mapfile -t images < <(cat index.html  | grep -E "(.jpg|.jpeg)" | sed -E -e 's#.+(images/[0-9]+.(jpeg|jpg)).+#\1#' | uniq; );
-        dout="./output";
-        if [[ -d "$dout" ]]; then
-            rm -r "$dout";
+        mapfile -t images < <(cat index.html  | grep -E "(.jpg|.jpeg|.png)" | sed -E -e 's#.+(images/[0-9]+.(jpeg|jpg|png)).+#\1#' | uniq; );
+        dout2="./output";
+        if [[ -d "$dout2" ]]; then
+            rm -r "$dout2";
         fi;
         fi;
-        mkdir "$dout";
+        mkdir "$dout2";
         n=1;
         for path in "${images[@]}"; do
         n=1;
         for path in "${images[@]}"; do
-            fnew="${dout}/$(printf "%06d" "$n").jpg";
+            fnew="${dout2}/$(printf "%06d" "$n").jpg";
             cp "$path" "$fnew";
             ((n++));
         done;
         # Add cover file if present
         if [[ -f cover.jpg ]]; then
             cp "$path" "$fnew";
             ((n++));
         done;
         # Add cover file if present
         if [[ -f cover.jpg ]]; then
-            cp -n cover.jpg "${dout}/000000.jpg";
+            cp -n cover.jpg "${dout2}/000000.jpg";
         fi;
         # Remove duplicate images
         if command -v jdupes 1>/dev/random 2>&1; then
         fi;
         # Remove duplicate images
         if command -v jdupes 1>/dev/random 2>&1; then
-            jdupes -dN "$dout";
+            jdupes -dN "$dout2";
         fi;
         faout="output.cbz";
         if [[ -f "$faout" ]]; then
             rm "$fout";
         fi;
         fi;
         faout="output.cbz";
         if [[ -f "$faout" ]]; then
             rm "$fout";
         fi;
-        zip -j output.cbz "$dout"/*;
+        zip -j output.cbz "$dout2"/*;
     ) &
 done;
 wait && echo "STATUS:Finished." 1>&2;
     ) &
 done;
 wait && echo "STATUS:Finished." 1>&2;