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
scriptVersion="1.0.063"
scriptVersion="1.0.064"
if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then
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 :: Checking Musicbrainz for recordings..."
musicbrainzArtistRecordings=$(curl -s -A "$agent" "$musicbrainzMirror/ws/2/recording?artist=$lidarrArtistMusicbrainzId&limit=1&offset=0&fmt=json")
sleep 1
musicbrainzArtistRecordingsCount=$(echo "$musicbrainzArtistRecordings" | jq -r '."recording-count"')
sleep 1
musicbrainzArtistRecordingsCount=$(echo "$musicbrainzArtistRecordings" | jq -r '."recording-count"')
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: $musicbrainzArtistRecordingsCount recordings found..."
if [ ! -d /config/extended/cache/musicbrainz ]; then
@ -116,18 +116,15 @@ CacheMusicbrainzRecords () {
chmod 777 /config/extended/cache/musicbrainz
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
musicbrainzArtistDownloadedRecordingsCount=$(cat "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" | jq -r .id | wc -l)
if [ $musicbrainzArtistRecordingsCount -ne $musicbrainzArtistDownloadedRecordingsCount ]; then
log "$processCount of $lidarrArtistIdsCount :: MBZDB :: $lidarrArtistName :: Previously cached, data needs to be updated..."
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
@ -265,8 +262,14 @@ ImvdbCache () {
if [ "$artistImvdbVideoUrlsCount" == "$cachedArtistImvdbVideoUrlsCount" ]; then
log "$processCount of $lidarrArtistIdsCount :: IMVDB :: $lidarrArtistName :: Chache is already up-to-date, skipping..."
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
sleep 0.5
imvdbProcessCount=0
for imvdbVideoUrl in $(echo "$artistImvdbVideoUrls"); do
@ -605,7 +608,7 @@ lidarrArtistIdsCount=$(echo "$lidarrArtistIds" | wc -l)
processCount=0
for lidarrArtistId in $(echo $lidarrArtistIds); do
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)
lidarrArtistMusicbrainzId=$(echo $lidarrArtistData | jq -r .foreignArtistId)
@ -614,13 +617,6 @@ for lidarrArtistId in $(echo $lidarrArtistIds); do
continue
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")"
lidarrArtistFolder="$(basename "${lidarrArtistPath}")"
lidarrArtistFolderNoDisambig="$(echo "$lidarrArtistFolder" | sed "s/ (.*)$//g" | sed "s/\.$//g")" # Plex Sanitization, remove disambiguation
@ -645,6 +641,13 @@ for lidarrArtistId in $(echo $lidarrArtistIds); do
CacheMusicbrainzRecords
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..."
musicbrainzArtistVideoRecordings=$(cat "/config/extended/cache/musicbrainz/$lidarrArtistId--$lidarrArtistMusicbrainzId--recordings.json" | jq -r "select(.video==true)")
musicbrainzArtistVideoRecordingsCount=$(echo "$musicbrainzArtistVideoRecordings" | jq -r .id | wc -l)

Loading…
Cancel
Save