Exemplo n.º 1
0
        public bool TryRead(string filename, out Tag tag)
        {
            if (filename == null) throw new ArgumentNullException("filename");

            try
            {
                var file = new File(filename);

                LogWarnings(filename, file);

                var t = new Tag();
                PopulateFromTag(file, t);
                PopulateFallbackValues(t);

                if (file.Properties != null)
                    t.Duration = file.Properties.Duration;

                tag = t;
                return true;
            }
            catch (Exception e)
            {
                Log.Error(String.Format("Error reading M4A tag from {0}.", filename), e);
                tag = null;
                return false;
            }
        }
Exemplo n.º 2
0
         public void Clean(Tag tag)
         {
             if (tag == null) throw new ArgumentNullException("tag");

             tag.Artist = Cleanup(tag.Artist);
             tag.Title = Cleanup(tag.Title);
         }
Exemplo n.º 3
0
        public Tag Read(string filename)
        {
            if (filename == null) throw new ArgumentNullException("filename");

            var t = new Tag();

            t.Title = Path.GetFileNameWithoutExtension(filename);
            t.Artist = TrackDefaults.UnknownArtist;
            t.Duration = GetDuration(filename);

            return t;
        }
Exemplo n.º 4
0
        void PopulateFromTag(File file, Tag tag)
        {
            //if (!file.TagTypes.HasFlag(TagTypes.Id3v2))
            //    return;

            tag.ImageData = GetImageData(file);

            // ID3v2 Tags Reference: http://id3.org/id3v2.4.0-frames
            tag.Artist = JoinPerformers(file.Tag.Performers);
            tag.Title = file.Tag.Title;
            tag.Year = ToStringOrDefault(file.Tag.Year);
            tag.Genre = file.Tag.JoinedGenres;
            tag.Publisher = file.Tag.Grouping;
            tag.Bpm = ToStringOrDefault(file.Tag.BeatsPerMinute);
        }
Exemplo n.º 5
0
 void PopulateFallbackValues(Tag tag)
 {
     tag.Artist = tag.Artist ?? TrackDefaults.UnknownArtist;
     tag.Title = tag.Title ?? TrackDefaults.UnknownTitle;
 }
Exemplo n.º 6
0
        Track CreateTrackFromTag(string filename, Tag tag)
        {
            foreach (var cleanup in cleanupFactory.GetCleanups())
                cleanup.Clean(tag);

            string filenameKey;
            string filenameBpm;
            filenameParser.TryParse(filename, out filenameKey, out filenameBpm);

            var strKey = StringUtils.Coalesce(tag.InitialKey, filenameKey);
            var strBpm = StringUtils.Coalesce(tag.Bpm, filenameBpm);

            HarmonicKey key = keyParser.ParseHarmonicKey(strKey);

            double bpm;
            if (!Double.TryParse(strBpm, out bpm))
                bpm = double.NaN;

            TrackImageData images = 
                tag.ImageData != null ? imageResizer.Process(tag.ImageData) : null;

            var track = new Track(tag.Artist, tag.Title, key, filename, bpm, tag.Duration)
                            {
                                Label = tag.Publisher ?? "",
                                Genre = tag.Genre ?? "",
                                Year = tag.Year ?? "",
                                Images = images
                            };

            return track;
        }