Exemple #1
0
        public override T CloneBasicInstance <T>()
        {
            if (typeof(T) == typeof(AlbumInfo))
            {
                AlbumInfo info = new AlbumInfo();
                info.AudioDbId          = AlbumAudioDbId;
                info.CdDdId             = AlbumCdDdId;
                info.MusicBrainzDiscId  = AlbumMusicBrainzDiscId;
                info.MusicBrainzGroupId = AlbumMusicBrainzGroupId;
                info.MusicBrainzId      = AlbumMusicBrainzId;
                info.AmazonId           = AlbumAmazonId;
                info.ItunesId           = AlbumItunesId;
                info.NameId             = AlbumNameId;
                foreach (var keyVal in CustomAlbumIds)
                {
                    info.CustomIds[keyVal.Key] = keyVal.Value;
                }

                info.Album       = Album;
                info.DiscNum     = DiscNum;
                info.TotalDiscs  = TotalDiscs;
                info.TotalTracks = TotalTracks;
                info.Compilation = Compilation;
                info.ReleaseDate = ReleaseDate;
                info.Genres.AddRange(Genres);
                info.Languages.AddRange(Languages);
                info.Artists.AddRange(AlbumArtists);
                info.LastChanged       = LastChanged;
                info.DateAdded         = DateAdded;
                info.ForceOnlineSearch = ForceOnlineSearch;
                return((T)(object)info);
            }
            return(default(T));
        }
Exemple #2
0
        public override bool CopyIdsFrom <T>(T otherInstance)
        {
            if (otherInstance == null)
            {
                return(false);
            }

            if (otherInstance is TrackInfo)
            {
                TrackInfo otherTrack = otherInstance as TrackInfo;
                AlbumAudioDbId          = otherTrack.AlbumAudioDbId;
                AlbumCdDdId             = otherTrack.AlbumCdDdId;
                AlbumMusicBrainzDiscId  = otherTrack.AlbumMusicBrainzDiscId;
                AlbumMusicBrainzGroupId = otherTrack.AlbumMusicBrainzGroupId;
                AlbumMusicBrainzId      = otherTrack.AlbumMusicBrainzId;
                AlbumAmazonId           = otherTrack.AlbumAmazonId;
                AlbumItunesId           = otherTrack.AlbumItunesId;
                AlbumNameId             = otherTrack.AlbumNameId;
                AudioDbId     = otherTrack.AudioDbId;
                MusicBrainzId = otherTrack.MusicBrainzId;
                MusicIpId     = otherTrack.MusicIpId;
                MvDbId        = otherTrack.MvDbId;
                LyricId       = otherTrack.LyricId;
                NameId        = otherTrack.NameId;
                foreach (var keyVal in otherTrack.CustomIds)
                {
                    CustomIds[keyVal.Key] = keyVal.Value;
                }
                foreach (var keyVal in otherTrack.CustomAlbumIds)
                {
                    CustomAlbumIds[keyVal.Key] = keyVal.Value;
                }
                return(true);
            }
            else if (otherInstance is AlbumInfo)
            {
                AlbumInfo otherAlbum = otherInstance as AlbumInfo;
                AlbumAudioDbId          = otherAlbum.AudioDbId;
                AlbumCdDdId             = otherAlbum.CdDdId;
                AlbumMusicBrainzDiscId  = otherAlbum.MusicBrainzDiscId;
                AlbumMusicBrainzGroupId = otherAlbum.MusicBrainzGroupId;
                AlbumMusicBrainzId      = otherAlbum.MusicBrainzId;
                AlbumAmazonId           = otherAlbum.AmazonId;
                AlbumItunesId           = otherAlbum.ItunesId;
                AlbumNameId             = otherAlbum.NameId;
                foreach (var keyVal in otherAlbum.CustomIds)
                {
                    CustomAlbumIds[keyVal.Key] = keyVal.Value;
                }
                return(true);
            }
            return(false);
        }
Exemple #3
0
 public override T CloneBasicInstance <T>()
 {
     if (typeof(T) == typeof(AlbumInfo))
     {
         AlbumInfo info = new AlbumInfo();
         info.CopyIdsFrom(this);
         info.Album       = Album;
         info.AlbumSort   = AlbumSort;
         info.ReleaseDate = ReleaseDate;
         return((T)(object)info);
     }
     return(default(T));
 }
