Skip to content

Commit a554a62

Browse files
committed
do not remove all files if download fails
1 parent d03cd76 commit a554a62

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.3.2
1+
v0.3.3

files/downloader.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,30 @@ for ITEM in "${DOWNLOADER_ITEMS[@]}"; do
5151
YT_DLP_ARGUMENTS=()
5252
if [[ "$TYPE" == movie ]]; then
5353
YT_DLP_ARGUMENTS=("${VIDEO_DEFAULT_ARGUMENTS[@]}" --output \
54-
"${WORKDIR}/%(title)s (%(release_date>%Y,upload_date>%Y)s)\
54+
"%(title)s (%(release_date>%Y,upload_date>%Y)s)\
5555
%(format_note& - {}|)s [%(language).2s].%(ext)s")
5656
elif [[ "$TYPE" == music ]]; then
5757
RUN_FILENAME_SANITIZE=true
5858
RUN_FILEORGANIZER=true
5959
YT_DLP_ARGUMENTS=("${AUDIO_DEFAULT_ARGUMENTS[@]}" \
6060
--postprocessor-args "ThumbnailsConvertor+ffmpeg_o:-c:v \
6161
mjpeg -vf crop=\"'if(gt(ih,iw),iw,ih)':'if(gt(iw,ih),ih,iw)'\"" \
62-
--output "${WORKDIR}/%(creator).80s - %(title)s.%(ext)s")
62+
--output "%(creator).80s - %(title)s.%(ext)s")
6363
elif [[ "$TYPE" == musicvideo ]]; then
6464
YT_DLP_ARGUMENTS=("${VIDEO_DEFAULT_ARGUMENTS[@]}" --output \
65-
"${WORKDIR}/%(creator).80s - %(title)s.%(ext)s")
65+
"%(creator).80s - %(title)s.%(ext)s")
6666
RUN_FILENAME_SANITIZE=true
6767
elif [[ "$TYPE" == news ]]; then
6868
YT_DLP_ARGUMENTS=("${VIDEO_DEFAULT_ARGUMENTS[@]}" --output \
69-
"${WORKDIR}/%(release_date>%Y.%m.%d,upload_date>%Y.%m.%d)s \
69+
"%(release_date>%Y.%m.%d,upload_date>%Y.%m.%d)s \
7070
%(playlist_title,channel)s - %(title)s \\[%(language).2s\\].%(ext)s")
7171
elif [[ "$TYPE" == podcast ]]; then
7272
YT_DLP_ARGUMENTS=("${AUDIO_DEFAULT_ARGUMENTS[@]}" --output \
73-
"${WORKDIR}/%(release_date>%Y.%m.%d,upload_date>%Y.%m.%d)s \
73+
"%(release_date>%Y.%m.%d,upload_date>%Y.%m.%d)s \
7474
%(series,playlist_title,channel)s%(title& - {}|)s [%(language).2s].%(ext)s")
7575
elif [[ "$TYPE" == series ]]; then
7676
YT_DLP_ARGUMENTS=("${VIDEO_DEFAULT_ARGUMENTS[@]}" --output \
77-
"${WORKDIR}/%(series,playlist_title,channel)s S%(season_number|XX)02d\
77+
"%(series,playlist_title,channel)s S%(season_number|XX)02d\
7878
E%(episode_number,playlist_index|XX)02d%(title& {}|)s (%(release_date>%Y,upload_date>%Y)s)\
7979
%(format_note& - {}|)s [%(language).2s].%(ext)s")
8080
else
@@ -89,13 +89,14 @@ E%(episode_number,playlist_index|XX)02d%(title& {}|)s (%(release_date>%Y,upload_
8989
--audio-multistream --cache-dir /tmp/yt-dlp/cache --concurrent-fragments 8 \
9090
--convert-thumb jpg --download-archive "${CONFIG_DIR}/${TYPE}/downloaded.txt" \
9191
--embed-chapters --embed-metadata --embed-subs --embed-thumbnail \
92-
--fragment-retries 1000 --retries 100 --retry-sleep 10 \
93-
--sub-langs all,-live_chat --trim-filenames "124" --quiet "$URL" \
92+
--fragment-retries 1000 --paths "home:${WORKDIR}" --paths "temp:${WORKDIR}/yt-dlp" \
93+
--retries 100 --retry-sleep 10 --sub-langs all,-live_chat --trim-filenames "124" \
94+
--quiet "$URL" \
9495
|| EXIT_CODE=$?
9596
if [[ "$EXIT_CODE" != @(101|0) ]]; then
9697
echo "Download failed with exit code ${EXIT_CODE}."
97-
rm -f "$WORKDIR"/*
9898
fi
99+
rm --force --recursive "${WORKDIR}/yt-dlp"
99100
if [[ ! "$(ls -A "$WORKDIR")" ]]; then
100101
echo "No new download"
101102
break

0 commit comments

Comments
 (0)