## 3rd alternative:
HTTP_AUTH="--user=$USER --password=$PASS"
+case "$URL_FILE" in
+ https://* )
+ # Got an URL for the file parameter.
+ TMP_FILE=$(mktemp kaoget_XXXX)
+ case "$URL_FILE" in
+ *"&q=1&m=0" )
+ # If it appears to point to a generated directory listing, wget it.
+ echo "# If it appears to point to a generated directory listing, wget it."
+ wget -c --retry-connrefused \
+ $POST_AUTH \
+ $HTTP_AUTH --auth-no-challenge \
+ -O "$TMP_FILE" \
+ "$URL_FILE$GET_AUTH"
+ ;;
+ *)
+ # Otherwise, store the URL verbatim.
+ echo "echo $URL_FILE > $TMP_FILE"
+ echo "$URL_FILE" > $TMP_FILE
+ ;;
+ esac
+ # Either way, use the new file as the source for download URLs.
+ URL_FILE=$TMP_FILE
+ ;;
+esac
+
while read URL; do
case "$URL" in
+ "#"* )
+ continue
+ ;;
*/dl.php*f=* )
NAME=${URL#*f=}
NAME=${NAME%&*}
if [ -n "$NAME" ] ; then
mkdir -p "$(dirname "$NAME")"
+ PNAME="$NAME".part
+ mv "$NAME" "$PNAME" 2> /dev/null
wget -c --retry-connrefused \
$POST_AUTH \
$HTTP_AUTH --auth-no-challenge \
$BWLIM \
- -O "$NAME" \
- "$URL$GET_AUTH"
+ -O "$PNAME" \
+ "$URL$GET_AUTH" \
+ && mv "$PNAME" "$NAME"
fi
done < "$URL_FILE"
+
+[ -n "$TMP_FILE" ] && rm -f $TMP_FILE