mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Parser Enhancements (#291)
* When matching tracks with metadata, ensure we also check their track number as some albums have two tracks with same title.
This commit is contained in:
parent
e67af5e747
commit
b661344ba8
3 changed files with 23 additions and 9 deletions
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Music
|
|||
Track GetTrack(int id);
|
||||
List<Track> GetTracks(IEnumerable<int> ids);
|
||||
Track FindTrack(int artistId, int albumId, int mediumNumber, int trackNumber);
|
||||
Track FindTrackByTitle(int artistId, int albumId, int mediumNumber, string releaseTitle);
|
||||
Track FindTrackByTitle(int artistId, int albumId, int mediumNumber, int trackNumber, string releaseTitle);
|
||||
List<Track> GetTracksByArtist(int artistId);
|
||||
List<Track> GetTracksByAlbum(int albumId);
|
||||
//List<Track> GetTracksByAlbumTitle(string artistId, string albumTitle);
|
||||
|
@ -76,7 +76,7 @@ namespace NzbDrone.Core.Music
|
|||
return _trackRepository.GetTracksByAlbum(albumId);
|
||||
}
|
||||
|
||||
public Track FindTrackByTitle(int artistId, int albumId, int mediumNumber, string releaseTitle)
|
||||
public Track FindTrackByTitle(int artistId, int albumId, int mediumNumber, int trackNumber, string releaseTitle)
|
||||
{
|
||||
// TODO: can replace this search mechanism with something smarter/faster/better
|
||||
var normalizedReleaseTitle = Parser.Parser.NormalizeEpisodeTitle(releaseTitle).Replace(".", " ");
|
||||
|
@ -88,11 +88,19 @@ namespace NzbDrone.Core.Music
|
|||
Position = normalizedReleaseTitle.IndexOf(Parser.Parser.NormalizeEpisodeTitle(track.Title), StringComparison.CurrentCultureIgnoreCase),
|
||||
Length = Parser.Parser.NormalizeEpisodeTitle(track.Title).Length,
|
||||
Track = track
|
||||
})
|
||||
.Where(e => e.Track.Title.Length > 0 && e.Position >= 0)
|
||||
.OrderBy(e => e.Position)
|
||||
.ThenByDescending(e => e.Length)
|
||||
.ToList();
|
||||
});
|
||||
|
||||
if (trackNumber == 0)
|
||||
{
|
||||
matches = matches.Where(e => e.Track.Title.Length > 0 && e.Position >= 0);
|
||||
} else
|
||||
{
|
||||
matches = matches.Where(e => e.Track.Title.Length > 0 && e.Position >= 0 && e.Track.AbsoluteTrackNumber == trackNumber);
|
||||
}
|
||||
|
||||
matches.OrderBy(e => e.Position)
|
||||
.ThenByDescending(e => e.Length)
|
||||
.ToList();
|
||||
|
||||
if (matches.Any())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue