From 2c5b0a289f5bbef4354a0db9bd6aa12d0bfbfdde Mon Sep 17 00:00:00 2001 From: Matrix Runout Date: Thu, 3 Dec 2026 07:01:02 -0700 Subject: [PATCH] Include the track version in the title tag Deezer keeps a track's mix or edit apart from its title: SNG_TITLE "Watch The Sunrise", VERSION "(Axwell Remode)". The title tag used SNG_TITLE alone, so every track of a remix release got the same title and Lidarr, which matches tracks by title, could only tell them apart by length. Axwell's "Watch The Sunrise (Remixes)" was matched to the wrong release and rejected at 63%. Co-Authored-By: Claude Opus 5.5 --- DeezNET.Tests/MetadataTests.cs | 21 +++++++++++++++++++++ DeezNET/Downloader.cs | 13 ++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/DeezNET.Tests/MetadataTests.cs b/DeezNET.Tests/MetadataTests.cs index 0386b6b..720fd40 100644 --- a/DeezNET.Tests/MetadataTests.cs +++ b/DeezNET.Tests/MetadataTests.cs @@ -28,5 +28,26 @@ public void ParseYearTreatsMissingDateAsMissing() { Downloader.ParseYear(null).ShouldBeNull(); } + + [Fact] + public void TrackTitleIncludesTheVersion() + { + var data = new JObject { ["SNG_TITLE"] = "Watch The Sunrise", ["VERSION"] = "(Axwell Remode)" }; + + Downloader.TrackTitle(data).ShouldBe("Watch The Sunrise (Axwell Remode)"); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + [InlineData(" ")] + public void TrackTitleWithoutAVersionIsTheTitle(string? version) + { + var data = new JObject { ["SNG_TITLE"] = "Watch The Sunrise" }; + if (version != null) + data["VERSION"] = version; + + Downloader.TrackTitle(data).ShouldBe("Watch The Sunrise"); + } } } diff --git a/DeezNET/Downloader.cs b/DeezNET/Downloader.cs index 51ecdb0..146ed10 100644 --- a/DeezNET/Downloader.cs +++ b/DeezNET/Downloader.cs @@ -369,7 +369,7 @@ private async Task ApplyMetadataToTagLibFile(TagLib.File track, long trackId, in byte[]? albumArt = null; try { albumArt = await GetArtBytes(page["DATA"]!["ALB_PICTURE"]!.ToString(), coverResolution, token); } catch (UnavailableArtException) { } - track.Tag.Title = page["DATA"]!["SNG_TITLE"]!.ToString(); + track.Tag.Title = TrackTitle(page["DATA"]!); track.Tag.Album = page["DATA"]!["ALB_TITLE"]!.ToString(); track.Tag.Performers = page["DATA"]!["ARTISTS"]!.Select(a => a["ART_NAME"]!.ToString()).ToArray(); track.Tag.AlbumArtists = albumPage["DATA"]!["ARTISTS"]!.Select(a => a["ART_NAME"]!.ToString()).ToArray(); @@ -499,6 +499,17 @@ private async Task ApplyMetadataToTagLibFile(TagLib.File track, long trackId, in track.Save(); } + // Deezer keeps a track's mix or edit apart from its title: SNG_TITLE "Watch The Sunrise", VERSION "(Axwell Remode)". + // Without the version every track of a remix release is tagged with the same title, and Lidarr, which matches + // tracks by title, can only tell them apart by length. + internal static string TrackTitle(JToken data) + { + string title = data["SNG_TITLE"]!.ToString(); + string? version = data["VERSION"]?.ToString().Trim(); + + return string.IsNullOrEmpty(version) ? title : $"{title} {version}"; + } + // reads the year from a yyyy-MM-dd date, treating 0000 and anything unparseable as missing internal static uint? ParseYear(JToken? date) {