public string GetDiscName() { foreach (XmlTrack track in Tracks) { if (!string.IsNullOrEmpty(track.Album)) { return(string.Format("{0} Disc {1}", track.Album, DiscNumber.ToString("000"))); } } return(string.Format("{0} Disc {1}", ConstantStrings.UnknownDisc, DiscNumber.ToString("000"))); }
/// <summary> /// Returns a string field /// </summary> /// <param name="name">Name of field</param> /// <returns></returns> public string this[string name] { get { switch (name.ToLower()) { case "title": return(Title); case "artist": return(Artist); case "album": return(Album); case "genre": return(Genre); case "rating": return(RatingString); case "length": return(LengthString); case "play count": return(PlayCount.ToString()); case "date added": return(DateAdded.ToShortTimeString()); case "last played": return(LastPlayed.ToShortDateString()); case "track number": return(TrackNumber.ToString()); case "disc number": return(DiscNumber.ToString()); default: return(null); } } }
private TagData toTagData() { TagData result = new TagData(); result.Title = Title; result.Artist = Artist; result.Composer = Composer; result.Comment = Comment; result.Genre = Genre; result.OriginalArtist = OriginalArtist; result.OriginalAlbum = OriginalAlbum; result.GeneralDescription = Description; result.Rating = (Popularity * 5).ToString(); result.Copyright = Copyright; result.Publisher = Publisher; if (!PublishingDate.Equals(DateTime.MinValue)) { result.PublishingDate = TrackUtils.FormatISOTimestamp(PublishingDate); } result.AlbumArtist = AlbumArtist; result.Conductor = Conductor; if (!Date.Equals(DateTime.MinValue)) { result.RecordingDate = TrackUtils.FormatISOTimestamp(Date); } result.RecordingYear = Year.ToString(); result.Album = Album; result.TrackNumber = TrackNumber.ToString(); result.TrackTotal = TrackTotal.ToString(); result.DiscNumber = DiscNumber.ToString(); result.DiscTotal = DiscTotal.ToString(); result.ChaptersTableDescription = ChaptersTableDescription.ToString(); result.Chapters = new List <ChapterInfo>(); foreach (ChapterInfo chapter in Chapters) { result.Chapters.Add(new ChapterInfo(chapter)); } if (Lyrics != null) { result.Lyrics = new LyricsInfo(Lyrics); } foreach (string s in AdditionalFields.Keys) { result.AdditionalFields.Add(new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, s, AdditionalFields[s])); } // Detect and tag deleted Additional fields (=those which were in initialAdditionalFields and do not appear in AdditionalFields anymore) foreach (string s in initialAdditionalFields) { if (!AdditionalFields.ContainsKey(s)) { MetaFieldInfo metaFieldToDelete = new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, s, ""); metaFieldToDelete.MarkedForDeletion = true; result.AdditionalFields.Add(metaFieldToDelete); } } result.Pictures = new List <PictureInfo>(); if (currentEmbeddedPictures != null) { foreach (PictureInfo targetPic in currentEmbeddedPictures) { targetPic.TransientFlag = 0; } } if (initialEmbeddedPictures != null && currentEmbeddedPictures != null) { foreach (PictureInfo picInfo in initialEmbeddedPictures) { // Detect and tag deleted pictures (=those which were in initialEmbeddedPictures and do not appear in embeddedPictures anymore) if (!currentEmbeddedPictures.Contains(picInfo)) { PictureInfo picToDelete = new PictureInfo(picInfo); picToDelete.MarkedForDeletion = true; result.Pictures.Add(picToDelete); } else // Only add new additions (pictures identical to initial list will be kept, and do not have to make it to the list, or else a duplicate will be created) { foreach (PictureInfo targetPic in currentEmbeddedPictures) { if (targetPic.Equals(picInfo)) { // Compare picture contents targetPic.ComputePicHash(); if (targetPic.PictureHash != picInfo.PictureHash) { // A new picture content has been defined for an existing location result.Pictures.Add(targetPic); PictureInfo picToDelete = new PictureInfo(picInfo); picToDelete.MarkedForDeletion = true; result.Pictures.Add(picToDelete); } targetPic.TransientFlag = 1; } } } } if (currentEmbeddedPictures != null) { foreach (PictureInfo targetPic in currentEmbeddedPictures) { if (0 == targetPic.TransientFlag) // Entirely new pictures without equivalent in initialEmbeddedPictures { result.Pictures.Add(targetPic); } } } } return(result); }