From 768d468fe16196dc52655ce4077f3ed701d09f57 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Thu, 7 Jul 2022 13:05:14 +0000 Subject: [PATCH] v1.0.94 - tidal bug fixes and enhancements, get album ID from musicbrainz --- root/scripts/download.sh | 47 +++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/root/scripts/download.sh b/root/scripts/download.sh index 33b8049..e414dc3 100644 --- a/root/scripts/download.sh +++ b/root/scripts/download.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.93" +scriptVersion="1.0.94" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" if [ "$lidarrUrlBase" = "null" ]; then lidarrUrlBase="" @@ -847,7 +847,7 @@ SearchProcess () { skipTidal=false fi - # Search Musicbrainz for Album ID, + # Search Musicbrainz for Deezer Album ID if [ $audioLyricType = both ]; then if [ "$skipDeezer" = "false" ]; then # Verify it's not already imported into Lidarr @@ -886,6 +886,45 @@ SearchProcess () { fi fi fi + + # Search Musicbrainz for Tidal Album ID + if [ $audioLyricType = both ]; then + if [ "$skipTidal" = "false" ]; then + # Verify it's not already imported into Lidarr + LidarrTaskStatusCheck + CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" "notbeets" + if [ $alreadyImported = true ]; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Already Imported, skipping..." + continue + fi + + # Search Musicbrainz + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Tidal Album ID :: Searching for Album ID..." + msuicbrainzTidalDownloadAlbumID=$(curl -s "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") + + # 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')" + downloadedReleaseDate="$(echo ${tidalArtistAlbumData} | jq -r .releaseDate)" + if [ "$downloadedReleaseDate" = "null" ]; then + downloadedReleaseDate=$(echo $tidalArtistAlbumData | jq -r '.streamStartDate') + fi + downloadedReleaseYear="${downloadedReleaseDate:0:4}" + DownloadProcess "$msuicbrainzDeezerDownloadAlbumID" "TIDAL" "$downloadedReleaseYear" + + # Verify it was successfully imported into Lidarr + LidarrTaskStatusCheck + CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" "notbeets" + if [ $alreadyImported = true ]; then + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: Already Imported, skipping..." + continue + fi + else + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: Musicbrainz Tidal Album ID :: NOT FOUND!" + fi + fi + fi if [ "$skipDeezer" = "false" ]; then @@ -1106,9 +1145,7 @@ SearchProcess () { # Tidal search if [ "$skipTidal" = "false" ]; then - tidalArtistAlbumsIds=($(echo "${tidalArtistAlbumsData}" | jq -r "select(.explicit=="false") | .id")) - for id in ${!tidalArtistAlbumsIds[@]}; do processNumberTwo=$(( $id + 1 )) tidalArtistAlbumId="${tidalArtistAlbumsIds[$id]}" @@ -1128,7 +1165,7 @@ SearchProcess () { fi DownloadProcess "$tidalArtistAlbumId" "TIDAL" "$downloadedReleaseYear" else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumReleaseTitleClean vs $deezerArtistAlbumTitleClean :: CLEAN Tidal MATCH NOT Found" + log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumReleaseTitleClean vs $tidalArtistAlbumTitleClean :: CLEAN Tidal MATCH NOT Found" fi LidarrTaskStatusCheck done