1.0.203 - Better process for skiping previously notfound albums

Move notfound logs from: /config/extended/logs/downloaded/notfound -> /config/extended/logs/notfound/
Use Lidarr album ID instead of MBZ id
When the script generates the missing/cutoff list, skip items in the "/config/extended/logs/notfound" directory, thus improving the speed of all the processes.
pull/35/head
RandomNinjaAtk 2 years ago committed by GitHub
parent 361ee70489
commit 8b4a4782ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
scriptVersion="1.0.202" scriptVersion="1.0.203"
lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
if [ "$lidarrUrlBase" = "null" ]; then if [ "$lidarrUrlBase" = "null" ]; then
lidarrUrlBase="" lidarrUrlBase=""
@ -937,11 +937,13 @@ 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') 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 for lidarrRecordId in $(echo $lidarrRecords); do
touch /config/extended/cache/lidarr/list/${lidarrRecordId}-missing if [ ! -f "/config/extended/logs/notfound/$lidarrRecordId" ]; then
touch /config/extended/cache/lidarr/list/${lidarrRecordId}-missing
fi
done done
done done
fi fi
lidarrMissingTotalRecords=$(find /config/extended/cache/lidarr/list -type f -iname "*-missing" | wc -l)
log ":: ${lidarrMissingTotalRecords} MISSING ALBUMS FOUND" log ":: ${lidarrMissingTotalRecords} MISSING ALBUMS FOUND"
# Get cutoff album list # Get cutoff album list
@ -960,11 +962,14 @@ GetMissingCutOffList () {
log ":: Downloading page $page... ($offset - $dlnumber of $lidarrCutoffTotalRecords Results)" 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') 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 for lidarrRecordId in $(echo $lidarrRecords); do
touch /config/extended/cache/lidarr/list/${lidarrRecordId}-cutoff if [ ! -f "/config/extended/logs/notfound/$lidarrRecordId" ]; then
touch /config/extended/cache/lidarr/list/${lidarrRecordId}-cutoff
fi
done done
done done
fi fi
lidarrCutoffTotalRecords=$(find /config/extended/cache/lidarr/list -type f -iname "*-cutoff" | wc -l)
log ":: ${lidarrCutoffTotalRecords} CUTOFF ALBUMS FOUND" log ":: ${lidarrCutoffTotalRecords} CUTOFF ALBUMS FOUND"
wantedListAlbumTotal=$(( $lidarrMissingTotalRecords + $lidarrCutoffTotalRecords )) wantedListAlbumTotal=$(( $lidarrMissingTotalRecords + $lidarrCutoffTotalRecords ))
@ -997,12 +1002,26 @@ SearchProcess () {
lidarrAlbumData="$(curl -s "$lidarrUrl/api/v1/album/$wantedAlbumId?apikey=${lidarrApiKey}")" lidarrAlbumData="$(curl -s "$lidarrUrl/api/v1/album/$wantedAlbumId?apikey=${lidarrApiKey}")"
lidarrAlbumType=$(echo "$lidarrAlbumData" | jq -r ".albumType") lidarrAlbumType=$(echo "$lidarrAlbumData" | jq -r ".albumType")
lidarrAlbumTitle=$(echo "$lidarrAlbumData" | jq -r ".title") lidarrAlbumTitle=$(echo "$lidarrAlbumData" | jq -r ".title")
lidarrAlbumForeignAlbumId=$(echo "$lidarrAlbumData" | jq -r ".foreignAlbumId")
if [ ! -d /config/extended/logs/notfound ]; then
mkdir -p /config/extended/logs/notfound
chmod 777 /config/extended/logs/notfound
chown abc:abc /config/extended/logs/notfound
fi
if [ -f "/config/extended/logs/notfound/$wantedAlbumId" ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..."
continue
fi
lidarrAlbumForeignAlbumId=$(echo "$lidarrAlbumData" | jq -r ".foreignAlbumId")
if [ -f "/config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId" ]; then if [ -f "/config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId" ]; then
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..." log ":: $processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..."
rm "/config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId"
touch "/config/extended/logs/notfound/$wantedAlbumId"
continue continue
fi fi
lidarrAlbumTitleClean=$(echo "$lidarrAlbumTitle" | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g') lidarrAlbumTitleClean=$(echo "$lidarrAlbumTitle" | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')
lidarrAlbumTitleCleanSpaces=$(echo "$lidarrAlbumTitle" | sed -e "s%[^[:alpha:][:digit:]]% %g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g') lidarrAlbumTitleCleanSpaces=$(echo "$lidarrAlbumTitle" | sed -e "s%[^[:alpha:][:digit:]]% %g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')
@ -1312,16 +1331,16 @@ SearchProcess () {
fi fi
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Album Not found" log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Album Not found"
if [ ! -d /config/extended/logs/downloaded/notfound ]; then if [ ! -d /config/extended/logs/notfound ]; then
mkdir -p /config/extended/logs/downloaded/notfound mkdir -p /config/extended/logs/notfound
chmod 777 /config/extended/logs/downloaded/notfound chmod 777 /config/extended/logs/notfound
chown abc:abc /config/extended/logs/downloaded/notfound chown abc:abc /config/extended/logs/notfound
fi fi
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Marking Album as notfound" log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Marking Album as notfound"
if [ ! -f /config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId ]; then if [ ! -f /config/extended/logs/notfound/$wantedAlbumId ]; then
touch /config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId touch /config/extended/logs/notfound/$wantedAlbumId
chmod 666 /config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId chmod 666 /config/extended/logs/notfound/$wantedAlbumId
chown abc:abc /config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId chown abc:abc /config/extended/logs/notfound/$wantedAlbumId
fi fi
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Search Complete..." log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Search Complete..."
done done

Loading…
Cancel
Save