コード例 #1
0
        private void LoadChangesFromFiles()
        {
            foreach (Tuple <Release, LocalAlbum> item in matcherResult.ChangedReleases)
            {
                Release    release = item.Item1;
                LocalAlbum album   = item.Item2;
                release.Genre = album.Genre ?? release.Genre;
                if (album.Year != 0 && release.ReleaseDate.Date.Year != album.Year)
                {
                    release.ReleaseDate = album.Year == 0 ? new ReleaseDate() : new ReleaseDate(album.Year);
                }
                if (!this.collectionManager.Operations.MatchReleaseTracklistWithLocalAlbum(release, album))
                {
                    release.Tracklist.Clear();
                    release.Tracklist.AddRange(this.collectionManager.Operations.GenerateTracklistForLocalAlbum(this.collectionManager, album, release));
                }
                release.DateModified = DateTime.Now;

                release.UpdateDynamicProperties();
                this.collectionManager.Save(release);

                ++this.totalProcessed;
                this.OnProgressChanged();
            }
        }
コード例 #2
0
        public List<Track> GenerateTracklistForLocalAlbum(ICollectionManager collectionManager, LocalAlbum album, Release release)
        {
            List<Track> list = new List<Track>();
            foreach (LocalDisc disc in album.Discs)
            {
                bool hasTrackArtists = disc.Tracks.Any(t => t.Artist != disc.Tracks[0].Artist);

                foreach (TrackInfoCache localTrack in disc.Tracks)
                {
                    Track track = new Track()
                    {
                        Disc = localTrack.Disc,
                        Position = localTrack.Track,
                        Title = localTrack.Title,
                        RelativeFilename = localTrack.RelativeFilename
                    };
                    if (hasTrackArtists)
                    {
                        track.Artists.Add(new TrackArtist()
                        {
                            Artist = collectionManager.GetOrCreateArtist(localTrack.Artist),
                        });
                        track.JoinedArtists = localTrack.Artist;
                    }

                    list.Add(track);
                }
            }
            return list;
        }
コード例 #3
0
        public bool MatchReleaseTracklistWithLocalAlbum(Release release, LocalAlbum localAlbum)
        {
            List<Track> tracks = this.GenerateTracklistForLocalAlbum(this.collectionManager, localAlbum, null);

            for (int i = 0; i < tracks.Count; ++i)
            {
                Track track = release.Tracklist[i];
                Track localTrack = tracks[i];

                if (track.RelativeFilename != localTrack.RelativeFilename)
                {
                    return false;
                }
                if (track.Title != localTrack.Title)
                {
                    return false;
                }
                if (track.JoinedArtists != localTrack.JoinedArtists)
                {
                    return false;
                }
                if (track.Disc != localTrack.Disc)
                {
                    return false;
                }
                if (track.Position != localTrack.Position)
                {
                    return false;
                }
            }

            foreach (LocalDisc disc in localAlbum.Discs)
            {
                foreach (TrackInfoCache track in disc.Tracks)
                {
                    if (track.Year != 0 && track.Year != release.ReleaseDate.Date.Year)
                    {
                        return false;
                    }
                    if (track.Year == 0 && release.ReleaseDate.IsValid)
                    {
                        return false;
                    }
                    if (track.RelativeFilename != track.RelativeFilename)
                    {
                        return false;
                    }

                    if (track.Genre != release.Genre)
                    {
                        return false;
                    }
                    if (track.DiscCount != release.DiscCount)
                    {
                        return false;
                    }
                    if (track.AlbumArtist != release.JoinedAlbumArtists)
                    {
                        return false;
                    }
                    if (track.Album != release.Title)
                    {
                        return false;
                    }
                }
            }

            return true;
        }
コード例 #4
0
        public bool MatchReleaseWithLocalAlbum(Release release, LocalAlbum localAlbum)
        {
            if (release.JoinedAlbumArtists != localAlbum.AlbumArtist)
            {
                return false;
            }
            if (release.Title != localAlbum.Title)
            {
                return false;
            }

            if (localAlbum.Year != 0 && release.ReleaseDate.Date.Year != localAlbum.Year)
            {
                return false;
            }
            if (localAlbum.Year == 0 && release.ReleaseDate.IsValid)
            {
                return false;
            }

            if (release.Genre != localAlbum.Genre)
            {
                return false;
            }
            if (release.DiscCount != localAlbum.DiscCount)
            {
                return false;
            }

            if (!MatchReleaseTracklistWithLocalAlbum(release, localAlbum))
            {
                return false;
            }

            return true;
        }
コード例 #5
0
 public Release GetReleaseByLocalAlbumName(LocalAlbum localAlbum)
 {
     return this.collectionManager.Releases
         .Where(r => r.Title == localAlbum.Title && r.JoinedAlbumArtists == localAlbum.AlbumArtist)
         .FirstOrDefault();
 }