v2.18 - Simplify search process

Removing unnecessary code, simplifying search/download process.

If a download fails to import, it will take multiple runs of the script for it to search every album title/track count variation for an album. Which can result in the process being slower, however, it greatly simplifies the process making things easier to maintain...
This commit is contained in:
RandomNinjaAtk 2023-09-21 18:42:57 -04:00 committed by GitHub
parent a2ec66eebe
commit c2e702a49c
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.16" scriptVersion="2.18"
scriptName="Audio" scriptName="Audio"
### Import Settings ### Import Settings
@ -354,6 +354,7 @@ DownloadProcess () {
# $4 = Album Title that matches Album ID Metadata # $4 = Album Title that matches Album ID Metadata
# $5 = Expected Track Count # $5 = Expected Track Count
lidarrDownloadImportNotfication="false"
# Create Required Directories # Create Required Directories
if [ ! -d "$audioPath/incomplete" ]; then if [ ! -d "$audioPath/incomplete" ]; then
@ -682,41 +683,13 @@ DownloadProcess () {
if [ -d "$audioPath/complete/$downloadedAlbumFolder" ]; then if [ -d "$audioPath/complete/$downloadedAlbumFolder" ]; then
NotifyLidarrForImport "$audioPath/complete/$downloadedAlbumFolder" NotifyLidarrForImport "$audioPath/complete/$downloadedAlbumFolder"
lidarrDownloadImportNotfication="true"
LidarrTaskStatusCheck LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
rm -rf "$audioPath"/incomplete/*
fi
fi
if [ -d "$audioPath/complete/$downloadedAlbumFolder" ]; then
NotifyLidarrForImport "$audioPath/complete/$downloadedAlbumFolder"
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
rm -rf "$audioPath"/incomplete/*
fi
fi
if [ -d "$audioPath/complete/$downloadedAlbumFolder" ]; then
NotifyLidarrForImport "$audioPath/complete/$downloadedAlbumFolder"
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
rm -rf "$audioPath"/incomplete/*
fi
fi fi
if [ -d "$audioPath/complete/$downloadedAlbumFolder" ]; then if [ -d "$audioPath/complete/$downloadedAlbumFolder" ]; then
rm -rf "$audioPath"/incomplete/* rm -rf "$audioPath"/incomplete/*
fi fi
# NotifyPlexToScan
} }
ProcessWithBeets () { ProcessWithBeets () {
@ -899,16 +872,6 @@ NotifyLidarrForImport () {
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: LIDARR IMPORT NOTIFICATION SENT! :: $1" log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: LIDARR IMPORT NOTIFICATION SENT! :: $1"
} }
NotifyPlexToScan () {
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Notifying Plex to Scan :: $lidarrArtistPath"
bash /config/extended/PlexNotify.bash "$lidarrArtistPath"
fi
}
DeemixClientSetup () { DeemixClientSetup () {
log "DEEZER :: Verifying deemix configuration" log "DEEZER :: Verifying deemix configuration"
if [ ! -z "$arlToken" ]; then if [ ! -z "$arlToken" ]; then
@ -1287,6 +1250,7 @@ SearchProcess () {
lyricFilter="false" lyricFilter="false"
fi fi
lidarrDownloadImportNotfication="false"
releaseProcessCount=0 releaseProcessCount=0
for title in ${!lidarrReleaseTitles[@]}; do for title in ${!lidarrReleaseTitles[@]}; do
releaseProcessCount=$(( $releaseProcessCount + 1)) releaseProcessCount=$(( $releaseProcessCount + 1))
@ -1302,107 +1266,65 @@ SearchProcess () {
if [ "$lidarrArtistForeignArtistId" != "89ad4ac3-39f7-470e-963a-56509c546377" ]; then if [ "$lidarrArtistForeignArtistId" != "89ad4ac3-39f7-470e-963a-56509c546377" ]; then
# Lidarr Status Check # Lidarr Status Check
LidarrTaskStatusCheck LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
break 2
fi
# Tidal Artist search # Tidal Artist search
if [ "$skipTidal" == "false" ]; then if [ "$lidarrDownloadImportNotfication" == "false" ]; then
for tidalArtistId in $(echo $tidalArtistIds); do if [ "$dlClientSource" == "both" ] || [ "$dlClientSource" == "tidal" ]; then
ArtistTidalSearch "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal" "$tidalArtistId" "$lyricFilter" for tidalArtistId in $(echo $tidalArtistIds); do
sleep 0.01 ArtistTidalSearch "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal" "$tidalArtistId" "$lyricFilter"
done sleep 0.01
fi done
fi
# Lidarr Status Check
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
break 2
fi fi
# Deezer artist search # Deezer artist search
if [ "$skipDeezer" == "false" ]; then if [ "$lidarrDownloadImportNotfication" == "false" ]; then
for dId in ${!deezerArtistIds[@]}; do if [ "$dlClientSource" == "both" ] || [ "$dlClientSource" == "deezer" ]; then
deezerArtistId="${deezerArtistIds[$dId]}" for dId in ${!deezerArtistIds[@]}; do
ArtistDeezerSearch "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal" "$deezerArtistId" "$lyricFilter" deezerArtistId="${deezerArtistIds[$dId]}"
sleep 0.01 ArtistDeezerSearch "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal" "$deezerArtistId" "$lyricFilter"
done sleep 0.01
done
fi
fi fi
fi fi
# Lidarr Status Check
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
break 2
fi
# Tidal fuzzy search # Tidal fuzzy search
if [ "$dlClientSource" == "both" ] || [ "$dlClientSource" == "tidal" ]; then if [ "$lidarrDownloadImportNotfication" == "false" ]; then
FuzzyTidalSearch "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal" "$lyricFilter" if [ "$dlClientSource" == "both" ] || [ "$dlClientSource" == "tidal" ]; then
sleep 0.01 FuzzyTidalSearch "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal" "$lyricFilter"
fi sleep 0.01
fi
# Lidarr Status Check
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
break 2
fi fi
# Deezer fuzzy search # Deezer fuzzy search
if [ "$dlClientSource" == "both" ] || [ "$dlClientSource" == "deezer" ]; then if [ "$lidarrDownloadImportNotfication" == "false" ]; then
FuzzyDeezerSearch "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal" "$lyricFilter" if [ "$dlClientSource" == "both" ] || [ "$dlClientSource" == "deezer" ]; then
sleep 0.01 FuzzyDeezerSearch "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal" "$lyricFilter"
sleep 0.01
fi
fi fi
# End search if lidarr was successfully notified for import
if [ "$lidarrDownloadImportNotfication" == "true" ]; then
break
else
continue
fi
done done
# End search if lidarr was successfully notified for import
if [ "$lidarrDownloadImportNotfication" == "true" ]; then
break
fi
# Break after all operations are complete # Break after all operations are complete
if [ "$loopCount" == "$endLoop" ]; then if [ "$loopCount" == "$endLoop" ]; then
break break
fi fi
done done
# Lidarr Status Check
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
continue
fi
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
continue
fi
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..."
continue
fi
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Album Not found"
if [ "$skipNotFoundLogCreation" == "false" ]; then
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Marking Album as notfound"
if [ ! -f "/config/extended/logs/notfound/$wantedAlbumId--$lidarrArtistForeignArtistId--$lidarrAlbumForeignAlbumId" ]; then
touch "/config/extended/logs/notfound/$wantedAlbumId--$lidarrArtistForeignArtistId--$lidarrAlbumForeignAlbumId"
chmod 777 "/config/extended/logs/notfound/$wantedAlbumId--$lidarrArtistForeignArtistId--$lidarrAlbumForeignAlbumId"
fi
else
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Skip marking album as not found because it's a new release for 7 days..."
fi
log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Search Complete..." log "$page :: $wantedAlbumListSource :: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Search Complete..."
done done
} }
@ -1508,23 +1430,8 @@ ArtistDeezerSearch () {
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: Downloading $deezerAlbumTrackCount Tracks :: $deezerAlbumTitle ($downloadedReleaseYear)" log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: Downloading $deezerAlbumTrackCount Tracks :: $deezerAlbumTitle ($downloadedReleaseYear)"
DownloadProcess "$deezerAlbumID" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount" DownloadProcess "$deezerAlbumID" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount"
# Verify it was successfully imported into Lidarr
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
break
fi
fi fi
done done
if [ "$alreadyImported" == "true" ]; then
return
else
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: ERROR :: Albums found, but none matching search criteria..."
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: ERROR :: Album not found..."
fi
} }
FuzzyDeezerSearch () { FuzzyDeezerSearch () {
@ -1600,13 +1507,6 @@ FuzzyDeezerSearch () {
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: Downloading $deezerAlbumTrackCount Tracks :: $deezerAlbumTitle ($downloadedReleaseYear)" log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: Downloading $deezerAlbumTrackCount Tracks :: $deezerAlbumTitle ($downloadedReleaseYear)"
DownloadProcess "$deezerAlbumID" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount" DownloadProcess "$deezerAlbumID" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount"
# Verify it was successfully imported into Lidarr
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
break
fi
fi fi
done done
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: ERROR :: Results found, but none matching search criteria..." log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: ERROR :: Results found, but none matching search criteria..."
@ -1682,25 +1582,11 @@ ArtistTidalSearch () {
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: Downloading $downloadedTrackCount Tracks :: $downloadedAlbumTitle ($downloadedReleaseYear)" log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: Downloading $downloadedTrackCount Tracks :: $downloadedAlbumTitle ($downloadedReleaseYear)"
DownloadProcess "$tidalArtistAlbumId" "TIDAL" "$downloadedReleaseYear" "$downloadedAlbumTitle" "$downloadedTrackCount" DownloadProcess "$tidalArtistAlbumId" "TIDAL" "$downloadedReleaseYear" "$downloadedAlbumTitle" "$downloadedTrackCount"
# Verify it was successfully imported into Lidarr
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
break
fi
else else
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal Match Not Found :: Calculated Difference ($diff) greater than 5" log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal Match Not Found :: Calculated Difference ($diff) greater than 5"
fi fi
done done
if [ "$alreadyImported" == "true" ]; then
return
else
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: ERROR :: Albums found, but none matching search criteria..."
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: ERROR :: Album not found"
fi
} }
FuzzyTidalSearch () { FuzzyTidalSearch () {
@ -1756,13 +1642,6 @@ FuzzyTidalSearch () {
DownloadProcess "$tidalAlbumID" "TIDAL" "$downloadedReleaseYear" "$tidalAlbumTitle" "$downloadedTrackCount" DownloadProcess "$tidalAlbumID" "TIDAL" "$downloadedReleaseYear" "$tidalAlbumTitle" "$downloadedTrackCount"
# Verify it was successfully imported into Lidarr
LidarrTaskStatusCheck
CheckLidarrBeforeImport "$checkLidarrAlbumId"
if [ "$alreadyImported" == "true" ]; then
break
fi
else else
log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal Match Not Found :: Calculated Difference ($diff) greater than 5" log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal Match Not Found :: Calculated Difference ($diff) greater than 5"
fi fi