Beispiel #1
0
 /// <summary>
 /// Adds Get() method to <see cref="TagLib.Tag"/> which
 /// is read only by default.
 /// </summary>
 /// <param name="tag">Target tag</param>
 /// <returns>Casted tag</returns>
 /// <remarks>
 /// The tag is casted to <see cref="mp3tag.Metadata"/> prior to return.
 /// Used to initialize tag once <see cref="TagLib.File"/> is created
 /// in <see cref="mp3Tag.Music"/>.
 /// If not initialized, any updates to the tag fail with
 /// NullExceptions.
 /// </remarks>
 static public Metadata Get(this TagLib.Tag tag)
 {
   Metadata Id3 = new Id3();
   Id3.Artist = tag.FirstPerformer;
   Id3.Release = tag.Album;
   Id3.Title = tag.Title;
   Id3.ReleaseYear = tag.Year.ToString();
   Id3.Genre = tag.FirstGenre;
   Id3.Track = tag.Track.ToString();
   Id3.MusicBrainzReleaseType = tag.MusicBrainzReleaseType;
   Id3.MusicBrainzReleaseArtistId = tag.MusicBrainzArtistId;
   Id3.MusicBrainzArtistId = tag.MusicBrainzArtistId;
   Id3.MusicBrainzReleaseId = tag.MusicBrainzReleaseId;
   Id3.MusicBrainzTrackId = tag.MusicBrainzTrackId;
   Id3.MusicBrainzDiscId = tag.MusicBrainzDiscId; 
   return Id3;
 }
    /// <summary>
    /// Converts musicbrainz metadata collection to 
    /// <see cref="mp3tag.MetadataCollection"/>.
    /// </summary>
    /// <param name="album">Musicbrainz album object</param>
    /// <returns>Corresponding tag collection</returns>
    /// <remarks>
    /// Musicbrainz supports release types. This information
    /// in the case of non-album releases the data is appended
    /// to the album name. Date defaults to today if nothing 
    /// is set.
    /// 
    /// In the case of various artist, the artist is set to
    /// album artist first to locate album art & genre. 
    /// Then artist is based on a per-track basis.
    /// </remarks>
    static public Metadata ToTag(this MusicBrainz.Release album)
    {
      Metadata Collection = new MetadataCollection();
      Metadata Metadata = new Id3();

      // If date is not set, use current date
      string ReleaseDate = String.Empty;
      try {
        ReleaseDate = album.GetEvents().First().Date.ToString();
      } 
      catch(Exception)
      {
        ReleaseDate = DateTime.Now.Year.ToString();
      }
      
      // Build tag with search data
      Art Art = new Art();
      Metadata.MusicBrainzReleaseArtistId = album.GetArtist().Id;
      Metadata.MusicBrainzReleaseId = album.Id;
      Metadata.MusicBrainzReleaseType = album.GetReleaseType().ToString();
      Metadata.AlbumArtist = album.GetArtist();
      Metadata.Release = album.GetTitle();
      Metadata.AmazonId = album.GetAsin();
      Metadata.ReleaseYear = ReleaseDate.Substring(0, 4);
      Metadata.Art = Art.Search(Metadata);

      // Search for genre; populate with default for now
      Metadata.Genre = "Hardcore";
      //Metadata.Genre = ITunesService.SearchArtistGenre(Metadata);

      // Set track titles
      foreach (Track Trk in album.GetTracks())
      {
        Metadata.Title = Trk.GetTitle();
        Metadata.Artist = Trk.GetArtist();
        Metadata.MusicBrainzArtistId = Trk.GetArtist().Id;
        Metadata.Track = (Collection.ToList<Metadata>().Count() + 1).ToString();
        Collection.Add(new Id3(Metadata));
      }

      return Collection;
    }
Beispiel #3
0
    /// <summary>
    /// Explicitly casts <see cref="Lastfm.Services.Album"/>
    /// to <see cref="mp3tag.Metadata"/>
    /// </summary>
    /// <param name="album">Album tag to be casted</param>
    /// <returns>mp3tag.Tag object</returns>
    static public Metadata ToTag(this Lastfm.Services.Album album)
    {
      // Set album specific data
      Metadata Collection = new MetadataCollection();
      Metadata Metadata = new Id3();
      Metadata.Artist = album.Artist.Name;
      Metadata.Release = album.Name;
      Metadata.ReleaseYear = album.GetReleaseDate().Year.ToString();
      Metadata.Art = album.GetImageURL(AlbumImageSize.ExtraLarge);
      
      // Invoke copy constructor on tag object
      // otherwirse all tags in the collection will have changes
      // applied.
      foreach (Track t in album.GetTracks())
      {
        Metadata.Title = t.Title;
        Metadata.Track = (Collection.ToList<Metadata>().Count() + 1).ToString();
        Collection.Add(new Id3(Metadata));
      }

      // Return tag collection for album
      return Collection;
    }
Beispiel #4
0
 /// <summary>
 /// Constructor for art object
 /// </summary>
 /// <param name="path">Location of the file</param>
 /// <param name="depth">Depth in file heirarchy</param>
 public Art(string url)
 {
   Path = Parent.Path + "\\image" + url.Substring(url.Length - 4, 4).ToLower();
   Depth = Parent.Depth + 1;
   Metadata = new Id3();
 }
Beispiel #5
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public Art()
 {
   Metadata = new Id3();
 }
Beispiel #6
0
 /// <summary>
 /// Not implemented for leaf case in composite pattern.
 /// </summary>
 public void Add(Id3 tag)
 {
   throw new NotImplementedException();
 }
Beispiel #7
0
 /// <summary>
 /// Not implemented for leaf case in composite pattern.
 /// </summary>
 public void Remove(Id3 tag)
 {
   throw new NotImplementedException();
 }
Beispiel #8
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public Md5()
 {
   Buffer = new StringBuilder();
   Metadata = new Id3();
   Extension = ".md5";
 }