1.0.064 - Improve cache process and completed artist handeling

#208 

Addresses items 2 & 3 from: https://github.com/RandomNinjaAtk/docker-lidarr-extended/issues/208#issuecomment-1456073016

It removes the caching timeout and if the local cache is updated, it removes the log file that prevents the artist from being processed by the script.
pull/226/head
RandomNinjaAtk 2 years ago committed by GitHub
parent aa5c68b56c
commit f585973994
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.063" scriptVersion="1.0.064"
if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then
lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
@ -107,8 +107,8 @@ CacheMusicbrainzRecords () {
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Processing..." log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Processing..."
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Checking Musicbrainz for recordings..." log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Checking Musicbrainz for recordings..."
musicbrainzArtistRecordings=$(curl -s -A "$agent" "$musicbrainzMirror/ws/2/recording?artist=$lidarrArtistMusicbrainzId&limit=1&offset=0&fmt=json") musicbrainzArtistRecordings=$(curl -s -A "$agent" "$musicbrainzMirror/ws/2/recording?artist=$lidarrArtistMusicbrainzId&limit=1&offset=0&fmt=json")
sleep 1 sleep 1
musicbrainzArtistRecordingsCount=$(echo "$musicbrainzArtistRecordings" | jq -r '."recording-count"') musicbrainzArtistRecordingsCount=$(echo "$musicbrainzArtistRecordings" | jq -r '."recording-count"')
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: $musicbrainzArtistRecordingsCount recordings found..." log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: $musicbrainzArtistRecordingsCount recordings found..."
if [ ! -d /config/extended/cache/musicbrainz ]; then if [ ! -d /config/extended/cache/musicbrainz ]; then
@ -116,18 +116,15 @@ CacheMusicbrainzRecords () {
chmod 777 /config/extended/cache/musicbrainz chmod 777 /config/extended/cache/musicbrainz
fi fi
if [ -f "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" ]; then
if ! [[ $(find "/config/extended/cache/musicbrainz" -type f -name "$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" -mtime +7 -print) ]]; then
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Previously cached, skipping..."
return
fi
fi
if [ -f "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" ]; then if [ -f "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" ]; then
musicbrainzArtistDownloadedRecordingsCount=$(cat "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" | jq -r .id | wc -l) musicbrainzArtistDownloadedRecordingsCount=$(cat "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" | jq -r .id | wc -l)
if [ $musicbrainzArtistRecordingsCount -ne $musicbrainzArtistDownloadedRecordingsCount ]; then if [ $musicbrainzArtistRecordingsCount -ne $musicbrainzArtistDownloadedRecordingsCount ]; then
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Previously cached, data needs to be updated..." log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Previously cached, data needs to be updated..."
rm "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" rm "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json"
if [ -f /config/extended/extended/logs/video/complete/$lidarrArtistMusicbrainzId ]; then
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Removing Artist completed log file to allow artist re-processing..."
rm /config/extended/extended/logs/video/complete/$lidarrArtistMusicbrainzId
fi
fi fi
fi fi
@ -265,7 +262,13 @@ ImvdbCache () {
if [ "$artistImvdbVideoUrlsCount" == "$cachedArtistImvdbVideoUrlsCount" ]; then if [ "$artistImvdbVideoUrlsCount" == "$cachedArtistImvdbVideoUrlsCount" ]; then
log "$processCount of $lidarrArtistIdsCount :: IMVDB :: $lidarrArtistName :: Chache is already up-to-date, skipping..." log "$processCount of $lidarrArtistIdsCount :: IMVDB :: $lidarrArtistName :: Chache is already up-to-date, skipping..."
return return
else
if [ -f /config/extended/extended/logs/video/complete/$lidarrArtistMusicbrainzId ]; then
log "$processCount of $lidarrArtistIdsCount :: IMVDB :: $lidarrArtistName :: Removing Artist completed log file to allow artist re-processing..."
rm /config/extended/extended/logs/video/complete/$lidarrArtistMusicbrainzId
fi
fi fi
sleep 0.5 sleep 0.5
imvdbProcessCount=0 imvdbProcessCount=0
@ -605,7 +608,7 @@ lidarrArtistIdsCount=$(echo "$lidarrArtistIds" | wc -l)
processCount=0 processCount=0
for lidarrArtistId in $(echo $lidarrArtistIds); do for lidarrArtistId in $(echo $lidarrArtistIds); do
processCount=$(( $processCount + 1)) processCount=$(( $processCount + 1))
lidarrArtistData=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/artist/$lidarrArtistId?apikey=$lidarrApiKey") lidarrArtistData=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/artist/$lidarrArtistId?apikey=$lidarrApiKey")
lidarrArtistName=$(echo $lidarrArtistData | jq -r .artistName) lidarrArtistName=$(echo $lidarrArtistData | jq -r .artistName)
lidarrArtistMusicbrainzId=$(echo $lidarrArtistData | jq -r .foreignArtistId) lidarrArtistMusicbrainzId=$(echo $lidarrArtistData | jq -r .foreignArtistId)
@ -613,13 +616,6 @@ for lidarrArtistId in $(echo $lidarrArtistIds); do
log "$processCount of $lidarrArtistIdsCount :: $lidarrArtistName :: Skipping, not processed by design..." log "$processCount of $lidarrArtistIdsCount :: $lidarrArtistName :: Skipping, not processed by design..."
continue continue
fi fi
if [ -d /config/extended/logs/video/complete ]; then
if [ -f "/config/extended/logs/video/complete/$lidarrArtistMusicbrainzId" ]; then
log "$processCount of $lidarrArtistIdsCount :: $lidarrArtistName :: Music Videos previously downloaded, skipping..."
continue
fi
fi
lidarrArtistPath="$(echo "${lidarrArtistData}" | jq -r " .path")" lidarrArtistPath="$(echo "${lidarrArtistData}" | jq -r " .path")"
lidarrArtistFolder="$(basename "${lidarrArtistPath}")" lidarrArtistFolder="$(basename "${lidarrArtistPath}")"
@ -644,6 +640,13 @@ for lidarrArtistId in $(echo $lidarrArtistIds); do
CacheMusicbrainzRecords CacheMusicbrainzRecords
ImvdbCache ImvdbCache
if [ -d /config/extended/logs/video/complete ]; then
if [ -f "/config/extended/logs/video/complete/$lidarrArtistMusicbrainzId" ]; then
log "$processCount of $lidarrArtistIdsCount :: $lidarrArtistName :: Music Videos previously downloaded, skipping..."
continue
fi
fi
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Checking records for videos..." log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Checking records for videos..."
musicbrainzArtistVideoRecordings=$(cat "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" | jq -r "select(.video==true)") musicbrainzArtistVideoRecordings=$(cat "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" | jq -r "select(.video==true)")

Loading…
Cancel
Save