1.0.151 - bug fixes, code cleanup, re-organize search operations order...

pull/16/head
RandomNinjaAtk 2 years ago committed by GitHub
parent 6da8ae2a61
commit 72e91473fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
scriptVersion="1.0.150" scriptVersion="1.0.151"
lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)"
if [ "$lidarrUrlBase" = "null" ]; then if [ "$lidarrUrlBase" = "null" ]; then
lidarrUrlBase="" lidarrUrlBase=""
@ -226,7 +226,7 @@ AddDeezerArtistToLidarr () {
lidarrArtistsData="$(curl -s "$lidarrUrl/api/v1/artist?apikey=${lidarrApiKey}")" lidarrArtistsData="$(curl -s "$lidarrUrl/api/v1/artist?apikey=${lidarrApiKey}")"
lidarrArtistIds="$(echo "${lidarrArtistsData}" | jq -r ".[].foreignArtistId")" lidarrArtistIds="$(echo "${lidarrArtistsData}" | jq -r ".[].foreignArtistId")"
deezerArtistsUrl=$(echo "${lidarrArtistsData}" | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url") deezerArtistsUrl=$(echo "${lidarrArtistsData}" | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url")
deezeArtistIds="$(echo "$deezerArtistsUrl" | grep -o '[[:digit:]]*' | sort -u)" deezerArtistIds="$(echo "$deezerArtistsUrl" | grep -o '[[:digit:]]*' | sort -u)"
log ":: Finding $description..." log ":: Finding $description..."
log ":: $getDeezerArtistsIdsCount $description Found..." log ":: $getDeezerArtistsIdsCount $description Found..."
for id in ${!getDeezerArtistsIds[@]}; do for id in ${!getDeezerArtistsIds[@]}; do
@ -236,7 +236,7 @@ AddDeezerArtistToLidarr () {
sleep $sleepTimer sleep $sleepTimer
log ":: $currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: Searching Musicbrainz for Deezer artist id ($deezerArtistId)" log ":: $currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: Searching Musicbrainz for Deezer artist id ($deezerArtistId)"
if echo "$deezeArtistIds" | grep "^${deezerArtistId}$" | read; then if echo "$deezerArtistIds" | grep "^${deezerArtistId}$" | read; then
log ":: $currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: $deezerArtistId already in Lidarr..." log ":: $currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: $deezerArtistId already in Lidarr..."
continue continue
fi fi
@ -1112,22 +1112,23 @@ SearchProcess () {
continue continue
fi fi
if [ "$dlClientSource" = "deezer" ];then if [ "$dlClientSource" = "deezer" ]; then
skipTidal=true skipTidal=true
skipDeezer=false skipDeezer=false
fi fi
if [ "$dlClientSource" = "tidal" ];then if [ "$dlClientSource" = "tidal" ]; then
skipDeezer=true skipDeezer=true
skipTidal=false skipTidal=false
fi fi
if [ "$dlClientSource" = "both" ];then if [ "$dlClientSource" = "both" ]; then
skipDeezer=false skipDeezer=false
skipTidal=false skipTidal=false
fi fi
# Search Musicbrainz for Tidal Album ID
# Search Musicbrainz for Tidal Album ID
if [ $audioLyricType = both ]; then if [ $audioLyricType = both ]; then
if [ "$skipTidal" = "false" ]; then if [ "$skipTidal" = "false" ]; then
# Verify it's not already imported into Lidarr # Verify it's not already imported into Lidarr
@ -1218,7 +1219,7 @@ SearchProcess () {
# Search for explicit matches # Search for explicit matches
if [ $audioLyricType = both ] || [ $audioLyricType = clean ]; then if [ $audioLyricType = both ] || [ $audioLyricType = clean ]; then
if [ "$skipTidal" = "false" ]; then if [ "$dlClientSource" = "both" ] || [ "$dlClientSource" = "tidal" ]; then
FuzzyTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "false" FuzzyTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "false"
fi fi
fi fi
@ -1233,7 +1234,7 @@ SearchProcess () {
# Search for clean matches # Search for clean matches
if [ $audioLyricType = both ] || [ $audioLyricType = clean ]; then if [ $audioLyricType = both ] || [ $audioLyricType = clean ]; then
if [ "$skipTidal" = "false" ]; then if [ "$dlClientSource" = "both" ] || [ "$dlClientSource" = "tidal" ]; then
FuzzyTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "false" FuzzyTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "false"
fi fi
fi fi
@ -1247,29 +1248,12 @@ SearchProcess () {
fi fi
if [ $audioLyricType = both ]; then if [ $audioLyricType = both ]; then
if [ "$skipDeezer" = "false" ]; then if [ "$dlClientSource" = "both" ] || [ "$dlClientSource" = "deezer" ]; 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
FuzzyDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" FuzzyDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId"
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: ERROR :: Various Artists is not supported by normal search, skipping..."
continue
else
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: ERROR :: Various Artists is not supported by normal search, skipping..."
continue
fi fi
else
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: ERROR :: Various Artists is not supported by normal search, skipping..."
continue
fi fi
log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: ERROR :: Various Artists is not supported by normal search, skipping..."
continue
fi fi
if [ "$skipDeezer" = "false" ]; then if [ "$skipDeezer" = "false" ]; then
@ -1293,6 +1277,7 @@ SearchProcess () {
fi fi
skipDeezer=true skipDeezer=true
fi fi
deezerArtistIds=($(echo "$deezerArtistUrl" | grep -o '[[:digit:]]*' | sort -u))
fi fi
@ -1323,10 +1308,8 @@ SearchProcess () {
# Search for explicit matches # Search for explicit matches
if [ $audioLyricType = both ] || [ $audioLyricType = explicit ]; then if [ $audioLyricType = both ] || [ $audioLyricType = explicit ]; then
# Tidal search # Tidal search
if [ "$skipTidal" = "false" ]; then if [ "$dlClientSource" = "both" ] || [ "$dlClientSource" = "tidal" ]; then
for tidalArtistId in $(echo $tidalArtistIds); do FuzzyTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "true"
ArtistTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$tidalArtistId" "true"
done
fi fi
LidarrTaskStatusCheck LidarrTaskStatusCheck
@ -1337,7 +1320,9 @@ SearchProcess () {
fi fi
if [ "$skipTidal" = "false" ]; then if [ "$skipTidal" = "false" ]; then
FuzzyTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "true" for tidalArtistId in $(echo $tidalArtistIds); do
ArtistTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$tidalArtistId" "true"
done
fi fi
LidarrTaskStatusCheck LidarrTaskStatusCheck
@ -1349,9 +1334,9 @@ SearchProcess () {
# Deezer search # Deezer search
if [ "$skipDeezer" = "false" ]; then if [ "$skipDeezer" = "false" ]; then
for dId in ${!deezeArtistIds[@]}; do for dId in ${!deezerArtistIds[@]}; do
deezeArtistId="${deezeArtistIds[$dId]}" deezerArtistId="${deezerArtistIds[$dId]}"
ArtistDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$deezeArtistId" "true" ArtistDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$deezerArtistId" "true"
done done
fi fi
@ -1368,10 +1353,7 @@ SearchProcess () {
if [ $audioLyricType = both ] || [ $audioLyricType = clean ]; then if [ $audioLyricType = both ] || [ $audioLyricType = clean ]; then
# Tidal search # Tidal search
if [ "$skipTidal" = "false" ]; then if [ "$skipTidal" = "false" ]; then
FuzzyTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "false"
for tidalArtistId in $(echo $tidalArtistIds); do
ArtistTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$tidalArtistId" "false"
done
fi fi
LidarrTaskStatusCheck LidarrTaskStatusCheck
@ -1382,7 +1364,9 @@ SearchProcess () {
fi fi
if [ "$skipTidal" = "false" ]; then if [ "$skipTidal" = "false" ]; then
FuzzyTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "false" for tidalArtistId in $(echo $tidalArtistIds); do
ArtistTidalSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$tidalArtistId" "false"
done
fi fi
LidarrTaskStatusCheck LidarrTaskStatusCheck
@ -1394,9 +1378,9 @@ SearchProcess () {
# Deezer search # Deezer search
if [ "$skipDeezer" = "false" ]; then if [ "$skipDeezer" = "false" ]; then
for dId in ${!deezeArtistIds[@]}; do for dId in ${!deezerArtistIds[@]}; do
deezeArtistId="${deezeArtistIds[$dId]}" deezerArtistId="${deezerArtistIds[$dId]}"
ArtistDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$deezeArtistId" "false" ArtistDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" "$deezerArtistId" "false"
done done
fi fi
fi fi
@ -1410,14 +1394,7 @@ SearchProcess () {
# Fallback/last resort Fuzzy Search # Fallback/last resort Fuzzy Search
if [ $audioLyricType = both ]; then if [ $audioLyricType = both ]; then
if [ "$skipDeezer" = "false" ]; then if [ "$dlClientSource" = "both" ] || [ "$dlClientSource" = "deezer" ]; 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
FuzzyDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId" FuzzyDeezerSearch "$processNumber of $wantedListAlbumTotal" "$wantedAlbumId"
fi fi
fi fi
@ -1562,7 +1539,12 @@ FuzzyDeezerSearch () {
fi fi
if [ ! -z "$deezerSearch" ]; then if [ ! -z "$deezerSearch" ]; then
for deezerAlbumID in $(echo "$deezerSearch" | jq -r .album.id | sort -u); do for deezerAlbumID in $(echo "$deezerSearch" | jq -r .album.id | sort -u); do
deezerAlbumData="$(echo "$deezerSearch" | jq -r ".album | select(.id==$deezerAlbumID)")" if [ -f "/config/extended/cache/deezer/${msuicbrainzDeezerDownloadAlbumID}.json" ]; then
deezerArtistAlbumData="$(cat "/config/extended/cache/deezer/$deezerAlbumID.json")"
else
deezerArtistAlbumData="$(curl -s "https://api.deezer.com/album/$deezerAlbumID")"
fi
deezerAlbumTrackCount="$(echo $deezerArtistAlbumData | jq -r .nb_tracks)"
deezerAlbumTitle=$(echo "$deezerAlbumData"| jq -r .title | head -n1) deezerAlbumTitle=$(echo "$deezerAlbumData"| jq -r .title | head -n1)
lidarrAlbumReleaseTitleClean=$(echo "$lidarrAlbumReleaseTitle" | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g') lidarrAlbumReleaseTitleClean=$(echo "$lidarrAlbumReleaseTitle" | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')
deezerAlbumTitleClean=$(echo ${deezerAlbumTitle} | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g') deezerAlbumTitleClean=$(echo ${deezerAlbumTitle} | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')
@ -1575,7 +1557,7 @@ FuzzyDeezerSearch () {
DownloadProcess "$deezerAlbumID" "DEEZER" "$lidarrAlbumReleaseYear" "$lidarrAlbumReleaseTitle" DownloadProcess "$deezerAlbumID" "DEEZER" "$lidarrAlbumReleaseYear" "$lidarrAlbumReleaseTitle"
# Verify it was successfully imported into Lidarr # Verify it was successfully imported into Lidarr
LidarrTaskStatusCheck LidarrTaskStatusCheck
CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" "notbeets" "$lidarrAlbumReleaseTrackCount" CheckLidarrBeforeImport "$lidarrAlbumForeignAlbumId" "notbeets" "$deezerAlbumTrackCount"
if [ $alreadyImported = true ]; then if [ $alreadyImported = true ]; then
break 2 break 2
fi fi
@ -1934,7 +1916,7 @@ AddRelatedArtists () {
lidarrArtistLinkDeezerIds="$(echo "${lidarrArtistsData}" | jq -r ".[] | .links[] | select(.name==\"deezer\") | .url" | grep -o '[[:digit:]]*')" lidarrArtistLinkDeezerIds="$(echo "${lidarrArtistsData}" | jq -r ".[] | .links[] | select(.name==\"deezer\") | .url" | grep -o '[[:digit:]]*')"
log ":: $lidarrArtistTotal Artists Found" log ":: $lidarrArtistTotal Artists Found"
deezerArtistsUrl=$(echo "${lidarrArtistsData}" | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url") deezerArtistsUrl=$(echo "${lidarrArtistsData}" | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url")
deezeArtistIds="$(echo "$deezerArtistsUrl" | grep -o '[[:digit:]]*' | sort -u)" deezerArtistIds="$(echo "$deezerArtistsUrl" | grep -o '[[:digit:]]*' | sort -u)"
for id in ${!lidarrArtistList[@]}; do for id in ${!lidarrArtistList[@]}; do
artistNumber=$(( $id + 1 )) artistNumber=$(( $id + 1 ))

Loading…
Cancel
Save