From 91b01c69535d9fa97b3c974ec1530899ff009eb7 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Fri, 23 Sep 2022 07:38:34 -0400 Subject: [PATCH] 1.0.248 - Use new matchDistance parameter #76 --- root/scripts/audio.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/root/scripts/audio.sh b/root/scripts/audio.sh index 12321ba..d623d56 100644 --- a/root/scripts/audio.sh +++ b/root/scripts/audio.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.0.247" +scriptVersion="1.0.248" if [ -z "$lidarrUrl" ] || [ -z "$lidarrApiKey" ]; then lidarrUrlBase="$(cat /config/config.xml | xq | jq -r .Config.UrlBase)" if [ "$lidarrUrlBase" == "null" ]; then @@ -29,6 +29,7 @@ musicbrainzMirror=https://musicbrainz.org #requireQuality="true" #searchSort="album" #arlToken="" +#matchDistance=10 sleepTimer=0.5 @@ -153,6 +154,8 @@ Configuration () { else log "Replaygain Tagging Disabled" fi + + log "Match Distance: $matchDistance" } @@ -1492,7 +1495,7 @@ ArtistDeezerSearch () { deezerAlbumTitleClean="$(echo ${deezerAlbumTitle} | sed -e "s%[^[:alpha:][:digit:]]%%g" -e "s/ */ /g" | sed 's/^[.]*//' | sed 's/[.]*$//g' | sed 's/^ *//g' | sed 's/ *$//g')" # String Character Count test, quicker than the levenshtein method to allow faster processing characterMath=$(( ${#deezerAlbumTitleClean} - ${#lidarrAlbumReleaseTitleClean} )) - if [ "$characterMath" -gt "5" ]; then + if [ "$characterMath" -gt "$matchDistance" ]; then continue elif [ "$characterMath" -lt "0" ]; then continue @@ -1519,7 +1522,7 @@ ArtistDeezerSearch () { 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 + if [ "$diff" -le "$matchDistance" ]; then log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Deezer :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $deezerAlbumTitleClean :: Deezer MATCH Found :: Calculated Difference = $diff" # Execute Download @@ -1581,7 +1584,7 @@ FuzzyDeezerSearch () { # String Character Count test, quicker than the levenshtein method to allow faster processing characterMath=$(( ${#deezerAlbumTitleClean} - ${#lidarrAlbumReleaseTitleClean} )) - if [ "$characterMath" -gt "5" ]; then + if [ "$characterMath" -gt "$matchDistance" ]; then continue elif [ "$characterMath" -lt "0" ]; then continue @@ -1613,7 +1616,7 @@ FuzzyDeezerSearch () { 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 + if [ "$diff" -le "$matchDistance" ]; 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)" @@ -1689,7 +1692,7 @@ ArtistTidalSearch () { # String Character Count test, quicker than the levenshtein method to allow faster processing characterMath=$(( ${#tidalAlbumTitleClean} - ${#lidarrAlbumReleaseTitleClean} )) - if [ "$characterMath" -gt "5" ]; then + if [ "$characterMath" -gt "$matchDistance" ]; then continue elif [ "$characterMath" -lt "0" ]; then continue @@ -1698,7 +1701,7 @@ ArtistTidalSearch () { 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 + if [ "$diff" -le "$matchDistance" ]; then log "$1 :: $lidarrArtistName :: $lidarrAlbumTitle :: $lidarrAlbumType :: Artist Search :: Tidal :: $type :: $lidarrReleaseTitle :: $lidarrAlbumReleaseTitleClean vs $tidalAlbumTitleClean :: Tidal MATCH Found :: Calculated Difference = $diff" # Execute Download @@ -1764,7 +1767,7 @@ FuzzyTidalSearch () { # String Character Count test, quicker than the levenshtein method to allow faster processing characterMath=$(( ${#tidalAlbumTitleClean} - ${#lidarrAlbumReleaseTitleClean} )) - if [ "$characterMath" -gt "5" ]; then + if [ "$characterMath" -gt "$matchDistance" ]; then continue elif [ "$characterMath" -lt "0" ]; then continue @@ -1773,7 +1776,7 @@ FuzzyTidalSearch () { 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 + if [ "$diff" -le "$matchDistance" ]; 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)"