Fix Unicode dash mismatch in Lidarr discovery dedup check
blink-182 kept getting rescored and re-added every week despite already being in the library (id=155). Root cause: MusicBrainz's canonical name is 'blink‐182' using a Unicode hyphen (U+2010), while Last.fm's candidate list returns the plain ASCII hyphen — the exact-string _in_lidarr() / _in_emby_library() checks never matched, so it was treated as a new artist every run, scored, accepted, and its add attempt correctly failed against Lidarr's duplicate-MBID rejection. Added _normalize_dashes() to collapse Unicode hyphen/dash variants (U+2010 through U+2014) to ASCII '-' before comparing, applied to both the stored library name lists and each candidate name at match time. Fixes this for any artist with a stylized dash in their canonical name, not just this one.
This commit is contained in:
@@ -529,8 +529,25 @@ EMBY_ARTIST_NAMES=$(echo "$EMBY_LIBRARY_JSON" | jq -r '.Items[] | .AlbumArtists[
|
|||||||
EMBY_ARTIST_COUNT=$(echo "$EMBY_ARTIST_NAMES" | grep -c . 2>/dev/null || echo 0)
|
EMBY_ARTIST_COUNT=$(echo "$EMBY_ARTIST_NAMES" | grep -c . 2>/dev/null || echo 0)
|
||||||
log "$EMBY_ARTIST_COUNT album artists in Emby library"
|
log "$EMBY_ARTIST_COUNT album artists in Emby library"
|
||||||
|
|
||||||
_in_lidarr() { echo "$LIDARR_NAMES" | grep -iq "^${1}$"; }
|
# MusicBrainz's canonical name for some artists (e.g. "blink‐182") uses a Unicode
|
||||||
_in_emby_library(){ [[ -n "$EMBY_ARTIST_NAMES" ]] && echo "$EMBY_ARTIST_NAMES" | grep -iq "^${1}$"; }
|
# hyphen/dash rather than plain ASCII "-". Last.fm's candidate names are plain ASCII,
|
||||||
|
# so an exact-string match against Lidarr/Emby's names silently misses these artists
|
||||||
|
# every time — they never register as "already known" and get retried (and rejected
|
||||||
|
# as duplicates) on every future run. Normalize both sides before comparing.
|
||||||
|
_normalize_dashes() {
|
||||||
|
local n="$1"
|
||||||
|
n="${n//‐/-}" # U+2010 HYPHEN
|
||||||
|
n="${n//‑/-}" # U+2011 NON-BREAKING HYPHEN
|
||||||
|
n="${n//‒/-}" # U+2012 FIGURE DASH
|
||||||
|
n="${n//–/-}" # U+2013 EN DASH
|
||||||
|
n="${n//—/-}" # U+2014 EM DASH
|
||||||
|
echo "$n"
|
||||||
|
}
|
||||||
|
LIDARR_NAMES=$(_normalize_dashes "$LIDARR_NAMES")
|
||||||
|
EMBY_ARTIST_NAMES=$(_normalize_dashes "$EMBY_ARTIST_NAMES")
|
||||||
|
|
||||||
|
_in_lidarr() { echo "$LIDARR_NAMES" | grep -iq "^$(_normalize_dashes "$1")$"; }
|
||||||
|
_in_emby_library(){ [[ -n "$EMBY_ARTIST_NAMES" ]] && echo "$EMBY_ARTIST_NAMES" | grep -iq "^$(_normalize_dashes "$1")$"; }
|
||||||
|
|
||||||
# ==============================================================================================
|
# ==============================================================================================
|
||||||
# ━━━ Score Stage 2 Candidates ━━━
|
# ━━━ Score Stage 2 Candidates ━━━
|
||||||
|
|||||||
Reference in New Issue
Block a user