예제 #1
0
        /// <summary>
        /// Return available tags for specified file
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private async Task <IGmtMedia> GetTagsAsync(TrackFile file)
        {
            //Object to store all retrieved tags
            var gmtContainer = new TrackFile();

            //Start looking for tags based on specified order in settings
            foreach (var tagType in GetSearchOrder())
            {
                //Get the tag type that has priority
                var searchCacheType = tagType == SearchResultType.Album ? CacheType.Album : CacheType.Artist;

                //Search tags from cache or if result is null return it from web
                IGmtMedia tags = GetCache(file, searchCacheType) ?? (await GetTagsFromWebAsync(file, tagType));

                //If no tracks are found go to next search type
                if (tags == null)
                {
                    continue;
                }

                //Log progress
                await LogMessageTagSearchResult(tagType.ToString(), tags.Count());

                //Add retrieved tags to container
                gmtContainer.AddGmtMedia(tags);

                //If we got what we want, stop
                if (tags?.Count() > 0 && Options.TagPriority != 2)
                {
                    break;
                }
            }

            return(gmtContainer);
        }
예제 #2
0
        private async Task LoadTagsForGroup(IEnumerable <TrackFile> files)
        {
            foreach (var file in files)
            {
                if (_cancelProgress)
                {
                    break;
                }

                IGmtMedia tags = await GetTagsAsync(file);

                ReportProgress(file);

                if (tags?.Count() > 0)
                {
                    await LogMessageTagSearchCompleted(tags.Count(), file.Title, file.Artist);

                    _filesToUpdate.Add(file.SetGmtMedia(tags, Options));
                }
            }
        }