From a1ce05fbc0af227d452b49b199220a20a9e4cf11 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Thu, 1 Sep 2022 20:44:32 -0400 Subject: [PATCH] v1.0.039 - Retry failed tidal verification check up to 3 times --- root/scripts/video.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/root/scripts/video.sh b/root/scripts/video.sh index 0fc7adc..230f60c 100644 --- a/root/scripts/video.sh +++ b/root/scripts/video.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.038" +scriptVersion="1.0.039" if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" @@ -187,10 +187,19 @@ TidalClientSetup () { TidalClientTest () { log "TIDAL :: tidal-dl client setup verification..." - TidaldlStatusCheck - tidal-dl -o $downloadPath/incomplete -l "166356219" &>/dev/null - - downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) + i=0 + while [ $i -lt 3 ]; do + i=$(( $i + 1 )) + TidaldlStatusCheck + tidal-dl -q Normal -o "$downloadPath"/incomplete -l "166356219" &>/dev/null + downloadCount=$(find "$downloadPath"/incomplete -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) + if [ $downloadCount -le 0 ]; then + continue + else + break + fi + done + if [ $downloadCount -le 0 ]; then if [ -f /config/xdg/.tidal-dl.token.json ]; then rm /config/xdg/.tidal-dl.token.json @@ -198,11 +207,11 @@ TidalClientTest () { log "TIDAL :: ERROR :: Download failed" log "TIDAL :: ERROR :: You will need to re-authenticate on next script run..." log "TIDAL :: ERROR :: Exiting..." - rm -rf $downloadPath/incomplete/* - NotifyWebhook "Error" "TIDAL not authenticated but configured" + rm -rf "$downloadPath"/incomplete/* + NotifyWebhook "Error" "TIDAL not authenticated but configured" exit else - rm -rf $downloadPath/incomplete/* + rm -rf "$downloadPath"/incomplete/* log "TIDAL :: Successfully Verified" fi }