2.9 - Improved caching process and logging output for debugging

#44 - Additional improvements
This commit is contained in:
RandomNinjaAtk 2023-08-01 11:58:19 +00:00 committed by GitHub
parent 4b84be9d74
commit a6e26d7a72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,5 @@
#!/usr/bin/with-contenv bash #!/usr/bin/with-contenv bash
scriptVersion="2.8" scriptVersion="2.9"
scriptName="Video" scriptName="Video"
### Import Settings ### Import Settings
@ -101,14 +101,37 @@ ImvdbCache () {
log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: Recording Artist Slug into cache" log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: Recording Artist Slug into cache"
echo -n "$lidarrArtistName" > /config/extended/cache/imvdb/$artistImvdbSlug echo -n "$lidarrArtistName" > /config/extended/cache/imvdb/$artistImvdbSlug
fi fi
count=0
attemptError="false"
until false; do
count=$(( $count + 1 ))
artistImvdbVideoUrls=$(wget "https://imvdb.com/n/$artistImvdbSlug" -O - | grep "$artistImvdbSlug" | grep -Eoi '<a [^>]+>' | grep -Eo 'href="[^\"]+"' | grep -Eo '(http|https)://[^"]+' | grep -i ".com/video/$artistImvdbSlug/" | sed "s%/[0-9]$%%g" | sort -u) artistImvdbVideoUrls=$(wget "https://imvdb.com/n/$artistImvdbSlug" -O - | grep "$artistImvdbSlug" | grep -Eoi '<a [^>]+>' | grep -Eo 'href="[^\"]+"' | grep -Eo '(http|https)://[^"]+' | grep -i ".com/video/$artistImvdbSlug/" | sed "s%/[0-9]$%%g" | sort -u)
if echo "$artistImvdbVideoUrls" | grep -i "imvdb.com" | read; then
break
else
log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: ERROR :: Cannot connect to imvdb, retrying..."
sleep 0.5
fi
if [ $count == 10 ]; then
log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: ${imvdbProcessCount}/${artistImvdbVideoUrlsCount} :: ERROR :: All attempts at connecting failed, skipping..."
attemptError="true"
break
fi
done
if [ "$attemptError" == "true" ]; then
return
fi
artistImvdbVideoUrlsCount=$(echo "$artistImvdbVideoUrls" | wc -l) artistImvdbVideoUrlsCount=$(echo "$artistImvdbVideoUrls" | wc -l)
cachedArtistImvdbVideoUrlsCount=$(ls /config/extended/cache/imvdb/$lidarrArtistMusicbrainzId--* 2>/dev/null | wc -l) cachedArtistImvdbVideoUrlsCount=$(ls /config/extended/cache/imvdb/$lidarrArtistMusicbrainzId--* 2>/dev/null | wc -l)
if [ "$artistImvdbVideoUrlsCount" == "$cachedArtistImvdbVideoUrlsCount" ]; then if [ "$artistImvdbVideoUrlsCount" == "$cachedArtistImvdbVideoUrlsCount" ]; then
log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: Chache is already up-to-date, skipping..." log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: Chache is already up-to-date ($artistImvdbVideoUrlsCount==$cachedArtistImvdbVideoUrlsCount), skipping..."
return return
else else
log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: Chache needs updating ($artistImvdbVideoUrlsCount==$cachedArtistImvdbVideoUrlsCount)..."
if [ -f "/config/extended/logs/video/complete/$lidarrArtistMusicbrainzId" ]; then if [ -f "/config/extended/logs/video/complete/$lidarrArtistMusicbrainzId" ]; then
log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: Removing Artist completed log file to allow artist re-processing..." log "${processCount}/${lidarrArtistIdsCount} :: $lidarrArtistName :: IMVDB :: Removing Artist completed log file to allow artist re-processing..."
rm "/config/extended/logs/video/complete/$lidarrArtistMusicbrainzId" rm "/config/extended/logs/video/complete/$lidarrArtistMusicbrainzId"