示例#1
0
        public async Task <List <AudioDbMvid> > GetMusicVideosByArtistMbidAsync(string mbid, string language, bool cacheOnly)
        {
            AudioDbMvids audioDbMvids = null;
            string       cache        = CreateAndGetCacheName(mbid, "ArtistVideos_mbId");

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                audioDbMvids = await _downloader.ReadCacheAsync <AudioDbMvids>(cache).ConfigureAwait(false);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_MVID_BY_ARTIST_MBID, mbid);
                audioDbMvids = await _downloader.DownloadAsync <AudioDbMvids>(url, cache).ConfigureAwait(false);
            }
            if (audioDbMvids.MVids != null && audioDbMvids.MVids.Count > 0)
            {
                List <AudioDbMvid> list = audioDbMvids.MVids.Where(v => !string.IsNullOrEmpty(v.MusicVid)).ToList();
                foreach (AudioDbMvid vid in list)
                {
                    vid.SetLanguage(language);
                }
                if (list.Count > 0)
                {
                    return(list);
                }
            }
            return(null);
        }
示例#2
0
        public List <AudioDbMvid> GetMusicVideosByArtistId(string tadbArtistId, string language, bool cacheOnly)
        {
            AudioDbMvids audioDbMvids = null;
            string       cache        = CreateAndGetCacheName(tadbArtistId, "ArtistVideos");

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                audioDbMvids = _downloader.ReadCache <AudioDbMvids>(cache);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_MVID_BY_ARTIST_TADB, tadbArtistId);
                audioDbMvids = _downloader.Download <AudioDbMvids>(url, cache);
            }
            if (audioDbMvids.MVids != null && audioDbMvids.MVids.Count > 0)
            {
                List <AudioDbMvid> list = audioDbMvids.MVids.Where(v => !string.IsNullOrEmpty(v.MusicVid)).ToList();
                foreach (AudioDbMvid vid in list)
                {
                    vid.SetLanguage(language);
                }
                if (list.Count > 0)
                {
                    return(list);
                }
            }
            return(null);
        }