diff --git a/root/scripts/audio.sh b/root/scripts/audio.sh index 4cacd7d..0608136 100644 --- a/root/scripts/audio.sh +++ b/root/scripts/audio.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.217" +scriptVersion="1.0.218" if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" if [ "$lidarrUrlBase" = "null" ]; then @@ -32,7 +32,7 @@ sleepTimer=0.5 log () { m_time=`date "+%F %T"` - echo $m_time" :: Extended Audio "$1 + echo $m_time" :: Extended Audio :: "$1 } verifyApiAccess () { @@ -41,34 +41,34 @@ verifyApiAccess () { lidarrTest=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/system/status?apikey=${lidarrApiKey}" | jq -r .branch) if [ $lidarrTest = master ]; then lidarrVersion=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/system/status?apikey=${lidarrApiKey}" | jq -r .version) - log ":: Lidarr Version: $lidarrVersion" + log "Lidarr Version: $lidarrVersion" break else - log ":: Lidarr is not ready, sleeping until valid response..." + log "Lidarr is not ready, sleeping until valid response..." sleep 1 fi done } -echo "-----------------------------------------------------------------------------" -echo " |~) _ ._ _| _ ._ _ |\ |o._ o _ |~|_|_|" -echo " |~\(_|| |(_|(_)| | || \||| |_|(_||~| | |<" -echo " Presents: lidarr-extended ($scriptVersion)" -echo " Docker Version: $dockerVersion" -echo " May the beats be with you!" -echo "-----------------------------------------------------------------------------" -echo "Donate: https://github.com/sponsors/RandomNinjaAtk" -echo "Project: https://github.com/RandomNinjaAtk/docker-lidarr-extended" -echo "Support: https://github.com/RandomNinjaAtk/docker-lidarr-extended/discussions" -echo "-----------------------------------------------------------------------------" +log "-----------------------------------------------------------------------------" +log " |~) _ ._ _| _ ._ _ |\ |o._ o _ |~|_|_|" +log " |~\(_|| |(_|(_)| | || \||| |_|(_||~| | |<" +log " Presents: lidarr-extended ($scriptVersion)" +log " Docker Version: $dockerVersion" +log " May the beats be with you!" +log "-----------------------------------------------------------------------------" +log "Donate: https://github.com/sponsors/RandomNinjaAtk" +log "Project: https://github.com/RandomNinjaAtk/docker-lidarr-extended" +log "Support: https://github.com/RandomNinjaAtk/docker-lidarr-extended/discussions" +log "-----------------------------------------------------------------------------" sleep 5 -echo "" -echo "Lift off in..."; sleep 0.5 -echo "5"; sleep 1 -echo "4"; sleep 1 -echo "3"; sleep 1 -echo "2"; sleep 1 -echo "1"; sleep 1 +log "" +log "Lift off in..."; sleep 0.5 +log "5"; sleep 1 +log "4"; sleep 1 +log "3"; sleep 1 +log "2"; sleep 1 +log "1"; sleep 1 @@ -79,9 +79,9 @@ fi Configuration () { processstartid="$(ps -A -o pid,cmd|grep "start_audio.sh" | grep -v grep | head -n 1 | awk '{print $1}')" processdownloadid="$(ps -A -o pid,cmd|grep "audio.sh" | grep -v grep | head -n 1 | awk '{print $1}')" - log ":: To kill script, use the following command:" - log ":: kill -9 $processstartid" - log ":: kill -9 $processdownloadid" + log "To kill script, use the following command:" + log "kill -9 $processstartid" + log "kill -9 $processdownloadid" sleep 2 if [ -z $topLimit ]; then @@ -91,68 +91,68 @@ Configuration () { verifyApiAccess if [ "$addDeezerTopArtists" = "true" ]; then - log ":: Add Deezer Top $topLimit Artists is enabled" + log "Add Deezer Top $topLimit Artists is enabled" else - log ":: Add Deezer Top Artists is disabled (enable by setting addDeezerTopArtists=true)" + log "Add Deezer Top Artists is disabled (enable by setting addDeezerTopArtists=true)" fi if [ "$addDeezerTopAlbumArtists" = "true" ]; then - log ":: Add Deezer Top $topLimit Album Artists is enabled" + log "Add Deezer Top $topLimit Album Artists is enabled" else - log ":: Add Deezer Top Album Artists is disabled (enable by setting addDeezerTopAlbumArtists=true)" + log "Add Deezer Top Album Artists is disabled (enable by setting addDeezerTopAlbumArtists=true)" fi if [ "$addDeezerTopTrackArtists" = "true" ]; then - log ":: Add Deezer Top $topLimit Track Artists is enabled" + log "Add Deezer Top $topLimit Track Artists is enabled" else - log ":: Add Deezer Top Track Artists is disabled (enable by setting addDeezerTopTrackArtists=true)" + log "Add Deezer Top Track Artists is disabled (enable by setting addDeezerTopTrackArtists=true)" fi if [ "$addRelatedArtists" = "true" ]; then - log ":: Add Deezer Related Artists is enabled" - log ":: Add $numberOfRelatedArtistsToAddPerArtist Deezer related Artist for each Lidarr Artist" + log "Add Deezer Related Artists is enabled" + log "Add $numberOfRelatedArtistsToAddPerArtist Deezer related Artist for each Lidarr Artist" else - log ":: Add Deezer Related Artists is disabled (enable by setting addRelatedArtists=true)" + log "Add Deezer Related Artists is disabled (enable by setting addRelatedArtists=true)" fi if [ "$configureLidarrWithOptimalSettings" = "true" ]; then - log ":: Configure Lidarr with optimal settings is enabled" + log "Configure Lidarr with optimal settings is enabled" else - log ":: Configure Lidarr with optimal settings is disabled (enable by setting configureLidarrWithOptimalSettings=true)" + log "Configure Lidarr with optimal settings is disabled (enable by setting configureLidarrWithOptimalSettings=true)" fi - log ":: Download Location :: $downloadPath" - log ":: Output format = $audioFormat" - log ":: Output bitrate = $audioBitrate" + log "Download Location :: $downloadPath" + log "Output format = $audioFormat" + log "Output bitrate = $audioBitrate" if [ "$requireQuality" = "true" ]; then - log ":: Download Quality Check Enabled" + log "Download Quality Check Enabled" else - log ":: Download Quality Check Disabled (enable by setting: requireQuality=true" + log "Download Quality Check Disabled (enable by setting: requireQuality=true" fi if [ $audioLyricType = both ] || [ $audioLyricType = explicit ] || [ $audioLyricType = explicit ]; then - log ":: Preferred audio lyric type: $audioLyricType" + log "Preferred audio lyric type: $audioLyricType" fi - log ":: Tidal Country Code set to: $tidalCountryCode" + log "Tidal Country Code set to: $tidalCountryCode" if [ $enableReplaygainTags = true ]; then - log ":: Replaygain Tagging Enabled" + log "Replaygain Tagging Enabled" else - log ":: Replaygain Tagging Disabled" + log "Replaygain Tagging Disabled" fi if [ $enableBeetsTagging = true ]; then - log ":: Beets Tagging Enabled" - log ":: Beets Matching Threshold ${beetsMatchPercentage}%" + log "Beets Tagging Enabled" + log "Beets Matching Threshold ${beetsMatchPercentage}%" beetsMatchPercentage=$(expr 100 - $beetsMatchPercentage ) if cat /config/extended/scripts/beets-config.yaml | grep "strong_rec_thresh: 0.04" | read; then - log ":: Configuring Beets Matching Threshold" + log "Configuring Beets Matching Threshold" sed -i "s/strong_rec_thresh: 0.04/strong_rec_thresh: 0.${beetsMatchPercentage}/g" /config/extended/scripts/beets-config.yaml fi else - log ":: Beets Tagging Disabled" + log "Beets Tagging Disabled" fi } @@ -168,16 +168,16 @@ DownloadFormat () { tidal-dl -q Normal deemixQuality=128 else - log ":: ERROR :: Invalid audioFormat and audioBitrate options set..." - log ":: ERROR :: Change audioBitrate to a low, high, or lossless..." - log ":: ERROR :: Exiting..." + log "ERROR :: Invalid audioFormat and audioBitrate options set..." + log "ERROR :: Change audioBitrate to a low, high, or lossless..." + log "ERROR :: Exiting..." exit fi else if [ $audioBitrate = lossless ] || [ $audioBitrate = high ] || [ $audioBitrate = low ]; then - log ":: ERROR :: Invalid audioFormat and audioBitrate options set..." - log ":: ERROR :: Change audioBitrate to a desired bitrate number, example: 192..." - log ":: ERROR :: Exiting..." + log "ERROR :: Invalid audioFormat and audioBitrate options set..." + log "ERROR :: Change audioBitrate to a desired bitrate number, example: 192..." + log "ERROR :: Exiting..." exit else tidal-dl -q HiFi @@ -189,7 +189,7 @@ DownloadFormat () { DownloadFolderCleaner () { # check for completed download folder if [ -d "$downloadPath/complete" ]; then - log ":: Removing prevously completed downloads that failed to import..." + log "Removing prevously completed downloads that failed to import..." # check for completed downloads older than 1 day if find $downloadPath/complete -mindepth 1 -type d -mtime +1 | read; then # delete completed downloads older than 1 day, these most likely failed to import due to Lidarr failing to match @@ -203,7 +203,7 @@ NotFoundFolderCleaner () { if [ -d /config/extended/logs/notfound ]; then # check for notfound entries older than 90 days if find /config/extended/logs/notfound -mindepth 1 -type f -mtime +90 | read; then - log ":: Removing prevously notfound lidarr album ids older than 90 days to give them a retry..." + log "Removing prevously notfound lidarr album ids older than 90 days to give them a retry..." # delete ntofound entries older than 90 days find /config/extended/logs/notfound -mindepth 1 -type f -mtime +90 -delete fi @@ -242,17 +242,17 @@ AddDeezerArtistToLidarr () { lidarrArtistIds="$(echo "${lidarrArtistsData}" | jq -r ".[].foreignArtistId")" deezerArtistsUrl=$(echo "${lidarrArtistsData}" | jq -r ".[].links | .[] | select(.name==\"deezer\") | .url") deezerArtistIds="$(echo "$deezerArtistsUrl" | grep -o '[[:digit:]]*' | sort -u)" - log ":: Finding $description..." - log ":: $getDeezerArtistsIdsCount $description Found..." + log "Finding $description..." + log "$getDeezerArtistsIdsCount $description Found..." for id in ${!getDeezerArtistsIds[@]}; do currentprocess=$(( $id + 1 )) deezerArtistId="${getDeezerArtistsIds[$id]}" deezerArtistName="$(curl -s https://api.deezer.com/artist/$deezerArtistId | jq -r .name)" 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 "$deezerArtistIds" | grep "^${deezerArtistId}$" | read; then - log ":: $currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: $deezerArtistId already in Lidarr..." + log "$currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: $deezerArtistId already in Lidarr..." continue fi @@ -304,27 +304,27 @@ AddDeezerArtistToLidarr () { }" if echo "$lidarrArtistIds" | grep "^${musicbrainz_main_artist_id}$" | read; then - log ":: $currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: Already in Lidarr ($musicbrainz_main_artist_id), skipping..." + log "$currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: Already in Lidarr ($musicbrainz_main_artist_id), skipping..." continue fi - log ":: $currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: Adding $artistName to Lidarr ($musicbrainz_main_artist_id)..." + log "$currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: Adding $artistName to Lidarr ($musicbrainz_main_artist_id)..." LidarrTaskStatusCheck lidarrAddArtist=$(curl -s "$lidarrUrl/api/v1/artist" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $lidarrApiKey" --data-raw "$data") else - log ":: $currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: Artist not found in Musicbrainz, please add \"https://deezer.com/artist/${deezerArtistId}\" to the correct artist on Musicbrainz" + log "$currentprocess of $getDeezerArtistsIdsCount :: $deezerArtistName :: Artist not found in Musicbrainz, please add \"https://deezer.com/artist/${deezerArtistId}\" to the correct artist on Musicbrainz" fi LidarrTaskStatusCheck done } TidalClientSetup () { - log ":: TIDAL :: Verifying tidal-dl configuration" + log "TIDAL :: Verifying tidal-dl configuration" touch /config/xdg/.tidal-dl.log if [ -f /config/xdg/.tidal-dl.json ]; then rm /config/xdg/.tidal-dl.json fi if [ ! -f /config/xdg/.tidal-dl.json ]; then - log ":: TIDAL :: No default config found, importing default config \"tidal.json\"" + log "TIDAL :: No default config found, importing default config \"tidal.json\"" if [ -f /config/extended/scripts/tidal-dl.json ]; then cp /config/extended/scripts/tidal-dl.json /config/xdg/.tidal-dl.json chmod 777 -R /config/xdg/ @@ -339,16 +339,16 @@ TidalClientSetup () { if [ -f /config/xdg/.tidal-dl.token.json ]; then if [[ $(find "/config/xdg/.tidal-dl.token.json" -mtime +5 -print) ]]; then - log ":: TIDAL :: ERROR :: Token expired, removing..." + log "TIDAL :: ERROR :: Token expired, removing..." rm /config/xdg/.tidal-dl.token.json fi fi if [ ! -f /config/xdg/.tidal-dl.token.json ]; then TidaldlStatusCheck - log ":: TIDAL :: ERROR :: Downgrade tidal-dl for workaround..." + log "TIDAL :: ERROR :: Downgrade tidal-dl for workaround..." pip3 install tidal-dl==2022.3.4.2 --no-cache-dir 1>/dev/null - log ":: TIDAL :: ERROR :: Loading client for required authentication, please authenticate, then exit the client..." + log "TIDAL :: ERROR :: Loading client for required authentication, please authenticate, then exit the client..." TidaldlStatusCheck tidal-dl fi @@ -360,7 +360,7 @@ TidalClientSetup () { fi if [ -d /config/extended/cache/tidal ]; then - log ":: TIDAL :: Purging album list cache..." + log "TIDAL :: Purging album list cache..." find /config/extended/cache/tidal -type f -name "*.json" -delete fi @@ -373,13 +373,13 @@ TidalClientSetup () { fi TidaldlStatusCheck - log ":: TIDAL :: Upgrade tidal-dl to newer version..." + log "TIDAL :: Upgrade tidal-dl to newer version..." pip3 install tidal-dl==2022.07.06.1 --no-cache-dir 1>/dev/null } TidalClientTest () { - log ":: TIDAL :: tidal-dl client setup verification..." + log "TIDAL :: tidal-dl client setup verification..." TidaldlStatusCheck tidal-dl -o $downloadPath/incomplete -l "166356219" 1>/dev/null @@ -388,14 +388,14 @@ TidalClientTest () { if [ -f /config/xdg/.tidal-dl.token.json ]; then rm /config/xdg/.tidal-dl.token.json fi - log ":: TIDAL :: ERROR :: Download failed" - log ":: TIDAL :: ERROR :: You will need to re-authenticate on next script run..." - log ":: TIDAL :: ERROR :: Exiting..." + log "TIDAL :: ERROR :: Download failed" + log "TIDAL :: ERROR :: You will need to re-authenticate on next script run..." + log "TIDAL :: ERROR :: Exiting..." rm -rf $downloadPath/incomplete/* exit else rm -rf $downloadPath/incomplete/* - log ":: TIDAL :: Successfully Verified" + log "TIDAL :: Successfully Verified" fi } @@ -405,7 +405,7 @@ TidaldlStatusCheck () { running=no if ps aux | grep "tidal-dl" | grep -v "grep" | read; then running=yes - log ":: STATUS :: TIDAL-DL :: BUSY :: Pausing/waiting for all active tidal-dl tasks to end..." + log "STATUS :: TIDAL-DL :: BUSY :: Pausing/waiting for all active tidal-dl tasks to end..." sleep 2 continue fi @@ -479,18 +479,18 @@ DownloadProcess () { downloadedAlbumTitleClean="$(echo "$4" | sed -e "s%[^[:alpha:][:digit:]._' ]% %g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')" if find $downloadPath/complete -type d -iname "$lidarrArtistNameSanitized-$downloadedAlbumTitleClean ($3)-*-$1-$2" | read; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Downloaded..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Downloaded..." return fi # check for log file if [ "$2" = "DEEZER" ]; then if [ -f /config/extended/logs/downloaded/deezer/$1 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Downloaded ($1)..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Downloaded ($1)..." return fi if [ -f /config/extended/logs/downloaded/failed/deezer/$1 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Attempted Download ($1)..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Attempted Download ($1)..." return fi fi @@ -498,11 +498,11 @@ DownloadProcess () { # check for log file if [ "$2" = "TIDAL" ]; then if [ -f /config/extended/logs/downloaded/tidal/$1 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Downloaded ($1)..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Downloaded ($1)..." return fi if [ -f /config/extended/logs/downloaded/failed/tidal/$1 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Attempted Download ($1)..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Attempted Download ($1)..." return fi fi @@ -520,9 +520,11 @@ DownloadProcess () { touch /temp-download sleep 0.1 - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Download Attempt number $downloadTry" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Download Attempt number $downloadTry" if [ "$2" = "DEEZER" ]; then - DeezerClientTest + if [ $downloadTry = 0 ]; then + DeezerClientTest + fi deemix -b $deemixQuality -p $downloadPath/incomplete "https://www.deezer.com/album/$1" 1>/dev/null if [ -d "/tmp/deemix-imgs" ]; then rm -rf /tmp/deemix-imgs @@ -530,8 +532,10 @@ DownloadProcess () { fi if [ "$2" = "TIDAL" ]; then - TidaldlStatusCheck - TidalClientTest + if [ $downloadTry = 0 ]; then + TidaldlStatusCheck + TidalClientTest + fi TidaldlStatusCheck tidal-dl -o $downloadPath/incomplete -l "$1" 1>/dev/null fi @@ -539,19 +543,19 @@ DownloadProcess () { find "$downloadPath/incomplete" -type f -iname "*.flac" -newer "/temp-download" -print0 | while IFS= read -r -d '' file; do audioFlacVerification "$file" if [ $verifiedFlacFile = 0 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Flac Verification :: $file :: Verified" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Flac Verification :: $file :: Verified" else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Flac Verification :: $file :: ERROR :: Failed Verification" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Flac Verification :: $file :: ERROR :: Failed Verification" rm "$file" fi done downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|m4a\|mp3\)" | wc -l) if [ $downloadCount -ne $5 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: download failed, missing tracks..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: download failed, missing tracks..." completedVerification="false" else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Success" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Success" completedVerification="true" fi @@ -563,14 +567,14 @@ DownloadProcess () { fi break else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Retry Download in 1 second fix errors..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Retry Download in 1 second fix errors..." sleep 1 fi done # Consolidate files to a single folder if [ "$2" = "TIDAL" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Consolidating files to single folder" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Consolidating files to single folder" find "$downloadPath/incomplete" -type f -exec mv "{}" $downloadPath/incomplete/ \; if [ -d $downloadPath/incomplete/atd ]; then rm -rf $downloadPath/incomplete/atd @@ -585,8 +589,8 @@ DownloadProcess () { downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|m4a\|mp3\)" | wc -l) if [ $downloadCount -ne $5 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: All download Attempts failed..." - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Logging $1 as failed download..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: All download Attempts failed..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Logging $1 as failed download..." if [ "$2" = "DEEZER" ]; then @@ -599,7 +603,7 @@ DownloadProcess () { fi # Log Completed Download - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Logging $1 as successfully downloaded..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Logging $1 as successfully downloaded..." if [ "$2" = "DEEZER" ]; then touch /config/extended/logs/downloaded/deezer/$1 fi @@ -608,7 +612,7 @@ DownloadProcess () { fi if [ $audioFormat != native ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Converting Flac Audio to ${audioFormat^^} ${audioBitrate}k" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Converting Flac Audio to ${audioFormat^^} ${audioBitrate}k" if [ $audioFormat = opus ]; then options="-acodec libopus -ab ${audioBitrate}k -application audio -vbr off" extension="opus" @@ -635,10 +639,10 @@ DownloadProcess () { foldername="$(dirname "$audio")" filenamenoext="${filename%.*}" if ffmpeg -loglevel warning -hide_banner -nostats -i "$file" -n -vn $options "$foldername/${filenamenoext}.$extension" < /dev/null; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: $filename :: Conversion to $audioFormat (${audioBitrate}k) successful" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: $filename :: Conversion to $audioFormat (${audioBitrate}k) successful" rm "$file" else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: $filename :: ERROR :: Conversion Failed" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: $filename :: ERROR :: Conversion Failed" rm "$foldername/${filenamenoext}.$extension" fi done @@ -648,13 +652,13 @@ DownloadProcess () { if [ $enableReplaygainTags = true ]; then AddReplaygainTags "$downloadPath/incomplete" else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Replaygain Tagging Disabled (set enableReplaygainTags=true to enable...)" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Replaygain Tagging Disabled (set enableReplaygainTags=true to enable...)" fi find "$downloadPath/incomplete" -type f -iname "*.flac" -print0 | while IFS= read -r -d '' file; do lrcFile="${file%.*}.lrc" if [ -f "$lrcFile" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Embedding lyrics (lrc) into $file" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Embedding lyrics (lrc) into $file" metaflac --remove-tag=Lyrics "$file" metaflac --set-tag-from-file="Lyrics=$lrcFile" "$file" rm "$lrcFile" @@ -683,10 +687,10 @@ DownloadProcess () { chown -R abc:abc $downloadPath/complete if [ $enableBeetsTagging = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Processing files with beets..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Processing files with beets..." ProcessWithBeets "$downloadPath/complete/$downloadedAlbumFolder" "${albumquality^^}" "$2" "$1" else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Beets Tagging Disabled (set enableBeetsTagging=true to enable...)" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Beets Tagging Disabled (set enableBeetsTagging=true to enable...)" fi if [ -d "$downloadPath/complete/$downloadedAlbumFolder" ]; then @@ -700,73 +704,73 @@ DownloadProcess () { DownloadQualityCheck () { if [ "$requireQuality" = "true" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Checking for unwanted files" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Checking for unwanted files" if [ $audioFormat != native ]; then if find "$1" -type f -regex ".*/.*\.\(opus\|m4a\|mp3\)"| read; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Unwanted files found!" - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Performing cleanup..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Unwanted files found!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Performing cleanup..." rm "$1"/* else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: No unwanted files found!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: No unwanted files found!" fi fi if [ $audioFormat = native ]; then if [ $audioBitrate = lossless ]; then if find "$1" -type f -regex ".*/.*\.\(opus\|m4a\|mp3\)"| read; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Unwanted files found!" - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Performing cleanup..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Unwanted files found!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Performing cleanup..." rm "$1"/* else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: No unwanted files found!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: No unwanted files found!" fi elif [ $2 = DEEZER ]; then if find "$1" -type f -regex ".*/.*\.\(opus\|m4a\|flac\)"| read; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Unwanted files found!" - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Performing cleanup..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Unwanted files found!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Performing cleanup..." rm "$1"/* else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: No unwanted files found!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: No unwanted files found!" fi elif [ $2 = TIDAL ]; then if find "$1" -type f -regex ".*/.*\.\(opus\|flac\|mp3\)"| read; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Unwanted files found!" - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Performing cleanup..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Unwanted files found!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Performing cleanup..." rm "$1"/* else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: No unwanted files found!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: No unwanted files found!" fi fi fi else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Skipping download quality check... (enable by setting: requireQuality=true)" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Skipping download quality check... (enable by setting: requireQuality=true)" fi } AddReplaygainTags () { # Input Data # $1 Folder path to scan and add tags - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Adding Replaygain Tags using r128gain" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Adding Replaygain Tags using r128gain" r128gain -r -a "$1" 1>/dev/null } NotifyLidarrForImport () { LidarrProcessIt=$(curl -s "$lidarrUrl/api/v1/command" --header "X-Api-Key:"${lidarrApiKey} -H "Content-Type: application/json" --data "{\"name\":\"DownloadedAlbumsScan\", \"path\":\"$1\"}") - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: LIDARR IMPORT NOTIFICATION SENT! :: $1" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: LIDARR IMPORT NOTIFICATION SENT! :: $1" } NotifyPlexToScan () { LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Notifying Plex to Scan :: $lidarrArtistPath" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Notifying Plex to Scan :: $lidarrArtistPath" bash /config/extended/scripts/PlexNotify.bash "$lidarrArtistPath" fi } DeemixClientSetup () { - log ":: DEEZER :: Verifying deemix configuration" + log "DEEZER :: Verifying deemix configuration" if [ ! -z "$arlToken" ]; then arlToken="$(echo $arlToken | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')" # Create directories @@ -777,9 +781,9 @@ DeemixClientSetup () { if [ ! -f "/config/xdg/deemix/.arl" ]; then echo -n "$arlToken" > "/config/xdg/deemix/.arl" fi - log ":: DEEZER :: ARL Token: Configured" + log "DEEZER :: ARL Token: Configured" else - log ":: DEEZER :: ERROR :: arlToken setting invalid, currently set to: $arlToken" + log "DEEZER :: ERROR :: arlToken setting invalid, currently set to: $arlToken" fi if [ -f "/config/xdg/deemix/config.json" ]; then @@ -787,13 +791,13 @@ DeemixClientSetup () { fi if [ -f "/config/extended/scripts/deemix_config.json" ]; then - log ":: DEEZER :: Configuring deemix client" + log "DEEZER :: Configuring deemix client" cp /config/extended/scripts/deemix_config.json /config/xdg/deemix/config.json chmod 777 /config/xdg/deemix/config.json fi if [ -d /config/extended/cache/deezer ]; then - log ":: DEEZER :: Purging album list cache..." + log "DEEZER :: Purging album list cache..." find /config/extended/cache/deezer -type f -name "*-albums.json" -delete fi @@ -805,13 +809,13 @@ DeemixClientSetup () { rm -rf $downloadPath/incomplete/* fi - log ":: DEEZER :: Upgrade deemix to the latest..." + log "DEEZER :: Upgrade deemix to the latest..." pip3 install deemix --upgrade 1>/dev/null } DeezerClientTest () { - log ":: DEEZER :: deemix client setup verification..." + log "DEEZER :: deemix client setup verification..." deemix -b $deemixQuality -p $downloadPath/incomplete "https://www.deezer.com/album/197472472" 1>/dev/null if [ -d "/tmp/deemix-imgs" ]; then @@ -819,71 +823,71 @@ DeezerClientTest () { fi downloadCount=$(find $downloadPath/incomplete/ -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) if [ $downloadCount -le 0 ]; then - log ":: DEEZER :: ERROR :: Download failed" - log ":: DEEZER :: ERROR :: Please review log for errors in client" - log ":: DEEZER :: ERROR :: Try updating your ARL Token to possibly resolve the issue..." - log ":: DEEZER :: ERROR :: Exiting..." + log "DEEZER :: ERROR :: Download failed" + log "DEEZER :: ERROR :: Please review log for errors in client" + log "DEEZER :: ERROR :: Try updating your ARL Token to possibly resolve the issue..." + log "DEEZER :: ERROR :: Exiting..." rm -rf $downloadPath/incomplete/* exit else rm -rf $downloadPath/incomplete/* - log ":: DEEZER :: Successfully Verified" + log "DEEZER :: Successfully Verified" fi } ConfigureLidarrWithOptimalSettings () { if curl -s "$lidarrUrl/api/v1/rootFolder" -H "X-Api-Key: ${lidarrApiKey}" | sed '1q' | grep "\[\]" | read; then - log ":: ERROR :: No root folder found" - log ":: Configuring root folder..." + log "ERROR :: No root folder found" + log "Configuring root folder..." getSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/filesystem?path=%2Fmusic&allowFoldersWithoutTrailingSlashes=false&includeFiles=false" -H "X-Api-Key: ${lidarrApiKey}") postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/rootFolder?" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"defaultTags":[],"defaultQualityProfileId":1,"defaultMetadataProfileId":1,"name":"Music","path":"/music"}') fi - log ":: Configuring Lidarr Media Management Settings" + log "Configuring Lidarr Media Management Settings" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/config/mediamanagement" -X PUT -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"autoUnmonitorPreviouslyDownloadedTracks":false,"recycleBin":"","recycleBinCleanupDays":7,"downloadPropersAndRepacks":"preferAndUpgrade","createEmptyArtistFolders":true,"deleteEmptyFolders":true,"fileDate":"none","watchLibraryForChanges":true,"rescanAfterRefresh":"always","allowFingerprinting":"newFiles","setPermissionsLinux":true,"chmodFolder":"777","chownGroup":"abc","skipFreeSpaceCheckWhenImporting":false,"minimumFreeSpaceWhenImporting":100,"copyUsingHardlinks":true,"importExtraFiles":true,"extraFileExtensions":"jpg,png,lrc","id":1}') - log ":: Configuring Lidarr Metadata ConsumerSettings" + log "Configuring Lidarr Metadata ConsumerSettings" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/metadata/1?" -X PUT -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"enable":true,"name":"Kodi (XBMC) / Emby","fields":[{"name":"artistMetadata","value":true},{"name":"albumMetadata","value":true},{"name":"artistImages","value":true},{"name":"albumImages","value":false}],"implementationName":"Kodi (XBMC) / Emby","implementation":"XbmcMetadata","configContract":"XbmcMetadataSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#xbmcmetadata","tags":[],"id":1}') - log ":: Configuring Lidarr Metadata Provider Settings" + log "Configuring Lidarr Metadata Provider Settings" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/config/metadataProvider" -X PUT -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"metadataSource":"","writeAudioTags":"allFiles","scrubAudioTags":false,"id":1}') - log ":: Configuring Lidarr Custom Scripts" + log "Configuring Lidarr Custom Scripts" if curl -s "$lidarrUrl/api/v1/notification" -H "X-Api-Key: ${lidarrApiKey}" | jq -r .[].name | grep "PlexNotify.bash" | read; then - log ":: PlexNotify.bash Already added to Lidarr custom scripts" + log "PlexNotify.bash Already added to Lidarr custom scripts" else - log ":: Adding PlexNotify.bash to Lidarr custom scripts" + log "Adding PlexNotify.bash to Lidarr custom scripts" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/filesystem?path=%2Fconfig%2Fextended%2Fscripts%2FPlexNotify.bash&allowFoldersWithoutTrailingSlashes=true&includeFiles=true" -H "X-Api-Key: ${lidarrApiKey}") postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/notification?" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"onGrab":false,"onReleaseImport":true,"onUpgrade":true,"onRename":true,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"PlexNotify.bash","fields":[{"name":"path","value":"/config/extended/scripts/PlexNotify.bash"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#customscript","message":{"message":"Testing will execute the script with the EventType set to Test, ensure your script handles this correctly","type":"warning"},"tags":[]}') fi if curl -s "$lidarrUrl/api/v1/notification" -H "X-Api-Key: ${lidarrApiKey}" | jq -r .[].name | grep "Plex_MusicVideos.bash" | read; then - log ":: Plex_MusicVideos.bash Already added to Lidarr custom scripts" + log "Plex_MusicVideos.bash Already added to Lidarr custom scripts" else - log ":: Adding Plex_MusicVideos.bash to Lidarr custom scripts" + log "Adding Plex_MusicVideos.bash to Lidarr custom scripts" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/filesystem?path=%2Fconfig%2Fextended%2Fscripts%2FPlex_MusicVideos.bash&allowFoldersWithoutTrailingSlashes=true&includeFiles=true" -H "X-Api-Key: ${lidarrApiKey}") postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/notification?" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"onGrab":false,"onReleaseImport":false,"onUpgrade":false,"onRename":false,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"Plex_MusicVideos.bash","fields":[{"name":"path","value":"/config/extended/scripts/Plex_MusicVideos.bash"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#customscript","message":{"message":"Testing will execute the script with the EventType set to Test, ensure your script handles this correctly","type":"warning"},"tags":[]}') fi if curl -s "$lidarrUrl/api/v1/notification" -H "X-Api-Key: ${lidarrApiKey}" | jq -r .[].name | grep "MetadataPostProcess.bash" | read; then - log ":: MetadataPostProcess.bash Already added to Lidarr custom scripts" + log "MetadataPostProcess.bash Already added to Lidarr custom scripts" else - log ":: Adding MetadataPostProcess.bash to Lidarr custom scripts" + log "Adding MetadataPostProcess.bash to Lidarr custom scripts" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/filesystem?path=%2Fconfig%2Fextended%2Fscripts%2FMetadataPostProcess.bash&allowFoldersWithoutTrailingSlashes=true&includeFiles=true" -H "X-Api-Key: ${lidarrApiKey}") postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/notification?" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"onGrab":false,"onReleaseImport":false,"onUpgrade":false,"onRename":false,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":true,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"MetadataPostProcess.bash","fields":[{"name":"path","value":"/config/extended/scripts/MetadataPostProcess.bash"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#customscript","message":{"message":"Testing will execute the script with the EventType set to Test, ensure your script handles this correctly","type":"warning"},"tags":[]}') fi - log ":: Configuring Lidarr UI Settings" + log "Configuring Lidarr UI Settings" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/config/ui" -X PUT -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"firstDayOfWeek":0,"calendarWeekColumnHeader":"ddd M/D","shortDateFormat":"MMM D YYYY","longDateFormat":"dddd, MMMM D YYYY","timeFormat":"h(:mm)a","showRelativeDates":true,"enableColorImpairedMode":true,"uiLanguage":1,"expandAlbumByDefault":true,"expandSingleByDefault":true,"expandEPByDefault":true,"expandBroadcastByDefault":true,"expandOtherByDefault":true,"id":1}') - log ":: Configuring Lidarr Standard Metadata Profile" + log "Configuring Lidarr Standard Metadata Profile" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/metadataprofile/1?" -X PUT -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"name":"Standard","primaryAlbumTypes":[{"albumType":{"id":2,"name":"Single"},"allowed":true},{"albumType":{"id":4,"name":"Other"},"allowed":false},{"albumType":{"id":1,"name":"EP"},"allowed":true},{"albumType":{"id":3,"name":"Broadcast"},"allowed":false},{"albumType":{"id":0,"name":"Album"},"allowed":true}],"secondaryAlbumTypes":[{"albumType":{"id":0,"name":"Studio"},"allowed":true},{"albumType":{"id":3,"name":"Spokenword"},"allowed":true},{"albumType":{"id":2,"name":"Soundtrack"},"allowed":true},{"albumType":{"id":7,"name":"Remix"},"allowed":true},{"albumType":{"id":9,"name":"Mixtape/Street"},"allowed":true},{"albumType":{"id":6,"name":"Live"},"allowed":true},{"albumType":{"id":4,"name":"Interview"},"allowed":true},{"albumType":{"id":8,"name":"DJ-mix"},"allowed":true},{"albumType":{"id":10,"name":"Demo"},"allowed":true},{"albumType":{"id":1,"name":"Compilation"},"allowed":true}],"releaseStatuses":[{"releaseStatus":{"id":3,"name":"Pseudo-Release"},"allowed":false},{"releaseStatus":{"id":1,"name":"Promotion"},"allowed":false},{"releaseStatus":{"id":0,"name":"Official"},"allowed":true},{"releaseStatus":{"id":2,"name":"Bootleg"},"allowed":false}],"id":1}') - log ":: Configuring Lidarr Track Naming Settings" + log "Configuring Lidarr Track Naming Settings" postSettingsToLidarr=$(curl -s "$lidarrUrl/api/v1/config/naming" -X PUT -H 'Content-Type: application/json' -H "X-Api-Key: ${lidarrApiKey}" --data-raw '{"renameTracks":true,"replaceIllegalCharacters":true,"standardTrackFormat":"{Artist Name} - {Album Type} - {Release Year} - {Album Title}{ (Album Disambiguation)}/{medium:00}{track:00} - {Track Title}","multiDiscTrackFormat":"{Artist Name} - {Album Type} - {Release Year} - {Album Title}{ (Album Disambiguation)}/{medium:00}{track:00} - {Track Title}","artistFolderFormat":"{Artist Name}{ (Artist Disambiguation)}","includeArtistName":false,"includeAlbumTitle":false,"includeQuality":false,"replaceSpaces":false,"id":1}') touch /config/extended/logs/autoconfig @@ -894,9 +898,9 @@ ConfigureLidarrWithOptimalSettings () { LidarrRootFolderCheck () { if curl -s "$lidarrUrl/api/v1/rootFolder" -H "X-Api-Key: ${lidarrApiKey}" | sed '1q' | grep "\[\]" | read; then - log ":: ERROR :: No root folder found" - log ":: ERROR :: Configure root folder in Lidarr to continue..." - log ":: ERROR :: Exiting..." + log "ERROR :: No root folder found" + log "ERROR :: Configure root folder in Lidarr to continue..." + log "ERROR :: Exiting..." exit fi } @@ -935,7 +939,7 @@ GetMissingCutOffList () { lidarrMissingTotalRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/missing?page=1&pagesize=1&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r .totalRecords) - log ":: FINDING MISSING ALBUMS :: sorted by $searchSort" + log "FINDING MISSING ALBUMS :: sorted by $searchSort" if [ $lidarrMissingTotalRecords -le 1000 ]; then amountPerPull=500 @@ -970,7 +974,7 @@ GetMissingCutOffList () { if [ $dlnumber -gt $lidarrMissingTotalRecords ]; then dlnumber=$lidarrMissingTotalRecords fi - log ":: Downloading page $page... ($offset - $dlnumber of $lidarrMissingTotalRecords Results)" + log "Downloading page $page... ($offset - $dlnumber of $lidarrMissingTotalRecords Results)" lidarrRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/missing?page=$page&pagesize=$amountPerPull&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r '.records[].id') for lidarrRecordId in $(echo $lidarrRecords); do @@ -981,11 +985,11 @@ GetMissingCutOffList () { done fi lidarrMissingTotalRecords=$(find /config/extended/cache/lidarr/list -type f -iname "*-missing" | wc -l) - log ":: ${lidarrMissingTotalRecords} MISSING ALBUMS FOUND" + log "${lidarrMissingTotalRecords} MISSING ALBUMS FOUND" # Get cutoff album list lidarrCutoffTotalRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/cutoff?page=1&pagesize=1&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r .totalRecords) - log ":: FINDING CUTOFF ALBUMS sorted by $searchSort" + log "FINDING CUTOFF ALBUMS sorted by $searchSort" if [ $lidarrCutoffTotalRecords -ge 1 ]; then offsetcount=$(( $lidarrCutoffTotalRecords / $amountPerPull )) @@ -996,7 +1000,7 @@ GetMissingCutOffList () { if [ $dlnumber -gt $lidarrCutoffTotalRecords ]; then dlnumber=$lidarrCutoffTotalRecords fi - log ":: Downloading page $page... ($offset - $dlnumber of $lidarrCutoffTotalRecords Results)" + log "Downloading page $page... ($offset - $dlnumber of $lidarrCutoffTotalRecords Results)" lidarrRecords=$(wget --timeout=0 -q -O - "$lidarrUrl/api/v1/wanted/cutoff?page=$page&pagesize=$amountPerPull&sortKey=$searchOrder&sortDirection=$searchDirection&apikey=${lidarrApiKey}" | jq -r '.records[].id') for lidarrRecordId in $(echo $lidarrRecords); do if ! echo "$getNotFound" | grep "^$lidarrRecordId--" | read; then @@ -1007,17 +1011,17 @@ GetMissingCutOffList () { fi lidarrCutoffTotalRecords=$(find /config/extended/cache/lidarr/list -type f -iname "*-cutoff" | wc -l) - log ":: ${lidarrCutoffTotalRecords} CUTOFF ALBUMS FOUND" + log "${lidarrCutoffTotalRecords} CUTOFF ALBUMS FOUND" wantedListAlbumTotal=$(( $lidarrMissingTotalRecords + $lidarrCutoffTotalRecords )) - log ":: Searching for $wantedListAlbumTotal items" + log "Searching for $wantedListAlbumTotal items" } SearchProcess () { if [ $wantedListAlbumTotal = 0 ]; then - log ":: No items to find, end" + log "No items to find, end" return fi @@ -1035,12 +1039,12 @@ SearchProcess () { lidarrAlbumForeignAlbumId=$(echo "$lidarrAlbumData" | jq -r ".foreignAlbumId") if [ -f "/config/extended/logs/notfound/$wantedAlbumId--$lidarrArtistForeignArtistId--$lidarrAlbumForeignAlbumId" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..." continue fi if [ -f "/config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrAlbumTitle :: $lidarrAlbumType :: Previously Not Found, skipping..." rm "/config/extended/logs/downloaded/notfound/$lidarrAlbumForeignAlbumId" touch "/config/extended/logs/notfound/$wantedAlbumId--$lidarrArtistForeignArtistId--$lidarrAlbumForeignAlbumId" chmod 666 "/config/extended/logs/notfound/$wantedAlbumId--$lidarrArtistForeignArtistId--$lidarrAlbumForeignAlbumId" @@ -1079,9 +1083,9 @@ SearchProcess () { currentDateClean="$(echo "$currentDate" | sed -e "s%[^[:digit:]]%%g")" if [[ ${currentDateClean} -gt ${lidarrAlbumReleaseDateClean} ]]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Starting Search..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Starting Search..." else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Album ($lidarrAlbumReleaseDate) has not been released, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Album ($lidarrAlbumReleaseDate) has not been released, skipping..." continue fi @@ -1104,14 +1108,14 @@ SearchProcess () { # fallback to musicbrainz db for link if [ -z "$deezerArtistUrl" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: DEEZER :: Fallback to musicbrainz for Deezer ID" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: DEEZER :: Fallback to musicbrainz for Deezer ID" musicbrainzArtistData=$(curl -s -A "$agent" "https://musicbrainz.org/ws/2/artist/${lidarrArtistForeignArtistId}?inc=url-rels&fmt=json") deezerArtistUrl=$(echo "$musicbrainzArtistData" | jq -r '.relations | .[] | .url | select(.resource | contains("deezer")) | .resource') fi if [ -z "$deezerArtistUrl" ]; then sleep 1.5 - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: DEEZER :: ERROR :: musicbrainz id: $lidarrArtistForeignArtistId is missing Tidal link, see: \"/config/logs/deezer-artist-id-not-found.txt\" for more detail..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: DEEZER :: ERROR :: musicbrainz id: $lidarrArtistForeignArtistId is missing Tidal link, see: \"/config/logs/deezer-artist-id-not-found.txt\" for more detail..." touch "/config/logs/deezer-artist-id-not-found.txt" if cat "/config/logs/deezer-artist-id-not-found.txt" | grep "https://musicbrainz.org/artist/$lidarrArtistForeignArtistId/relationships" | read; then sleep 0.01 @@ -1128,14 +1132,14 @@ SearchProcess () { if [ "$skipTidal" = "false" ]; then # fallback to musicbrainz db for link if [ -z "$tidalArtistUrl" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: TIDAL :: Fallback to musicbrainz for Tidal ID" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: TIDAL :: Fallback to musicbrainz for Tidal ID" musicbrainzArtistData=$(curl -s -A "$agent" "https://musicbrainz.org/ws/2/artist/${lidarrArtistForeignArtistId}?inc=url-rels&fmt=json") tidalArtistUrl=$(echo "$musicbrainzArtistData" | jq -r '.relations | .[] | .url | select(.resource | contains("tidal")) | .resource') fi if [ -z "$tidalArtistUrl" ]; then sleep 1.5 - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: TIDAL :: ERROR :: musicbrainz id: $lidarrArtistForeignArtistId is missing Tidal link, see: \"/config/logs/tidal-artist-id-not-found.txt\" for more detail..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: TIDAL :: ERROR :: musicbrainz id: $lidarrArtistForeignArtistId is missing Tidal link, see: \"/config/logs/tidal-artist-id-not-found.txt\" for more detail..." touch "/config/logs/tidal-artist-id-not-found.txt" if cat "/config/logs/tidal-artist-id-not-found.txt" | grep "https://musicbrainz.org/artist/$lidarrArtistForeignArtistId/relationships" | read; then sleep 0.01 @@ -1195,7 +1199,7 @@ SearchProcess () { LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." break 2 fi @@ -1211,7 +1215,7 @@ SearchProcess () { LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." break 2 fi @@ -1229,7 +1233,7 @@ SearchProcess () { LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." break 2 fi @@ -1243,7 +1247,7 @@ SearchProcess () { LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." break 2 fi @@ -1266,7 +1270,7 @@ SearchProcess () { LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." continue fi @@ -1275,12 +1279,12 @@ SearchProcess () { if [ "$skipTidal" = "false" ]; then # Search Musicbrainz - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Tidal :: Searching for Album ID..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Tidal :: 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") # Process Album ID if found if [ ! -z $msuicbrainzTidalDownloadAlbumID ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Tidal ::: FOUND!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Tidal ::: FOUND!" tidalArtistAlbumData="$(curl -s "https://api.tidal.com/v1/albums/${msuicbrainzTidalDownloadAlbumID}?countryCode=$tidalCountryCode" -H 'x-tidal-token: CzET4vdadNUFQ5JU')" tidalAlbumTrackCount="$(echo "$tidalArtistAlbumData" | jq -r .numberOfTracks)" downloadedAlbumTitle="$(echo "${tidalArtistAlbumData}" | jq -r .title)" @@ -1289,19 +1293,19 @@ SearchProcess () { downloadedReleaseDate=$(echo "$tidalArtistAlbumData" | jq -r '.streamStartDate') fi downloadedReleaseYear="${downloadedReleaseDate:0:4}" - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Tidal :: Downloading $tidalAlbumTrackCount Tracks :: $downloadedAlbumTitle ($downloadedReleaseYear)" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Tidal :: Downloading $tidalAlbumTrackCount Tracks :: $downloadedAlbumTitle ($downloadedReleaseYear)" DownloadProcess "$msuicbrainzTidalDownloadAlbumID" "TIDAL" "$downloadedReleaseYear" "$downloadedAlbumTitle" "$tidalAlbumTrackCount" # Verify it was successfully imported into Lidarr LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." continue fi else sleep 1.5 - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Tidal :: NOT FOUND!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Tidal :: NOT FOUND!" fi fi fi @@ -1309,7 +1313,7 @@ SearchProcess () { LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." continue fi @@ -1318,12 +1322,12 @@ SearchProcess () { if [ "$skipDeezer" = "false" ]; then # Search Musicbrainz - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Deezer :: Searching for Album ID..." + 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") # Process Album ID if found if [ ! -z $msuicbrainzDeezerDownloadAlbumID ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Deezer :: FOUND!" + 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 @@ -1333,18 +1337,18 @@ SearchProcess () { 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)" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Deezer :: Downloading $deezerAlbumTrackCount Tracks :: $deezerAlbumTitle ($downloadedReleaseYear)" DownloadProcess "$msuicbrainzDeezerDownloadAlbumID" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount" # Verify it was successfully imported into Lidarr LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." continue fi else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Deezer :: NOT FOUND!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Musicbrainz URL :: Deezer :: NOT FOUND!" fi fi fi @@ -1352,18 +1356,18 @@ SearchProcess () { LidarrTaskStatusCheck CheckLidarrBeforeImport "$checkLidarrAlbumId" "notbeets" if [ $alreadyImported = true ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Already Imported, skipping..." continue fi - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Album Not found" - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Marking Album as notfound" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Album Not found" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $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 666 "/config/extended/logs/notfound/$wantedAlbumId--$lidarrArtistForeignArtistId--$lidarrAlbumForeignAlbumId" chown abc:abc "/config/extended/logs/notfound/$wantedAlbumId--$lidarrArtistForeignArtistId--$lidarrAlbumForeignAlbumId" fi - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Search Complete..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Search Complete..." done } @@ -1393,13 +1397,13 @@ ArtistDeezerSearch () { type=Clean fi - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: Searching $2... (Track Count: $lidarrAlbumReleasesMinTrackCount-$lidarrAlbumReleasesMaxTrackCount)..." - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: Filtering results by lyric type and \"$lidarrAlbumReleaseTitleFirstWord\"..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: Searching $2... (Track Count: $lidarrAlbumReleasesMinTrackCount-$lidarrAlbumReleasesMaxTrackCount)..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: Filtering results by lyric type and \"$lidarrAlbumReleaseTitleFirstWord\"..." deezerArtistAlbumsData=$(cat "/config/extended/cache/deezer/$2-albums.json" | jq -r .data[]) deezerArtistAlbumsIds=$(echo "${deezerArtistAlbumsData}" | jq -r "select(.explicit_lyrics=="$3") | select(.title | test(\"^$lidarrAlbumReleaseTitleFirstWord\";\"i\")) | .id") resultsCount=$(echo "$deezerArtistAlbumsIds" | wc -l) - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $resultsCount search results found" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $resultsCount search results found" for deezerAlbumID in $(echo "$deezerArtistAlbumsIds"); do deezerAlbumData="$(echo "$deezerSearch" | jq -r ".album | select(.id==$deezerAlbumID)")" deezerAlbumTitle="$(echo "$deezerAlbumData" | jq -r ".title")" @@ -1437,14 +1441,14 @@ ArtistDeezerSearch () { continue fi - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Checking for Match..." - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Calculating Similarity..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Checking for Match..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Calculating Similarity..." diff=$(levenshtein "${lidarrAlbumReleaseTitleClean,,}" "${deezerAlbumTitleClean,,}" 2>/dev/null) if [ "$diff" -le "5" ]; then - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Deezer MATCH Found :: Calculated Difference = $diff" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Deezer MATCH Found :: Calculated Difference = $diff" # Execute Download - 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 "$deezerArtistAlbumId" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount" @@ -1460,8 +1464,8 @@ ArtistDeezerSearch () { 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..." + 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 } @@ -1481,7 +1485,7 @@ FuzzyDeezerSearch () { mkdir -p /config/extended/cache/deezer fi - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: Searching... (Track Count: $lidarrAlbumReleasesMinTrackCount-$lidarrAlbumReleasesMaxTrackCount)" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: Searching... (Track Count: $lidarrAlbumReleasesMinTrackCount-$lidarrAlbumReleasesMaxTrackCount)" deezerSearch="" if [ "$lidarrArtistForeignArtistId" = "89ad4ac3-39f7-470e-963a-56509c546377" ]; then @@ -1492,7 +1496,7 @@ FuzzyDeezerSearch () { deezerSearch=$(curl -s "https://api.deezer.com/search?q=artist:%22${albumArtistNameSearch}%22%20album:%22${albumTitleSearch}%22&strict=on&limit=20" | jq -r ".data[]") fi resultsCount=$(echo "$deezerSearch" | jq -r .album.id | sort -u | wc -l) - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: $resultsCount search results found" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: $resultsCount search results found" if [ ! -z "$deezerSearch" ]; then for deezerAlbumID in $(echo "$deezerSearch" | jq -r .album.id | sort -u); do deezerAlbumData="$(echo "$deezerSearch" | jq -r ".album | select(.id==$deezerAlbumID)")" @@ -1537,12 +1541,12 @@ FuzzyDeezerSearch () { continue fi - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Checking for Match..." - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Calculating Similarity..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Checking for Match..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Calculating Similarity..." diff=$(levenshtein "${lidarrAlbumReleaseTitleClean,,}" "${deezerAlbumTitleClean,,}" 2>/dev/null) if [ "$diff" -le "5" ]; then - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Deezer MATCH Found :: Calculated Difference = $diff" - 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 :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Deezer MATCH Found :: Calculated Difference = $diff" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: Downloading $deezerAlbumTrackCount Tracks :: $deezerAlbumTitle ($downloadedReleaseYear)" DownloadProcess "$deezerAlbumID" "DEEZER" "$downloadedReleaseYear" "$deezerAlbumTitle" "$deezerAlbumTrackCount" @@ -1554,9 +1558,9 @@ FuzzyDeezerSearch () { fi fi 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..." else - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: ERROR :: No results found via Fuzzy Search..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Deezer :: $type :: $lidarrReleaseTitle :: ERROR :: No results found via Fuzzy Search..." fi } @@ -1589,19 +1593,19 @@ ArtistTidalSearch () { fi - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: Searching $2... (Track Count: $lidarrAlbumReleasesMinTrackCount-$lidarrAlbumReleasesMaxTrackCount)..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: Searching $2... (Track Count: $lidarrAlbumReleasesMinTrackCount-$lidarrAlbumReleasesMaxTrackCount)..." tidalArtistAlbumsData=$(cat "/config/extended/cache/tidal/$2-albums.json" | jq -r ".items | sort_by(.numberOfTracks) | sort_by(.explicit) | reverse |.[] | select((.numberOfTracks <= $lidarrAlbumReleasesMaxTrackCount) and .numberOfTracks >= $lidarrAlbumReleasesMinTrackCount)") - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: Filtering results by lyric type, track count and \"$lidarrAlbumReleaseTitleFirstWord\"" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: Filtering results by lyric type, track count and \"$lidarrAlbumReleaseTitleFirstWord\"" tidalArtistAlbumsIds=$(echo "${tidalArtistAlbumsData}" | jq -r "select(.explicit=="$3") | select(.title | test(\"^$lidarrAlbumReleaseTitleFirstWord\";\"i\")) | .id") if [ -z "$tidalArtistAlbumsIds" ]; then - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: ERROR :: No search results found..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: ERROR :: No search results found..." return fi searchResultCount=$(echo "$tidalArtistAlbumsIds" | wc -l) - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $searchResultCount search results found" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $searchResultCount search results found" for tidalArtistAlbumId in $(echo $tidalArtistAlbumsIds); do tidalArtistAlbumData=$(echo "$tidalArtistAlbumsData" | jq -r "select(.id=="$tidalArtistAlbumId")") @@ -1622,14 +1626,14 @@ ArtistTidalSearch () { continue fi - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Checking for Match..." - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Calculating Similarity..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Checking for Match..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Calculating Similarity..." diff=$(levenshtein "${lidarrAlbumReleaseTitleClean,,}" "${tidalAlbumTitleClean,,}" 2>/dev/null) if [ "$diff" -le "5" ]; then - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal MATCH Found :: Calculated Difference = $diff" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal MATCH Found :: Calculated Difference = $diff" # Execute Download - 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" @@ -1640,15 +1644,15 @@ ArtistTidalSearch () { break fi 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 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" + 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 } @@ -1664,7 +1668,7 @@ FuzzyTidalSearch () { type=Clean fi - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: Searching... (Track Count: $lidarrAlbumReleasesMinTrackCount-$lidarrAlbumReleasesMaxTrackCount)..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: Searching... (Track Count: $lidarrAlbumReleasesMinTrackCount-$lidarrAlbumReleasesMaxTrackCount)..." if [ "$lidarrArtistForeignArtistId" = "89ad4ac3-39f7-470e-963a-56509c546377" ]; then # Search without Artist for VA albums @@ -1676,7 +1680,7 @@ FuzzyTidalSearch () { sleep $sleepTimer searchResultCount=$(echo "$tidalSearch" | jq -r .id | sort -u | wc -l) - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $searchResultCount search results found" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $searchResultCount search results found" if [ ! -z "$tidalSearch" ]; then for tidalAlbumID in $(echo "$tidalSearch" | jq -r .id | sort -u); do tidalAlbumData="$(echo "$tidalSearch" | jq -r "select(.id==$tidalAlbumID)")" @@ -1697,12 +1701,12 @@ FuzzyTidalSearch () { continue fi - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Checking for Match..." - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Calculating Similarity..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Checking for Match..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Calculating Similarity..." diff=$(levenshtein "${lidarrAlbumReleaseTitleClean,,}" "${tidalAlbumTitleClean,,}" 2>/dev/null) if [ "$diff" -le "5" ]; then - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal MATCH Found :: Calculated Difference = $diff" - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: Downloading $downloadedTrackCount Tracks :: $tidalAlbumTitle ($downloadedReleaseYear)" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal MATCH Found :: Calculated Difference = $diff" + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: Downloading $downloadedTrackCount Tracks :: $tidalAlbumTitle ($downloadedReleaseYear)" DownloadProcess "$tidalAlbumID" "TIDAL" "$downloadedReleaseYear" "$tidalAlbumTitle" "$downloadedTrackCount" @@ -1714,12 +1718,12 @@ FuzzyTidalSearch () { fi 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 done - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: ERROR :: Albums found, but none matching search criteria..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: ERROR :: Albums found, but none matching search criteria..." else - log ":: $1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: ERROR :: No results found..." + log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Fuzzy Search :: Tidal :: $type :: $lidarrReleaseTitle :: ERROR :: No results found..." fi } @@ -1752,9 +1756,9 @@ ProcessWithBeets () { if [ $(find "$1" -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | wc -l) -gt 0 ]; then beet -c /scripts/beets-config.yaml -l /scripts/library.blb -d "$1" import -qC "$1" 1>/dev/null if [ $(find "$1" -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" -newer "/config/beets-match" | wc -l) -gt 0 ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: SUCCESS: Matched with beets!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: SUCCESS: Matched with beets!" else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Unable to match using beets to a musicbrainz release..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Unable to match using beets to a musicbrainz release..." touch "/config/beets-match-error" fi fi @@ -1765,13 +1769,13 @@ ProcessWithBeets () { fi if [ -f "/config/beets-match-error" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Beets could not match album, falling back to Lidarr for matching and importing..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Beets could not match album, falling back to Lidarr for matching and importing..." rm "/config/beets-match-error" # allow lidarr import... # rm -rf "$1" return else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: BEETS MATCH FOUND!" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: BEETS MATCH FOUND!" fi GetFile=$(find "$1" -type f -regex ".*/.*\.\(flac\|opus\|m4a\|mp3\)" | head -n1) @@ -1808,8 +1812,8 @@ ProcessWithBeets () { fi if [ -z "$matchedLidarrAlbumData" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Musicbrainz Release Group ID: $matchedTagsAlbumReleaseGroupId cannot be imported, due to status issue.." - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Correct Musicbrainz Entry to resolve error..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Musicbrainz Release Group ID: $matchedTagsAlbumReleaseGroupId cannot be imported, due to status issue.." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Correct Musicbrainz Entry to resolve error..." rm -rf "$1" return fi @@ -1826,9 +1830,9 @@ ProcessWithBeets () { sleep 0.1 else if [ "${matchedLidarrAlbumArtistCleanName}" != "null" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: $matchedLidarrAlbumArtistName ($matchedLidarrAlbumArtistId) found in Lidarr" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: $matchedLidarrAlbumArtistName ($matchedLidarrAlbumArtistId) found in Lidarr" else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: $matchedLidarrAlbumArtistName ($matchedLidarrAlbumArtistId) NOT found in Lidarr" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: $matchedLidarrAlbumArtistName ($matchedLidarrAlbumArtistId) NOT found in Lidarr" data=$(curl -s "$lidarrUrl/api/v1/search?term=lidarr%3A$matchedLidarrAlbumArtistId" -H "X-Api-Key: $lidarrApiKey" | jq -r ".[]") artistName="$(echo "$data" | jq -r ".artist.artistName")" foreignId="$(echo "$data" | jq -r ".foreignId")" @@ -1846,9 +1850,9 @@ ProcessWithBeets () { \"rootFolderPath\": \"$path\", \"addOptions\":{\"searchForMissingAlbums\":false} }" - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Adding Missing Artist to Lidarr :: $matchedLidarrAlbumArtistName ($matchedLidarrAlbumArtistId)..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Adding Missing Artist to Lidarr :: $matchedLidarrAlbumArtistName ($matchedLidarrAlbumArtistId)..." lidarrAddArtist=$(curl -s "$lidarrUrl/api/v1/artist" -X POST -H 'Content-Type: application/json' -H "X-Api-Key: $lidarrApiKey" --data-raw "$data") - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Allowing Lidarr Artist Update..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Allowing Lidarr Artist Update..." LidarrTaskStatusCheck fi fi @@ -1883,11 +1887,11 @@ CheckLidarrBeforeImport () { fi if [ ${checkLidarrAlbumPercentOfTracks%%.*} -ge 100 ]; then if [ $wantedAlbumListSource = missing ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Already Imported Album (Missing)" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Already Imported Album (Missing)" alreadyImported=true return else - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Importing Album (Cutoff)" + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: Importing Album (Cutoff)" return fi fi @@ -1895,7 +1899,7 @@ CheckLidarrBeforeImport () { if [ "$2" = "notbeets" ]; then if [ -f "/config/extended/logs/downloaded/found/$1" ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Found, skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Previously Found, skipping..." alreadyImported=true return fi @@ -1909,7 +1913,7 @@ CheckLidarrBeforeImport () { fi if [ ${checkLidarrAlbumPercentOfTracks%%.*} -ge 100 ]; then if [ $wantedAlbumListSource = missing ]; then - log ":: $processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Already Imported Album (Missing), skipping..." + log "$processNumber of $wantedListAlbumTotal :: $lidarrArtistNameSanitized :: $lidarrAlbumTitle :: $lidarrAlbumType :: ERROR :: Already Imported Album (Missing), skipping..." alreadyImported=true return fi @@ -1918,13 +1922,13 @@ CheckLidarrBeforeImport () { } AddRelatedArtists () { - log ":: Begin adding Lidarr related Artists from Deezer..." + log "Begin adding Lidarr related Artists from Deezer..." lidarrArtistsData="$(curl -s "$lidarrUrl/api/v1/artist?apikey=${lidarrApiKey}")" lidarrArtistTotal=$(echo "${lidarrArtistsData}"| jq -r '.[].sortName' | wc -l) lidarrArtistList=($(echo "${lidarrArtistsData}" | jq -r ".[].foreignArtistId")) lidarrArtistIds="$(echo "${lidarrArtistsData}" | jq -r ".[].foreignArtistId")" 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") deezerArtistIds="$(echo "$deezerArtistsUrl" | grep -o '[[:digit:]]*' | sort -u)" @@ -1936,9 +1940,9 @@ AddRelatedArtists () { deezerArtistUrl=$(echo "${lidarrArtistData}" | jq -r ".links | .[] | select(.name==\"deezer\") | .url") deezerArtistIds=($(echo "$deezerArtistUrl" | grep -o '[[:digit:]]*' | sort -u)) lidarrArtistMonitored=$(echo "${lidarrArtistData}" | jq -r ".monitored") - log ":: $artistNumber of $lidarrArtistTotal :: $lidarrArtistName :: Adding Related Artists..." + log "$artistNumber of $lidarrArtistTotal :: $lidarrArtistName :: Adding Related Artists..." if [ $lidarrArtistMonitored = false ]; then - log ":: $artistNumber of $lidarrArtistTotal :: $lidarrArtistName :: Artist is not monitored :: skipping..." + log "$artistNumber of $lidarrArtistTotal :: $lidarrArtistName :: Artist is not monitored :: skipping..." continue fi @@ -1962,7 +1966,7 @@ LidarrTaskStatusCheck () { if [ "$taskCount" -ge "1" ]; then if [ "$alerted" = "no" ]; then alerted=yes - log ":: STATUS :: LIDARR BUSY :: Pausing/waiting for all active Lidarr tasks to end..." + log "STATUS :: LIDARR BUSY :: Pausing/waiting for all active Lidarr tasks to end..." fi sleep 2 else @@ -1973,7 +1977,7 @@ LidarrTaskStatusCheck () { LidarrMissingAlbumSearch () { - log ":: Begin searching for missing artist albums via Lidarr Indexers..." + log "Begin searching for missing artist albums via Lidarr Indexers..." lidarrArtistIds=$(echo $lidarrMissingAlbumArtistsData | jq -r .id) lidarrArtistIdsCount=$(echo "$lidarrArtistIds" | wc -l) processCount=0 @@ -1984,11 +1988,11 @@ LidarrMissingAlbumSearch () { lidarrArtistMusicbrainzId=$(echo $lidarrArtistData | jq -r .foreignArtistId) if [ -d /config/extended/logs/searched/lidarr/artist ]; then if [ -f /config/extended/logs/searched/lidarr/artist/$lidarrArtistMusicbrainzId ]; then - log ":: $processCount of $lidarrArtistIdsCount :: Previously Notified Lidarr to search for \"$lidarrArtistName\" :: Skipping..." + log "$processCount of $lidarrArtistIdsCount :: Previously Notified Lidarr to search for \"$lidarrArtistName\" :: Skipping..." continue fi fi - log ":: $processCount of $lidarrArtistIdsCount :: Notified Lidarr to search for \"$lidarrArtistName\"" + log "$processCount of $lidarrArtistIdsCount :: Notified Lidarr to search for \"$lidarrArtistName\"" startLidarrArtistSearch=$(curl -s "$lidarrUrl/api/v1/command" -X POST -H "Content-Type: application/json" -H "X-Api-Key: $lidarrApiKey" --data-raw "{\"name\":\"ArtistSearch\",\"artistId\":$lidarrArtistId}") if [ ! -d /config/extended/logs/searched/lidarr/artist ]; then mkdir -p /config/extended/logs/searched/lidarr/artist @@ -2049,9 +2053,9 @@ if [ "$configureLidarrWithOptimalSettings" = "true" ]; then if [ ! -f /config/extended/logs/autoconfig ]; then ConfigureLidarrWithOptimalSettings else - log ":: Lidarr previously configured with optimal settings, skipping..." - log ":: To re-configure Lidarr, delete the following file:" - log ":: /config/extended/logs/autoconfig" + log "Lidarr previously configured with optimal settings, skipping..." + log "To re-configure Lidarr, delete the following file:" + log "/config/extended/logs/autoconfig" fi fi @@ -2096,14 +2100,14 @@ if [ "$dlClientSource" = "deezer" ] || [ "$dlClientSource" = "tidal" ] || [ "$dl GetMissingCutOffList SearchProcess else - log ":: ERROR :: No valid dlClientSource set" - log ":: ERROR :: Expected configuration :: deezer or tidal or both" - log ":: ERROR :: dlClientSource set as: \"$dlClientSource\"" + log "ERROR :: No valid dlClientSource set" + log "ERROR :: Expected configuration :: deezer or tidal or both" + log "ERROR :: dlClientSource set as: \"$dlClientSource\"" fi if [ "$addDeezerTopArtists" = "true" ] || [ "$addDeezerTopAlbumArtists" = "true" ] || [ "$addDeezerTopTrackArtists" = "true" ] || [ "$addRelatedArtists" = "true" ]; then LidarrMissingAlbumSearch fi -log ":: Script end..." +log "Script end..." exit