Exemple #4
0
 /// <summary>
 /// If album volume info is present, determines whether both albums represent the same volume.
 /// </summary>
 /// <param name="other">The album to match against.</param>
 /// <returns><c>true</c> if the volumes match or no volume info is present.</returns>
 public bool AlbumVolumesAreEqual(AlbumInfo other)
 {
     if (!string.IsNullOrEmpty(Album) && !string.IsNullOrEmpty(other.Album))
     {
         Match match = _albumNumber.Match(Album);
         if (match.Success)
         {
             string searchNumber = match.Groups["number"].Value;
             match = _albumNumber.Match(other.Album);
             if (match.Success && searchNumber != match.Groups["number"].Value)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemple #5
0
        public AlbumInfo Clone()
        {
            AlbumInfo clone = (AlbumInfo)this.MemberwiseClone();

            clone.Description = new SimpleTitle(Description.Text, Description.DefaultLanguage);
            clone.Rating      = new SimpleRating(Rating.RatingValue, Rating.VoteCount);
            clone.Languages   = new List <string>();
            foreach (var l in Languages)
            {
                clone.Languages.Add(l);
            }
            clone.Awards = new List <string>();
            foreach (var a in Awards)
            {
                clone.Awards.Add(a);
            }
            clone.Artists = new List <PersonInfo>();
            foreach (var a in Artists)
            {
                clone.Artists.Add(a.Clone());
            }
            clone.Tracks = new List <TrackInfo>();
            foreach (var d in Tracks)
            {
                clone.Tracks.Add(d.Clone());
            }
            clone.MusicLabels = new List <CompanyInfo>();
            foreach (var l in MusicLabels)
            {
                clone.MusicLabels.Add(l.Clone());
            }
            clone.Genres = new List <GenreInfo>();
            foreach (var g in Genres)
            {
                clone.Genres.Add(new GenreInfo()
                {
                    Id = g.Id, Name = g.Name
                });
            }

            return(clone);
        }
Exemple #6
0
        public override bool Equals(object obj)
        {
            AlbumInfo other = obj as AlbumInfo;

            if (other == null)
            {
                return(false);
            }

            //For albums, the name is likely to have come from a tag so ensure that names are similar in addition
            //to the checks below, so that if a user has 2 albums in different qualities, deliberately tagged differently
            //they don't get merged into the same album.
            if (!string.IsNullOrEmpty(Album) && !string.IsNullOrEmpty(other.Album) && !MatchNames(Album, other.Album))
            {
                return(false);
            }

            if (AudioDbId > 0 && other.AudioDbId > 0)
            {
                return(AudioDbId == other.AudioDbId);
            }

            if (!string.IsNullOrEmpty(CdDdId) && !string.IsNullOrEmpty(other.CdDdId))
            {
                return(string.Equals(CdDdId, other.CdDdId, StringComparison.InvariantCultureIgnoreCase));
            }
            if (!string.IsNullOrEmpty(UpcEanId) && !string.IsNullOrEmpty(other.UpcEanId))
            {
                return(string.Equals(UpcEanId, other.UpcEanId, StringComparison.InvariantCultureIgnoreCase));
            }
            if (!string.IsNullOrEmpty(AmazonId) && !string.IsNullOrEmpty(other.AmazonId))
            {
                return(string.Equals(AmazonId, other.AmazonId, StringComparison.InvariantCultureIgnoreCase));
            }
            if (!string.IsNullOrEmpty(ItunesId) && !string.IsNullOrEmpty(other.ItunesId))
            {
                return(string.Equals(ItunesId, other.ItunesId, StringComparison.InvariantCultureIgnoreCase));
            }
            foreach (var key in CustomIds.Keys)
            {
                if (other.CustomIds.ContainsKey(key))
                {
                    return(string.Equals(CustomIds[key], other.CustomIds[key], StringComparison.InvariantCultureIgnoreCase));
                }
            }

            //Name id is generated from name and can be unreliable so should only be used if matches
            if (!string.IsNullOrEmpty(NameId) && !string.IsNullOrEmpty(other.NameId) &&
                string.Equals(NameId, other.NameId, StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }

            if (!string.IsNullOrEmpty(MusicBrainzId) && !string.IsNullOrEmpty(other.MusicBrainzId))
            {
                return(string.Equals(MusicBrainzId, other.MusicBrainzId, StringComparison.InvariantCultureIgnoreCase));
            }
            if (!string.IsNullOrEmpty(MusicBrainzGroupId) && !string.IsNullOrEmpty(other.MusicBrainzGroupId))
            {
                return(string.Equals(MusicBrainzGroupId, other.MusicBrainzGroupId, StringComparison.InvariantCultureIgnoreCase));
            }

            if (ReleaseDate.HasValue && other.ReleaseDate.HasValue &&
                (Artists == null || Artists.Count == 0 || other.Artists == null || other.Artists.Count == 0 || Artists[0].Equals(other.Artists[0])))
            {
                return(ReleaseDate.Value.Year == other.ReleaseDate.Value.Year);
            }

            return(AlbumVolumesAreEqual(other));
        }