private void AutoAddTags() { if (Status != ItemStatus.Complete) { return; } if (!CompleteDestination.EndsWith(".mp3", StringComparison.CurrentCultureIgnoreCase)) { return; } if (!(Feed.ApplyAlbumTag || Feed.ApplyArtistTag || Feed.ApplyGenreTag || Feed.ApplyTrackTitleTag)) { return; } if (Feed.ApplyArtistTag && Feed.ArtistTag != "") { _artistTag = ExpandTagString(Feed.ArtistTag); } if (Feed.ApplyAlbumTag && Feed.AlbumTag != "") { _albumTag = ExpandTagString(Feed.AlbumTag); } if (Feed.ApplyGenreTag && Feed.GenreTag != "") { _genreTag = ExpandTagString(Feed.GenreTag); } if (Feed.ApplyTrackTitleTag && Feed.TrackTitleTag != "") { _trackTitleTag = ExpandTagString(Feed.TrackTitleTag); } _tagsSet = true; Thread thread = new Thread(new ThreadStart(WriteTagsToFile)); thread.Start(); //WriteTagsToFile(Feed.OverwriteExistingTags); }
private void ReadTagsFromFile() { if (Status != ItemStatus.Complete) { return; } if (!CompleteDestination.EndsWith(".mp3", StringComparison.CurrentCultureIgnoreCase)) { return; } try { ID3Tag tag = ID3v2Tag.ReadTag(CompleteDestination); if (tag == null) { tag = ID3v1Tag.ReadTag(CompleteDestination); if (tag == null) { tag = new ID3v2Tag(); } } TrackTitleTag = tag.Title; AlbumTag = tag.Album; ArtistTag = tag.Artist; GenreTag = tag.Genre; _tagsSet = true; } catch (Exception ex) { Trace.TraceError("Error: unable to read ID3 Tag for file: " + CompleteDestination + ". " + ex.Message); } }
public bool WriteTagsToFile(bool overwriteExistingTags) { if (Status != ItemStatus.Complete) { return(false); } if (!CompleteDestination.EndsWith(".mp3", StringComparison.CurrentCultureIgnoreCase)) { return(false); } try { ID3Tag tag = null; switch (ID3v2Tag.LookForTag(CompleteDestination)) { case ID3Versions.None: case ID3Versions.Unknown: default: tag = new ID3v2Tag(); SetTagContent(tag, overwriteExistingTags); tag.WriteTag(CompleteDestination, ID3Versions.V2_4); break; case ID3Versions.V1: case ID3Versions.V1_0: case ID3Versions.V1_1: tag = ID3v1Tag.ReadTag(CompleteDestination); SetTagContent(tag, overwriteExistingTags); tag.WriteTag(CompleteDestination, ID3Versions.V1_1); break; case ID3Versions.V2: case ID3Versions.V2_2: case ID3Versions.V2_3: tag = ID3v2Tag.ReadTag(CompleteDestination); SetTagContent(tag, overwriteExistingTags); tag.WriteTag(CompleteDestination, ID3Versions.V2_3); break; case ID3Versions.V2_4: tag = ID3v2Tag.ReadTag(CompleteDestination); SetTagContent(tag, overwriteExistingTags); tag.WriteTag(CompleteDestination, ID3Versions.V2_4); break; } } catch (Exception ex) { Trace.TraceError("Error writing tags to: " + CompleteDestination + ". " + ex.Message); return(false); } return(true); }