Esempio n. 1
0
 public static TagOption SetSelected(this TagOption tag, bool check)
 {
     if (check)
     {
         tag.Selected("selected");
     }
     return(tag);
 }
        public override SongTagFile PopulateSongTag(string fileName, TagOption options = TagOption.All)
        {
            //Can we scan discogs
            var discogOption = options.HasFlag(TagOption.Discog);

            //var tagged = Tagger.GetMp3Tag(fileName);
            return(CreateSongModelWithTagLib(fileName));
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the tag information from a file"/>
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public SongTagFile GetTagInformation(string fileName, TagOption options = TagOption.All)
        {
            if (Path.GetExtension(fileName).ToUpper() == ".FLAC")
            {
                return(_songTaggerTagLib.PopulateSongTag(fileName, options));
            }

            return(_songTagger.PopulateSongTag(fileName, options));
        }
Esempio n. 4
0
 /// <summary>
 /// Constructor for ClanTag
 /// </summary>
 public ClanTag(string tag, IEnumerable <Source> sources, TagOption tagOption = TagOption.Unknown)
     : base(tag, sources)
 {
     LayoutOption = tagOption;
     if (tagOption == TagOption.Surrounding && tag.Length == 2 && tag[0] == tag[1])
     {
         Value = tag[0].ToString();
     }
 }
Esempio n. 5
0
        public override SongTagFile PopulateSongTag(string fileName, TagOption tagOption = TagOption.All)
        {
            using (var fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                using (Mp3Stream mp3Stream = new Mp3Stream(fileStream, Mp3Permissions.ReadWrite))
                {
                    var id3Tag = GetTagFromStream(mp3Stream);

                    if (id3Tag != null)
                    {
                        var song = new SongTagFile();
                        song.Duration = mp3Stream.Audio.Duration.ToString();
                        song.BitRate  = mp3Stream.Audio.Bitrate;
                        return(CreateSongTag(song, id3Tag, tagOption));
                    }
                }

            return(null);
        }
Esempio n. 6
0
        /// <summary>
        /// Parses Id3 to create a song model
        /// </summary>
        /// <param name="songFile">song file path</param>
        /// <returns>new song</returns>
        private SongTagFile CreateSongTag(SongTagFile song, Id3Tag tag, TagOption options = TagOption.All)
        {
            //If that tag returned null return
            if (tag == null)
            {
                return(song);
            }

            GetTrackNumber(song, tag);
            GetArtist(song, tag);
            GetTitle(song, tag);
            GetAlbum(song, tag);
            GetYear(song, tag);
            GetRating(song, tag);
            GetBpm(song, tag);
            GetGenre(song, tag);
            GetComments(song, tag);
            GetMusicalKey(song, tag);

            //ARTWORK
            if (options.HasFlag(TagOption.All) || options.HasFlag(TagOption.Artwork))
            {
                GetPictureBytes(song, tag);
            }
            //Country
            if (options.HasFlag(TagOption.All) || options.HasFlag(TagOption.Country))
            {
                song.Country = GetCountry(tag);
            }
            //DISCOGS
            if (options.HasFlag(TagOption.All) || options.HasFlag(TagOption.Discog))
            {
                GetDiscogsId(song, tag);
            }
            //LABEL
            if (options.HasFlag(TagOption.All) || options.HasFlag(TagOption.Label))
            {
                GetLabelPublisher(song, tag);
            }

            return(song);
        }
Esempio n. 7
0
        private async Task <IEnumerable <DocumentGroup> > GetDocumentsToCreate(TagOption option, IEnumerable <TagElement> tags)
        {
            switch (option)
            {
            case TagOption.ReplaceTags:
                return(this.ReplaceTags(tags));

            case TagOption.LoadReplacedTags:
                IEnumerable <DocumentGroup>?loadedTags = await TaskExecutable.RunTask(this.LoadReplacedTags);

                if (loadedTags == null)
                {
                    return(Enumerable.Empty <DocumentGroup>());
                }

                return(loadedTags);
            }

            return(Enumerable.Empty <DocumentGroup>());
        }
Esempio n. 8
0
 public static TagOption onkeypress(this TagOption tag, string value)
 {
     tag.OnKeyPress = value; return(tag);
 }
Esempio n. 9
0
 public static TagOption onmouseout(this TagOption tag, string value)
 {
     tag.OnMouseOut = value; return(tag);
 }
Esempio n. 10
0
 public static TagOption ondblclick(this TagOption tag, string value)
 {
     tag.OnDblClick = value; return(tag);
 }
Esempio n. 11
0
 public static TagOption onmousedown(this TagOption tag, string value)
 {
     tag.OnMouseDown = value; return(tag);
 }
Esempio n. 12
0
 public static TagOption onmouseup(this TagOption tag, string value)
 {
     tag.OnMouseUp = value; return(tag);
 }
Esempio n. 13
0
 public static TagOption selected(this TagOption tag, Selected value)
 {
     tag.Selected = value; return(tag);
 }
Esempio n. 14
0
 public virtual SongTagFile PopulateSongTag(string fileName, TagOption options = TagOption.All)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
        public async Task <Dictionary <string, string> > UpdateAllTags(IEnumerable <Horsesoft.Music.Data.Model.File> files, TagOption tagOption = TagOption.All)
        {
            _cts = new CancellationTokenSource();

            //Make sure Directories exist for artwork
            CreateArtworkDirectories();

            return(await Task.Run(() =>
            {
                int i = 0;
                var failedFiles = new Dictionary <string, string>();

                foreach (var file in files)
                {
                    try
                    {
                        if (_cts.IsCancellationRequested)
                        {
                            throw new OperationCanceledException();
                        }

                        try
                        {
                            //Get tag and save to Db, Add to failed here.
                            var taggedSong = GetTagInformation(file, tagOption);

                            //Create an image
                            SaveImageFromTag(taggedSong);

                            if (taggedSong != null)
                            {
                                //Save image
                                _horsifyDataRepo.UpdateDbSongTag(taggedSong, (int)file.Id);

                                OnTagUpdated?.Invoke($"Tag update: {taggedSong.Title}");

                                if (i > 250)
                                {
                                    i = -1;
                                    ((IUnitOfWork)_horsifyDataRepo).Save();
                                }
                                else
                                {
                                    i++;
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            failedFiles.Add(file.ToString(), ex.Message);
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        break;
                    }
                }

                ((IUnitOfWork)_horsifyDataRepo).Save();

                return failedFiles;
            }, _cts.Token));
        }
Esempio n. 16
0
 public static TagOption id(this TagOption tag, string value)
 {
     tag.Id = value; return(tag);
 }
Esempio n. 17
0
 public static TagOption @class(this TagOption tag, string value)
 {
     tag.Class = value; return(tag);
 }
Esempio n. 18
0
 public static TagOption value(this TagOption tag, string value)
 {
     tag.Value = value; return(tag);
 }
Esempio n. 19
0
 public static TagOption label(this TagOption tag, string value)
 {
     tag.Label = value; return(tag);
 }
Esempio n. 20
0
 public static TagOption disabled(this TagOption tag, Disabled value)
 {
     tag.Disabled = value; return(tag);
 }
Esempio n. 21
0
        public SongTagFile GetTagInformation(Data.Model.File file, TagOption options = TagOption.All)
        {
            var songTag = GetTagInformation(file.ToString(), options);

            return(songTag);
        }
Esempio n. 22
0
 public static TagOption onkeydown(this TagOption tag, string value)
 {
     tag.OnKeyDown = value; return(tag);
 }
Esempio n. 23
0
 public static TagOption onmousemove(this TagOption tag, string value)
 {
     tag.OnMouseMove = value; return(tag);
 }
Esempio n. 24
0
 public static TagOption xmllang(this TagOption tag, string value)
 {
     tag.XmlLang = value; return(tag);
 }
Esempio n. 25
0
 public static bool Matches(TagOption start, TagOption end)
 {
     return(start.Position == TagOptionPosition.start &&
            end.Position == TagOptionPosition.end &&
            start.MainOption == end.MainOption);
 }
Esempio n. 26
0
 public static TagOption dir(this TagOption tag, Dir value)
 {
     tag.Dir = value; return(tag);
 }
Esempio n. 27
0
 public static TagOption title(this TagOption tag, string value)
 {
     tag.Title = value; return(tag);
 }
Esempio n. 28
0
 public static TagOption onkeyup(this TagOption tag, string value)
 {
     tag.OnKeyUp = value; return(tag);
 }
Esempio n. 29
0
 public static TagOption lang(this TagOption tag, LangCode value)
 {
     tag.Lang = value; return(tag);
 }
Esempio n. 30
0
 /// <summary>
 /// Construct a ClanTag based on the tag and the source
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="source"></param>
 public ClanTag(string tag, Source source, TagOption tagOption = TagOption.Unknown)
     : this(tag, source.AsEnumerable(), tagOption)
 {
 }