From c72ff79a42dd5c1c4dd6a0597fe8b93ad9188116 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Tue, 2 Aug 2022 14:28:21 +0000 Subject: [PATCH] 1.0.223 - New "GetDeezerAlbumInfo" process validate json data, correct typo --- root/scripts/audio.sh | 64 ++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/root/scripts/audio.sh b/root/scripts/audio.sh index 4e47059..52cba4a 100644 --- a/root/scripts/audio.sh +++ b/root/scripts/audio.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.222" +scriptVersion="1.0.223" if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" if [ "$lidarrUrlBase" = "null" ]; then @@ -1288,22 +1288,19 @@ SearchProcess () { # Search Musicbrainz log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Deezer :: Searching for Album ID..." - msuicbrainzDeezerDownloadAlbumID=$(curl -s -A "$agent" "https://musicbrainz.org/ws/2/release?release-group=$lidarrAlbumForeignAlbumId&inc=url-rels&fmt=json" | jq -r | grep "deezer.com" | grep "album" | head -n 1 | sed -e "s%[^[:digit:]]%%g") + musicbrainzDeezerDownloadAlbumID=$(curl -s -A "$agent" "https://musicbrainz.org/ws/2/release?release-group=$lidarrAlbumForeignAlbumId&inc=url-rels&fmt=json" | jq -r | grep "deezer.com" | grep "album" | head -n 1 | sed -e "s%[^[:digit:]]%%g") # Process Album ID if found - if [ ! -z $msuicbrainzDeezerDownloadAlbumID ]; then + if [ ! -z $musicbrainzDeezerDownloadAlbumID ]; then log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Deezer :: FOUND!" - if [ -f "/config/extended/cache/deezer/${msuicbrainzDeezerDownloadAlbumID}.json" ]; then - deezerArtistAlbumData="$(cat "/config/extended/cache/deezer/${msuicbrainzDeezerDownloadAlbumID}.json")" - else - deezerArtistAlbumData="$(curl -s "https://api.deezer.com/album/${msuicbrainzDeezerDownloadAlbumID}")" - fi + GetDeezerAlbumInfo "${musicbrainzDeezerDownloadAlbumID}" + deezerArtistAlbumData=$(cat "/config/extended/cache/deezer/$musicbrainzDeezerDownloadAlbumID.json") deezerAlbumTrackCount="$(echo "$deezerArtistAlbumData" | jq -r .nb_tracks)" deezerAlbumTitle="$(echo "$deezerArtistAlbumData"| jq -r .title)" downloadedReleaseDate="$(echo "$deezerArtistAlbumData" | jq -r .release_date)" downloadedReleaseYear="${downloadedReleaseDate:0:4}" log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Deezer :: Downloading $deezerAlbumTrackCount Tracks :: $deezerAlbumTitle ($downloadedReleaseYear)" - DownloadProcess "$msuicbrainzDeezerDownloadAlbumID" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount" + DownloadProcess "$musicbrainzDeezerDownloadAlbumID" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount" # Verify it was successfully imported into Lidarr LidarrTaskStatusCheck @@ -1336,6 +1333,35 @@ SearchProcess () { done } +GetDeezerAlbumInfo () { + until false + do + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Getting Album info..." + if [ ! -f "/config/extended/cache/deezer/$1.json" ]; then + curl -s "https://api.deezer.com/album/$1" -o "/config/extended/cache/deezer/$1.json" + sleep $sleepTimer + fi + if [ -f "/config/extended/cache/deezer/$1.json" ]; then + if jq -e . >/dev/null 2>&1 <<<"$(cat /config/extended/cache/deezer/$1.json)"; then + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Album info downloaded and verified..." + chmod 666 /config/extended/cache/deezer/$1.json + chown abc:abc /config/extended/cache/deezer/$1.json + albumInfoVerified=true + break + else + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Error getting album information" + if [ -f "/config/extended/cache/deezer/$1.json" ]; then + rm "/config/extended/cache/deezer/$1.json" + fi + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Retrying..." + fi + else + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: ERROR :: Download Failed" + fi + done + +} + ArtistDeezerSearch () { # Required Inputs # $1 Process ID @@ -1381,14 +1407,8 @@ ArtistDeezerSearch () { elif [ $characterMath -lt 0 ]; then continue fi - - if [ -f "/config/extended/cache/deezer/$deezerAlbumID.json" ]; then - deezerAlbumData="$(cat "/config/extended/cache/deezer/$deezerAlbumID.json")" - else - getDeezerAlbumData="$(curl -s "https://api.deezer.com/album/$deezerAlbumID" > "/config/extended/cache/deezer/$deezerAlbumID.json")" - sleep $sleepTimer - deezerAlbumData="$(cat "/config/extended/cache/deezer/$deezerAlbumID.json")" - fi + GetDeezerAlbumInfo "${deezerAlbumID}" + deezerAlbumData="$(cat "/config/extended/cache/deezer/$deezerAlbumID.json")" deezerAlbumTrackCount="$(echo "$deezerAlbumData" | jq -r .nb_tracks)" deezerAlbumExplicitLyrics="$(echo "$deezerAlbumData" | jq -r .explicit_lyrics)" deezerAlbumTitle="$(echo "$deezerAlbumData"| jq -r .title)" @@ -1477,14 +1497,8 @@ FuzzyDeezerSearch () { continue fi - if [ -f "/config/extended/cache/deezer/$deezerAlbumID.json" ]; then - deezerAlbumData="$(cat "/config/extended/cache/deezer/$deezerAlbumID.json")" - else - getDeezerAlbumData="$(curl -s "https://api.deezer.com/album/$deezerAlbumID" > "/config/extended/cache/deezer/$deezerAlbumID.json")" - sleep $sleepTimer - deezerAlbumData="$(cat "/config/extended/cache/deezer/$deezerAlbumID.json")" - fi - + GetDeezerAlbumInfo "${deezerAlbumID}" + deezerAlbumData="$(cat "/config/extended/cache/deezer/$deezerAlbumID.json")" deezerAlbumTrackCount="$(echo "$deezerAlbumData" | jq -r .nb_tracks)" deezerAlbumExplicitLyrics="$(echo "$deezerAlbumData" | jq -r .explicit_lyrics)" deezerAlbumTitle="$(echo "$deezerAlbumData"| jq -r .title)"