vidl: Slightly improve url ingestion and error output

This commit is contained in:
Marty Oehme 2024-07-26 10:57:21 +02:00
parent 017668792c
commit 2fcaad5c1c
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -124,7 +124,7 @@ download() { # 1=url
elif _should_archive; then elif _should_archive; then
archive_file=$(_findfile "$ARCHIVE_FOLDER" "$yt_dl_fname") archive_file=$(_findfile "$ARCHIVE_FOLDER" "$yt_dl_fname")
echo "$archive_file" | while read -r file; do echo "$archive_file" | while read -r file; do
echo "file $file exists, not downloading duplicate" printf "File %s exists, not downloading duplicate.\n" "$file"
_call_archive "$file" "$DL_FOLDER" _call_archive "$file" "$DL_FOLDER"
done done
fi fi
@ -132,8 +132,8 @@ download() { # 1=url
setup() { setup() {
TEMP_FOLDER="${TEMP_FOLDER:-${HOME}/downloads}" TEMP_FOLDER="${TEMP_FOLDER:-${HOME}/downloads}"
DL_FOLDER="${DL_FOLDER:-${XDG_VIDEOS_DIR:-$HOME/media/videos}/inbox}" DL_FOLDER="${DL_FOLDER:-${XDG_VIDEOS_DIR:-$HOME/videos}/inbox}"
ARCHIVE_FOLDER="${ARCHIVE_FOLDER:-${XDG_VIDEOS_DIR:-$HOME/media/videos}/archive}" ARCHIVE_FOLDER="${ARCHIVE_FOLDER:-${XDG_VIDEOS_DIR:-$HOME/videos}/archive}"
YT_DL_CMD="${YT_DL_CMD:-yt-dlp}" YT_DL_CMD="${YT_DL_CMD:-yt-dlp}"
yt_default_opts=(-f "best[height\<=1080]" --retries 15 --embed-chapters --embed-subs --sub-lang "en,de,es,fr") yt_default_opts=(-f "best[height\<=1080]" --retries 15 --embed-chapters --embed-subs --sub-lang "en,de,es,fr")
declare -a YT_DL_OPTS=${YT_DL_OPTS:-( "${yt_default_opts[@]}" )} declare -a YT_DL_OPTS=${YT_DL_OPTS:-( "${yt_default_opts[@]}" )}
@ -160,6 +160,7 @@ add_to_queue() { # 1=url
} }
remove_from_queue() { # 1=url remove_from_queue() { # 1=url
printf "Removing url %s from queue.\n" "$1"
sed -i.bak -e "\|$1|d" "$queue_file" sed -i.bak -e "\|$1|d" "$queue_file"
} }
@ -201,7 +202,7 @@ main() {
exit exit
fi fi
for url in $*; do for url in "$@"; do
add_to_queue "$url" add_to_queue "$url"
done done
if is_only_instance; then if is_only_instance; then