示例#1
0
        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 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 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);
        }