Exemplo n.º 1
0
        public async Task <AudioDbTrack> GetTrackByMbidAsync(string mbid, string language, bool cacheOnly)
        {
            AudioDbTracks audioDbTracks = null;
            string        cache         = CreateAndGetCacheName(mbid, "Track_mbId");

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                audioDbTracks = await _downloader.ReadCacheAsync <AudioDbTracks>(cache).ConfigureAwait(false);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_TRACK_BY_MBDB, mbid);
                audioDbTracks = await _downloader.DownloadAsync <AudioDbTracks>(url, cache).ConfigureAwait(false);
            }
            if (audioDbTracks.Tracks != null && audioDbTracks.Tracks.Count > 0)
            {
                AudioDbTrack track = audioDbTracks.Tracks.Where(t => t.TrackID > 0).FirstOrDefault();
                if (track != null)
                {
                    track.SetLanguage(language);
                }
                return(track);
            }
            return(null);
        }
Exemplo n.º 2
0
        public AudioDbTrack GetTrack(long tadbTrackId, string language, bool cacheOnly)
        {
            AudioDbTracks audioDbTracks = null;
            string        cache         = CreateAndGetCacheName(tadbTrackId, "Track");

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                audioDbTracks = _downloader.ReadCache <AudioDbTracks>(cache);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_TRACK_BY_TADB, tadbTrackId);
                audioDbTracks = _downloader.Download <AudioDbTracks>(url, cache);
            }
            if (audioDbTracks.Tracks != null && audioDbTracks.Tracks.Count > 0)
            {
                AudioDbTrack track = audioDbTracks.Tracks.Where(t => t.TrackID > 0).FirstOrDefault();
                if (track != null)
                {
                    track.SetLanguage(language);
                }
                return(track);
            }
            return(null);
        }
Exemplo n.º 3
0
        public async Task <List <AudioDbTrack> > GetTracksByAlbumIdAsync(long tadbAlbumId, string language, bool cacheOnly)
        {
            AudioDbTracks audioDbTracks = null;
            string        cache         = CreateAndGetCacheName(tadbAlbumId, "AlbumTracks");

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                audioDbTracks = await _downloader.ReadCacheAsync <AudioDbTracks>(cache).ConfigureAwait(false);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_TRACK_BY_ALBUM_TADB, tadbAlbumId);
                audioDbTracks = await _downloader.DownloadAsync <AudioDbTracks>(url, cache).ConfigureAwait(false);
            }
            if (audioDbTracks.Tracks != null && audioDbTracks.Tracks.Count > 0)
            {
                List <AudioDbTrack> list = audioDbTracks.Tracks.Where(t => t.TrackID > 0).ToList();
                foreach (AudioDbTrack track in list)
                {
                    track.SetLanguage(language);
                }
                if (list.Count > 0)
                {
                    return(list);
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        public async Task <List <AudioDbTrack> > SearchTrackAsync(string artistName, string trackName, string language)
        {
            string        url           = GetUrl(URL_TRACK_BY_ARTIST_AND_NAME, Uri.EscapeDataString(artistName), Uri.EscapeDataString(trackName));
            AudioDbTracks audioDbTracks = await _downloader.DownloadAsync <AudioDbTracks>(url).ConfigureAwait(false);

            if (audioDbTracks.Tracks != null && audioDbTracks.Tracks.Count > 0)
            {
                List <AudioDbTrack> list = audioDbTracks.Tracks.Where(t => t.TrackID > 0).ToList();
                foreach (AudioDbTrack track in list)
                {
                    track.SetLanguage(language);
                }
                if (list.Count > 0)
                {
                    return(list);
                }
            }
            return(null);
        }
Exemplo n.º 5
0
        public List <AudioDbTrack> SearchTrack(string artistName, string trackName, string language)
        {
            AudioDbTracks audioDbTracks = null;
            string        url           = GetUrl(URL_TRACK_BY_ARTIST_AND_NAME, Uri.EscapeDataString(artistName), Uri.EscapeDataString(trackName));

            audioDbTracks = _downloader.Download <AudioDbTracks>(url);
            if (audioDbTracks.Tracks != null && audioDbTracks.Tracks.Count > 0)
            {
                List <AudioDbTrack> list = audioDbTracks.Tracks.Where(t => t.TrackID > 0).ToList();
                foreach (AudioDbTrack track in list)
                {
                    track.SetLanguage(language);
                }
                if (list.Count > 0)
                {
                    return(list);
                }
            }
            return(null);
        }