* Support Leech+ links to directory listings and truncate TMP_FILE in kaoget.sh.
authorUrban Wallasch <urban.wallasch@freenet.de>
Sun, 25 Apr 2021 12:15:29 +0000 (14:15 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Sun, 25 Apr 2021 12:15:29 +0000 (14:15 +0200)
kaoget.sh

index d8433954306d4e5eadc96e3f71e92adca55c5f6d..daf437139163112fdac25e5c562a63417a5c87a3 100755 (executable)
--- a/kaoget.sh
+++ b/kaoget.sh
@@ -69,6 +69,15 @@ function make_kix {
     KIX=${KIX#*f=}
     KIX=${KIX%%&*}
     ;;
+   */leech/*~*/ )
+    KIX=${KIX##*~}
+    KIX=${KIX%/}
+    KIX="$(echo $KIX | sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b")"
+    ;;
+   */leech/*~* )
+    KIX=${KIX##*~}
+    KIX="$(echo $KIX | sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b")"
+    ;;
    */leech* )
     KIX=${KIX#*p=}
     KIX=${KIX%%&*}
@@ -86,6 +95,7 @@ case "$URL_FILE" in
   https://* )
     # Got an URL for the file parameter.
     TMP_FILE=$(make_kix "$URL_FILE")
+    truncate -s 0 "$TMP_FILE"
     case "$URL_FILE" in
       *"&s="*"&q="* )
         # URL appears to point to a directory, fetch the listing!
@@ -93,7 +103,7 @@ case "$URL_FILE" in
         URL_FILE="${URL_FILE/leech.php/leechx.php/}&q=1&m=0"
         $GETTER $GENOPT $HTTP_AUTH $OUTOPT "$TMP_FILE" "$URL_FILE$GET_AUTH"
         ;;
-      *"&q=1&m=0" )
+      *"&q=1&m=0" | */leech/*~*/ )
         # URL appears to point to a generated listing, fetch it!
         $GETTER $GENOPT $HTTP_AUTH $OUTOPT "$TMP_FILE" "$URL_FILE$GET_AUTH"
         ;;