protected override List <OnlineMediaItem> ExpandOnlinePlaylist(OnlinePlaylist op, ManualResetEvent abortEvent) { List <OnlineMediaItem> results = new List <OnlineMediaItem>(); if (abortEvent.WaitOne(5)) { return(results); } if (HasValidConfig) { string userAccessToken = ProTONEConfig.DeezerUserAccessToken; string applicationId = ProTONEConfig.DeezerApplicationId; string deezerApiEndpoint = ProTONEConfig.DeezerApiEndpoint; DeezerRuntime dzr = new DeezerRuntime(deezerApiEndpoint, userAccessToken, applicationId); if (_dzr != dzr) { _dzr = dzr; } Playlist p = _dzr.GetPlaylist(op.Id); if (p != null && p.Tracks != null) { foreach (var t in p.Tracks) { try { DeezerTrackItem dti = new DeezerTrackItem { Album = (t.Album != null) ? t.Album.Title : String.Empty, Artist = (t.Artist != null) ? t.Artist.Name : string.Empty, Title = t.Title ?? string.Empty, Url = string.Format("dzmedia:///track/{0}", t.Id), Duration = t.Duration }; results.Add(dti); } catch (Exception ex) { Logger.LogException(ex); } } } } if (abortEvent.WaitOne(5)) { return(results); } SortResults(ref results); return(results); }
public async Task GetCurrentCountryInfos() { // Arrange Deezer.Api.DeezerRuntime runtime = new DeezerRuntime(); // Act CountryInfos apiCallResult = await runtime.GetCountryInfos(); // Assert Assert.IsNotNull(apiCallResult); Assert.IsTrue(apiCallResult.IsDeezerServiceOpen); }
public async Task GetPlaylist() { // Arrange Deezer.Api.DeezerRuntime runtime = new DeezerRuntime(); // Act Playlist playlist = await runtime.GetPlaylist(436999035); Assert.IsNotNull(playlist); // Assert //Assert.IsTrue(testedArtist.Albums.Count > 0); }
public async Task GetArtistAlbums() { // Arrange Deezer.Api.DeezerRuntime runtime = new DeezerRuntime(); // Act Artist testedArtist = await runtime.GetArtist(144227); Assert.IsNotNull(testedArtist); await testedArtist.LoadAlbums(); // Assert Assert.IsTrue(testedArtist.Albums.Count > 0); }
public async Task GetUnknownArtistById() { try { // Arrange Deezer.Api.DeezerRuntime runtime = new DeezerRuntime(); // Act Artist apiCallResult = await runtime.GetArtist(9999999); } catch (DeezerRuntimeException) { // Assert Assert.IsTrue(true); } }
public async Task GetExistingArtist() { // Arrange Deezer.Api.DeezerRuntime runtime = new DeezerRuntime(); // Act Artist apiCallResult = await runtime.GetArtist(144227); // Assert Assert.IsNotNull(apiCallResult); Assert.AreEqual(144227, apiCallResult.Id); Assert.AreEqual("Katy Perry", apiCallResult.Name); Assert.AreEqual("http://www.deezer.com/artist/144227", apiCallResult.WebUri); Assert.AreEqual(new Uri("http://api.deezer.com/artist/144227/image"), apiCallResult.ArtistImageUri); Assert.AreEqual(true, apiCallResult.HasArtistRadio); Assert.IsTrue(apiCallResult.FansCount > 23000); Assert.IsTrue(apiCallResult.AlbumsCount > 70); }
protected override List <OnlinePlaylist> GetMyPlaylists(ManualResetEvent abortEvent) { List <OnlinePlaylist> results = new List <OnlinePlaylist>(); if (abortEvent.WaitOne(5)) { return(results); } if (HasValidConfig) { string userAccessToken = ProTONEConfig.DeezerUserAccessToken; string applicationId = ProTONEConfig.DeezerApplicationId; string deezerApiEndpoint = ProTONEConfig.DeezerApiEndpoint; DeezerRuntime dzr = new DeezerRuntime(deezerApiEndpoint, userAccessToken, applicationId); if (_dzr != dzr) { _dzr = dzr; } List <Playlist> playlists = _dzr.GetMyPlaylists(userAccessToken, abortEvent); if (playlists != null) { foreach (var p in playlists) { OnlinePlaylist op = new OnlinePlaylist { Id = p.Id, Description = p.Description, Title = p.Title }; results.Add(op); } } } return(results); }
protected override List <OnlineMediaItem> Search(OnlineContentSearchParameters searchParams, ManualResetEvent abortEvent) { List <OnlineMediaItem> results = new List <OnlineMediaItem>(); if (abortEvent.WaitOne(5)) { return(results); } if (HasValidConfig) { string userAccessToken = ProTONEConfig.DeezerUserAccessToken; string applicationId = ProTONEConfig.DeezerApplicationId; string deezerApiEndpoint = ProTONEConfig.DeezerApiEndpoint; DeezerRuntime dzr = new DeezerRuntime(deezerApiEndpoint, userAccessToken, applicationId); if (_dzr != dzr) { _dzr = dzr; } searchParams.Filter = OnlineContentSearchFilter.None; bool isFilteredSearch = false; isFilteredSearch |= searchParams.SearchText.Contains("artist:"); isFilteredSearch |= searchParams.SearchText.Contains("track:"); isFilteredSearch |= searchParams.SearchText.Contains("album:"); DeezerJsonFilter filter = null; if (isFilteredSearch) { filter = BuildFilterFromQuery(searchParams.SearchText); } List <Track> tracks = _dzr.ExecuteSearch(searchParams.SearchText, abortEvent); if (tracks != null) { foreach (var t in tracks) { try { DeezerTrackItem dti = new DeezerTrackItem { Album = (t.Album != null) ? t.Album.Title : String.Empty, Artist = (t.Artist != null) ? t.Artist.Name : string.Empty, Title = t.Title ?? string.Empty, Url = string.Format("dzmedia:///track/{0}", t.Id), Duration = t.Duration }; bool shouldAddTrack = true; if (DeezerJsonFilter.IsNullOrEmpty(filter) == false) { if (shouldAddTrack && string.IsNullOrEmpty(filter.Artist) == false) { shouldAddTrack &= dti.Artist.ToLowerInvariant().Contains(filter.Artist); } if (shouldAddTrack && string.IsNullOrEmpty(filter.Album) == false) { shouldAddTrack &= dti.Album.ToLowerInvariant().Contains(filter.Album); } if (shouldAddTrack && string.IsNullOrEmpty(filter.Title) == false) { shouldAddTrack &= dti.Title.ToLowerInvariant().Contains(filter.Title); } } if (shouldAddTrack) { results.Add(dti); } } catch (Exception ex) { Logger.LogException(ex); } } } } if (abortEvent.WaitOne(5)) { return(results); } SortResults(ref results); return(results); }