diff --git a/root/scripts/download.sh b/root/scripts/download.sh index c230e9a..9d36e27 100644 --- a/root/scripts/download.sh +++ b/root/scripts/download.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.203" +scriptVersion="1.0.204" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" if [ "$lidarrUrlBase" = "null" ]; then lidarrUrlBase="" @@ -937,7 +937,7 @@ GetMissingCutOffList () { lidarrRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/missing?page=$page&pagesize=$amountPerPull&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r '.records[].id') for lidarrRecordId in $(echo $lidarrRecords); do - if [ ! -f "/config/extended/logs/notfound/$lidarrRecordId" ]; then + if [ ! -f /config/extended/logs/notfound/$lidarrRecordId-* ]; then touch /config/extended/cache/lidarr/list/${lidarrRecordId}-missing fi done @@ -962,7 +962,7 @@ GetMissingCutOffList () { log ":: Downloading page $page... ($offset - $dlnumber of $lidarrCutoffTotalRecords Results)" lidarrRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/cutoff?page=$page&pagesize=$amountPerPull&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r '.records[].id') for lidarrRecordId in $(echo $lidarrRecords); do - if [ ! -f "/config/extended/logs/notfound/$lidarrRecordId" ]; then + if [ ! -f /config/extended/logs/notfound/$lidarrRecordId-* ]; then touch /config/extended/cache/lidarr/list/${lidarrRecordId}-cutoff fi done @@ -1000,6 +1000,8 @@ SearchProcess () { checkLidarrAlbumId=$wantedAlbumId wantedAlbumListSource=$(echo $lidarrMissingId | sed -e "s%[^[:alpha:]]%%g") lidarrAlbumData="$(curl -s "$lidarrUrl/api/v1/album/$wantedAlbumId?apikey=${lidarrApiKey}")" + lidarrArtistData=$(echo "${lidarrAlbumData}" | jq -r ".artist") + lidarrArtistForeignArtistId=$(echo "${lidarrArtistData}" | jq -r ".foreignArtistId") lidarrAlbumType=$(echo "$lidarrAlbumData" | jq -r ".albumType") lidarrAlbumTitle=$(echo "$lidarrAlbumData" | jq -r ".title") @@ -1009,7 +1011,7 @@ SearchProcess () { chown abc:abc /config/extended/logs/notfound fi - if [ -f "/config/extended/logs/notfound/$wantedAlbumId" ]; then + if [ -f "/config/extended/logs/notfound/$wantedAlbumId-$lidarrArtistForeignArtistId" ]; then log ":: $processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..." continue fi @@ -1018,7 +1020,9 @@ SearchProcess () { if [ -f "/config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId" ]; then log ":: $processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..." rm "/config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId" - touch "/config/extended/logs/notfound/$wantedAlbumId" + touch "/config/extended/logs/notfound/$wantedAlbumId-$lidarrArtistForeignArtistId" + chmod 666 "/config/extended/logs/notfound/$wantedAlbumId-$lidarrArtistForeignArtistId" + chown abc:abc "/config/extended/logs/notfound/$wantedAlbumId-$lidarrArtistForeignArtistId" continue fi @@ -1337,10 +1341,10 @@ SearchProcess () { chown abc:abc /config/extended/logs/notfound fi log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Marking Album as notfound" - if [ ! -f /config/extended/logs/notfound/$wantedAlbumId ]; then - touch /config/extended/logs/notfound/$wantedAlbumId - chmod 666 /config/extended/logs/notfound/$wantedAlbumId - chown abc:abc /config/extended/logs/notfound/$wantedAlbumId + if [ ! -f "/config/extended/logs/notfound/$wantedAlbumId-$lidarrArtistForeignArtistId" ]; then + touch "/config/extended/logs/notfound/$wantedAlbumId-$lidarrArtistForeignArtistId" + chmod 666 "/config/extended/logs/notfound/$wantedAlbumId-$lidarrArtistForeignArtistId" + chown abc:abc "/config/extended/logs/notfound/$wantedAlbumId-$lidarrArtistForeignArtistId" fi log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Search Complete..." done