diff --git a/root/scripts/download.sh b/root/scripts/download.sh index bc4fbed..67bc27a 100644 --- a/root/scripts/download.sh +++ b/root/scripts/download.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.90" +scriptVersion="1.0.91" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" if [ "$lidarrUrlBase" = "null" ]; then lidarrUrlBase="" @@ -164,6 +164,18 @@ DownloadFormat () { fi } +DownloadFolderCleaner () { + log ":: Removing prevously completed downloads that failed to import..." + # check for completed download folder + if [ -d "/downloads/lidarr-extended/complete" ]; then + # check for completed downloads older than 1 day + if find /downloads/lidarr-extended/complete -mindepth 1 -type d -mtime +1 | read; then + # delete completed downloads older than 1 day, these most likely failed to import due to Lidarr failing to match + find /downloads/lidarr-extended/complete -mindepth 1 -type d -mtime +1 -exec rm -rf "{}" \; &>/dev/null + fi + fi +} + AddDeezerTopArtists () { getDeezerArtistsIds=$(curl -s "https://api.deezer.com/chart/0/artists?limit=$1" | jq -r ".data[].id") getDeezerArtistsIdsCount=$(echo "$getDeezerArtistsIds" | wc -l) @@ -412,6 +424,7 @@ TidalClientSetup () { } DownloadProcess () { + downloadedAlbumTitleClean="$(echo "$downloadedAlbumTitle" | sed -e "s%[^[:alpha:][:digit:]._' ]% %g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')" if [ ! -d "/downloads/lidarr-extended" ]; then @@ -1384,6 +1397,9 @@ if [ "$configureLidarrWithOptimalSettings" = "true" ]; then fi fi +# Perform Completed Download Folder Cleanup process +DownloadFolderCleaner + LidarrRootFolderCheck DownloadFormat