From 0684dc65b7881055c6b00440233f95df09898f40 Mon Sep 17 00:00:00 2001 From: herowinb Date: Sun, 18 Aug 2024 14:58:36 +0700 Subject: [PATCH] Skip redownload thumbnail if not found https://github.com/herowinb/live-dl/issues/26 --- live-dl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/live-dl b/live-dl index 0d1620e..577e9ea 100755 --- a/live-dl +++ b/live-dl @@ -1676,13 +1676,15 @@ function func_finalize_download() { # Check if thumbnail is available (has 200 HTTP response code) local _thumb_resp=$(curl -qSsfw "%{http_code}" $THUMBNAIL_CALC -o /dev/null) - if [ "$_thumb_resp" != "200" ]; then - __info "No high-res thumbnial (maxresdefault.jpg), failback to hqdefault.jpg" - THUMBNAIL_CALC="https://i.ytimg.com/vi/$VIDEO_ID/hqdefault.jpg" - curl -s "$THUMBNAIL_CALC" -o "$OUTPUT_PATH.jpg" - else - curl -s "$THUMBNAIL_CALC" -o "$OUTPUT_PATH.jpg" - fi + if [ "$_thumb_resp" != "404" ]; then + # 404 error, so no thumbnail. The Video should be privated or deleted. Skip redownload thumbnail. + if [ "$_thumb_resp" != "200" ]; then + __info "No high-res thumbnial (maxresdefault.jpg), failback to hqdefault.jpg" + THUMBNAIL_CALC="https://i.ytimg.com/vi/$VIDEO_ID/hqdefault.jpg" + curl -s "$THUMBNAIL_CALC" -o "$OUTPUT_PATH.jpg" + else + curl -s "$THUMBNAIL_CALC" -o "$OUTPUT_PATH.jpg" + fi fi if [ $SKIP_METADATA == "false" ]; then