esac
#[ -n "$USER" ] && [ -n "$PASS" ] && GET_AUTH="&auth=$USER:$PASS"
+function rawurldecode() {
+ local s="${1//+/ }"
+ printf '%b' "${s//%/\\x}"
+}
function make_kix {
- KIX="$1"
+ local KIX="$1"
case "$KIX" in
*/dl.php*f=* )
KIX=${KIX#*f=}
*/leech/*~*/ )
KIX=${KIX##*~}
KIX=${KIX%/}
- KIX="$(echo $KIX | sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b")"
+ KIX="$(rawurldecode "$KIX")"
;;
*/leech/*~* )
KIX=${KIX##*~}
- KIX="$(echo $KIX | sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b")"
+ KIX="$(rawurldecode "$KIX")"
;;
*/leech* )
KIX=${KIX#*p=}
KIX=$(mktemp --dry-run kaoget_XXXX)
;;
esac
- KIX="$(echo $KIX | sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b")"
+ KIX="$(rawurldecode "$KIX")"
KIX="${KIX##*/}.kix"
echo "$KIX"
}
;;
esac
-sed -e 's/[[:space:]]*#.*// ; /^[[:space:]]*$/d' "$URL_FILE" |
while read URL; do
+ URL="${URL%%#*}"
case "$URL" in
*/dl.php*f=* )
NAME=${URL#*f=}
;;
*/leech/*~* )
NAME=${URL##*~}
- NAME=$(echo $NAME | sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b")
+ NAME="$(rawurldecode "$NAME")"
;;
* )
continue
;;
esac
- NAME=$(echo $NAME | sed "s@+@ @g;s@%@\\\\x@g" | xargs -0 printf "%b")
+ NAME="$(rawurldecode "$NAME")"
NAME=${NAME#*/}
NAME=${NAME#*/}
NAME=${NAME#*/}
$GETTER $GENOPT $HTTP_AUTH $BWLIM $OUTOPT "$PNAME" "$URL$GET_AUTH"
[ $? -ne 0 ] && exit 3
mv "$PNAME" "$NAME"
-done
+done < "$URL_FILE"
[ -n "$TMP_FILE" ] && rm -f "$TMP_FILE"
exit 0