diff --git a/root/scripts/download.sh b/root/scripts/download.sh index a3378e8..bde53d8 100644 --- a/root/scripts/download.sh +++ b/root/scripts/download.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.135" +scriptVersion="1.0.136" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" if [ "$lidarrUrlBase" = "null" ]; then lidarrUrlBase="" @@ -1049,9 +1049,9 @@ SearchProcess () { skipTidal=false fi - # Search Musicbrainz for Deezer Album ID + # Search Musicbrainz for Tidal Album ID if [ $audioLyricType = both ]; then - if [ "$skipDeezer" = "false" ]; then + if [ "$skipTidal" = "false" ]; then # Verify it's not already imported into Lidarr LidarrTaskStatusCheck CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" "notbeets" @@ -1061,20 +1061,15 @@ SearchProcess () { fi # Search Musicbrainz - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Deezer Album ID :: 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") + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Tidal Album ID :: Searching for Album ID..." + msuicbrainzTidalDownloadAlbumID=$(curl -s -A "$agent" "https://musicbrainz.org/ws/2/release?release-group=$lidarrAlbumForeignAlbumId&inc=url-rels&fmt=json" | jq -r | grep "tidal.com" | head -n 1 | sed -e "s%[^[:digit:]]%%g") sleep 1.5 - + # Process Album ID if found - if [ ! -z $msuicbrainzDeezerDownloadAlbumID ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Deezer Album ID :: 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 - - DownloadProcess "$msuicbrainzDeezerDownloadAlbumID" "DEEZER" "$lidarrAlbumReleaseYear" "$lidarrAlbumTitle" + if [ ! -z $msuicbrainzTidalDownloadAlbumID ]; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Tidal Album ID :: FOUND!" + tidalArtistAlbumData="$(curl -s "https://api.tidal.com/v1/albums/${msuicbrainzTidalDownloadAlbumID}?countryCode=$tidalCountryCode" -H 'x-tidal-token: CzET4vdadNUFQ5JU')" + DownloadProcess "$msuicbrainzTidalDownloadAlbumID" "TIDAL" "$lidarrAlbumReleaseYear" "$lidarrAlbumTitle" # Verify it was successfully imported into Lidarr LidarrTaskStatusCheck @@ -1084,14 +1079,14 @@ SearchProcess () { continue fi else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Deezer Album ID :: NOT FOUND!" + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Tidal Album ID :: NOT FOUND!" fi fi fi - # Search Musicbrainz for Tidal Album ID + # Search Musicbrainz for Deezer Album ID if [ $audioLyricType = both ]; then - if [ "$skipTidal" = "false" ]; then + if [ "$skipDeezer" = "false" ]; then # Verify it's not already imported into Lidarr LidarrTaskStatusCheck CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" "notbeets" @@ -1101,15 +1096,20 @@ SearchProcess () { fi # Search Musicbrainz - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Tidal Album ID :: Searching for Album ID..." - msuicbrainzTidalDownloadAlbumID=$(curl -s -A "$agent" "https://musicbrainz.org/ws/2/release?release-group=$lidarrAlbumForeignAlbumId&inc=url-rels&fmt=json" | jq -r | grep "tidal.com" | head -n 1 | sed -e "s%[^[:digit:]]%%g") + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Deezer Album ID :: 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") sleep 1.5 - + # Process Album ID if found - if [ ! -z $msuicbrainzTidalDownloadAlbumID ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Tidal Album ID :: FOUND!" - tidalArtistAlbumData="$(curl -s "https://api.tidal.com/v1/albums/${msuicbrainzTidalDownloadAlbumID}?countryCode=$tidalCountryCode" -H 'x-tidal-token: CzET4vdadNUFQ5JU')" - DownloadProcess "$msuicbrainzTidalDownloadAlbumID" "TIDAL" "$lidarrAlbumReleaseYear" "$lidarrAlbumTitle" + if [ ! -z $msuicbrainzDeezerDownloadAlbumID ]; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Deezer Album ID :: 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 + + DownloadProcess "$msuicbrainzDeezerDownloadAlbumID" "DEEZER" "$lidarrAlbumReleaseYear" "$lidarrAlbumTitle" # Verify it was successfully imported into Lidarr LidarrTaskStatusCheck @@ -1119,7 +1119,7 @@ SearchProcess () { continue fi else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Tidal Album ID :: NOT FOUND!" + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Deezer Album ID :: NOT FOUND!" fi fi fi @@ -1234,18 +1234,17 @@ SearchProcess () { # Search for explicit matches if [ $audioLyricType = both ] || [ $audioLyricType = explicit ]; then - # Deezer search - if [ "$skipDeezer" = "false" ]; then - for dId in ${!deezeArtistIds[@]}; do - deezeArtistId="${deezeArtistIds[$dId]}" - if [ ! -f "/config/extended/cache/deezer/$deezeArtistId-albums.json" ]; then + # Tidal search + if [ "$skipTidal" = "false" ]; then + for tidalArtistId in $(echo $tidalArtistIds); do + if [ ! -f "/config/extended/cache/tidal/$tidalArtistId-albums.json" ]; then continue fi - ArtistDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$deezeArtistId" "true" - done + ArtistTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$tidalArtistId" "true" + done fi - + LidarrTaskStatusCheck CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" "notbeets" if [ $alreadyImported = true ]; then @@ -1253,15 +1252,16 @@ SearchProcess () { continue fi - # Tidal search - if [ "$skipTidal" = "false" ]; then - for tidalArtistId in $(echo $tidalArtistIds); do - if [ ! -f "/config/extended/cache/tidal/$tidalArtistId-albums.json" ]; then + # Deezer search + if [ "$skipDeezer" = "false" ]; then + for dId in ${!deezeArtistIds[@]}; do + deezeArtistId="${deezeArtistIds[$dId]}" + if [ ! -f "/config/extended/cache/deezer/$deezeArtistId-albums.json" ]; then continue fi - ArtistTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$tidalArtistId" "true" - done + ArtistDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$deezeArtistId" "true" + done fi fi @@ -1274,18 +1274,18 @@ SearchProcess () { # Search for clean matches if [ $audioLyricType = both ] || [ $audioLyricType = clean ]; then - # Deezer search - if [ "$skipDeezer" = "false" ]; then - for dId in ${!deezeArtistIds[@]}; do - deezeArtistId="${deezeArtistIds[$dId]}" - if [ ! -f "/config/extended/cache/deezer/$deezeArtistId-albums.json" ]; then + # Tidal search + if [ "$skipTidal" = "false" ]; then + + for tidalArtistId in $(echo $tidalArtistIds); do + if [ ! -f "/config/extended/cache/tidal/$tidalArtistId-albums.json" ]; then continue fi - ArtistDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$deezeArtistId" "false" + ArtistTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$tidalArtistId" "false" done fi - + LidarrTaskStatusCheck CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" "notbeets" if [ $alreadyImported = true ]; then @@ -1293,15 +1293,15 @@ SearchProcess () { continue fi - # Tidal search - if [ "$skipTidal" = "false" ]; then - - for tidalArtistId in $(echo $tidalArtistIds); do - if [ ! -f "/config/extended/cache/tidal/$tidalArtistId-albums.json" ]; then + # Deezer search + if [ "$skipDeezer" = "false" ]; then + for dId in ${!deezeArtistIds[@]}; do + deezeArtistId="${deezeArtistIds[$dId]}" + if [ ! -f "/config/extended/cache/deezer/$deezeArtistId-albums.json" ]; then continue fi - ArtistTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$tidalArtistId" "false" + ArtistDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$deezeArtistId" "false" done fi fi