Ejemplo n.º 1
0
        // TODO: UnseenTrackCount
        // TODO: CreationDate
        // TODO: Rating

        public static IPlaylist FromJson(JToken json, IDeezerClient client)
        {
            return(new Playlist()
            {
                Id = ulong.Parse(json.Value <string>(ID_PROPERTY_NAME)),

                Title = json.Value <string>(TITLE_PROPERTY_NAME),
                Description = json.Value <string>(DESCRIPTION_PROPERTY_NAME),

                IsPublic = json.Value <bool>(PUBLIC_PROPERTY_NAME),
                IsCollaborative = json.Value <bool>(COLLABORATIVE_PROPERTY_NAME),
                IsLovedTrack = json.Value <bool>(LOVED_TRACKS_PROPERTY_NAME),

                Duration = json.Value <uint>(DURATION_PROPERTY_NAME),

                NumberOfFans = json.Value <uint>(FANS_PROPERTY_NAME),
                NumberOfTracks = json.Value <uint>(TRACK_COUNT_PROPERTY_NAME),

                Link = json.Value <string>(LINK_PROPERTY_NAME),
                ShareLink = json.Value <string>(SHARE_LINK_PROPERTY_NAME),

                Images = Api.Images.FromJson(json),

                Creator = Api.UserProfile.FromJson(json[CREATOR_PROPERTY_NAME], client) ?? Api.UserProfile.FromJson(json[USER_PROPERTY_NAME], client),
                TracklistInternal = FragmentOf <ITrack> .FromJson(json[TRACKS_PROPERTY_NAME], x => Api.Track.FromJson(x, client)),

                Client = client,
            });
        }
Ejemplo n.º 2
0
 public static IChart FromJson(JToken json, IDeezerClient client)
 {
     return(new Chart()
     {
         Albums = FragmentOf <IAlbum> .FromJson(json[ALBUMS_PROPERTY_NAME], x => Api.Album.FromJson(x, client)),
         Artists = FragmentOf <IArtist> .FromJson(json[ARTISTS_PROPERTY_NAME], x => Api.Artist.FromJson(x, client)),
         Tracks = FragmentOf <ITrack> .FromJson(json[TRACKS_PROPERTY_NAME], x => Api.Track.FromJson(x, client)),
         Playlists = FragmentOf <IPlaylist> .FromJson(json[PLAYLISTS_PROPERTY_NAME], x => Api.Playlist.FromJson(x, client)),
     });
 }
Ejemplo n.º 3
0
        public static IAlbum FromJson(JToken json, IDeezerClient client)
        {
            if (json == null)
            {
                return(null);
            }

            string   apiDateString = json.Value <string>(RELEASE_DATE_PROPERTY_NAME);
            DateTime?releaseDate   = DateTimeExtensions.ParseApiDateTime(apiDateString);

            return(new Album()
            {
                Id = json.Value <ulong>(ID_PROPERTY_NAME),
                Title = json.Value <string>(TITLE_PROPERTY_NAME),

                UPC = json.Value <string>(UPC_PROPERTY_NAME),

                Link = json.Value <string>(LINK_PROPERTY_NAME),
                ShareLink = json.Value <string>(SHARE_LINK_PROPERTY_NAME),

                CoverArtwork = Images.FromJson(json),

                GenreId = json.ValueOrDefault <ulong>(GENRE_ID_PROPERTY_NAME, 0),
                Genre = FragmentOf <IGenre> .FromJson(json[GENRE_LIST_PROPERTY_NAME],
                                                      x => Api.Genre.FromJson(x, client)),

                Fans = json.Value <uint>(FANS_PROPERTY_NAME),

                Rating = json.Value <int>(RATING_PROPERTY_NAME),

                Label = json.Value <string>(LABEL_PROPERTY_NAME),
                TrackCount = json.Value <uint>(TRACK_COUNT_PROEPRTY_NAME),
                Duration = json.Value <uint>(DURATION_PROPERTY_NAME),

                ReleaseDate = releaseDate,

                Available = json.Value <bool>(AVAILABLE_PROPERTY_NAME),

                RecordType = json.Value <string>(RECORD_TYPE_PROPERTY_NAME),

                Contributors = CollectionOf <IArtist> .FromJson(json[CONTRIBUTORS_PROPERTY_NAME],
                                                                x => Api.Artist.FromJson(x, client)),

                Artist = Api.Artist.FromJson(json[ARTIST_PROPERTY_NAME], client),

                TracklistInternal = FragmentOf <ITrack> .FromJson(json[TRACKS_PROPERTY_NAME],
                                                                  x => Api.Track.FromJson(x, client)),


                // ISessionObject
                Client = client,
            });
        }
Ejemplo n.º 4
0
        public Task <IEnumerable <IRadio> > FindRadio(string searchTerm, CancellationToken cancellationToken, uint start = 0, uint count = 25)
        {
            if (string.IsNullOrEmpty(searchTerm))
            {
                throw new ArgumentException("No search term given.", nameof(searchTerm));
            }

            var escapedSearchTerm = Uri.EscapeUriString(searchTerm);

            return(this.client.Get($"search/radio?q={escapedSearchTerm}&{START_PARAM}={start}&{COUNT_PARAM}={count}",
                                   cancellationToken,
                                   json => FragmentOf <IRadio> .FromJson(json, x => Api.Radio.FromJson(x, this.client))));
        }
Ejemplo n.º 5
0
 public Task <IEnumerable <IRadio> > GetRecommendedRadio(CancellationToken cancellationToken, uint start = 0, uint count = 25)
 => this.client.Get($"user/me/recommendations/radios?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    DeezerPermissions.BasicAccess,
                    cancellationToken,
                    json => FragmentOf <IRadio> .FromJson(json, x => Api.Radio.FromJson(x, this.client)));
Ejemplo n.º 6
0
 public Task <IEnumerable <IUserProfile> > GetAlbumFans(ulong albumId, CancellationToken cancellationToken, uint start = 0, uint count = 10)
 => this.client.Get($"/album/{albumId}/fans?{kStartParam}={start}&{kLimitParam}={count}",
                    cancellationToken,
                    json => FragmentOf <IUserProfile> .FromJson(json, x => Api.UserProfile.FromJson(x, this.client)));
Ejemplo n.º 7
0
 public Task <IEnumerable <ITrack> > GetArtistsTopTracks(ulong artistId, CancellationToken cancellationToken, uint start = 0, uint count = 25)
 => this.client.Get($"/artist/{artistId}/top?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <ITrack> .FromJson(json, x => Api.Track.FromJson(x, this.client)));
Ejemplo n.º 8
0
 public Task <IEnumerable <IAlbum> > GetArtistsAlbums(ulong artistId, CancellationToken cancellationToken, uint start = 0, uint count = 10)
 => this.client.Get($"/artist/{artistId}/albums?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <IAlbum> .FromJson(json, x => Api.Album.FromJson(x, this.client)));
Ejemplo n.º 9
0
 public Task <IEnumerable <ITrack> > GetAlbumTracks(ulong albumId, CancellationToken cancellationToken, uint start = 0, uint count = 50)
 => this.client.Get($"/album/{albumId}/tracks?{kStartParam}={start}&{kLimitParam}={count}",
                    cancellationToken,
                    json => FragmentOf <ITrack> .FromJson(json, x => Api.Track.FromJson(x, this.client)));
Ejemplo n.º 10
0
 public Task <IEnumerable <IPlaylist> > GetPlaylistsFeaturingArtist(ulong artistId, CancellationToken cancellationToken, uint start = 0, uint count = 10)
 => this.client.Get($"/artist/{artistId}/playlists?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <IPlaylist> .FromJson(json, x => Api.Playlist.FromJson(x, this.client)));
Ejemplo n.º 11
0
 public Task <IEnumerable <IUserProfile> > GetFans(ulong playlistId, CancellationToken cancellationToken, uint start = 0, uint count = 25)
 => this.client.Get($"playlist/{playlistId}/fans?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <IUserProfile> .FromJson(json, x => Api.UserProfile.FromJson(x, this.client)));
Ejemplo n.º 12
0
 public Task <IEnumerable <IAlbum> > GetNewReleasesForGenre(ulong genreId, CancellationToken cancellationToken, uint start = 0, uint count = 25)
 => this.client.Get($"/editorial/{genreId}/releases?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <IAlbum> .FromJson(json, x => Api.Album.FromJson(x, this.client)));
Ejemplo n.º 13
0
 // NOTE: Endpoint accepts paging but doesn't take note of it
 public Task <IEnumerable <IRadio> > GetRadioForGenre(ulong genreId, CancellationToken cancellationToken, uint start = 0, uint count = 25)
 => this.client.Get($"genre/{genreId}/radios?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <IRadio> .FromJson(json, x => Api.Radio.FromJson(x, this.client)));
Ejemplo n.º 14
0
 public Task <IEnumerable <IRadio> > GetFavouriteRadio(ulong userId, CancellationToken cancellationToken, uint start = 0, uint count = 25)
 => this.client.Get($"user/{userId}/radios?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <IRadio> .FromJson(json, x => Api.Radio.FromJson(x, this.client)));
Ejemplo n.º 15
0
 public Task <IEnumerable <ITrack> > GetListeningHistory(CancellationToken cancellationToken, uint start = 0, uint count = 25)
 => this.client.Get($"user/me/history?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    DeezerPermissions.ListeningHistory,
                    cancellationToken,
                    json => FragmentOf <ITrack> .FromJson(json, x => Api.Track.FromJson(x, this.client)));
Ejemplo n.º 16
0
 public Task <IEnumerable <ITrack> > GetFlow(ulong userId, CancellationToken cancellationToken, uint start = 0, uint count = 50)
 => this.client.Get($"user/{userId}/flow?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <ITrack> .FromJson(json, x => Api.Track.FromJson(x, this.client)));
Ejemplo n.º 17
0
 public Task <IEnumerable <ITrack> > GetTracks(ulong radioId, CancellationToken cancellationToken, uint trackCount = 50)
 => this.client.Get($"radio/{radioId}/tracks?{COUNT_PARAM}={trackCount}",
                    cancellationToken,
                    json => FragmentOf <ITrack> .FromJson(json, x => Api.Track.FromJson(x, this.client)));
Ejemplo n.º 18
0
 public Task <IEnumerable <IRadio> > GetTopRadio(CancellationToken cancellationToken)
 => this.client.Get("radio/top",
                    cancellationToken,
                    json => FragmentOf <IRadio> .FromJson(json, x => Api.Radio.FromJson(x, this.client)));
Ejemplo n.º 19
0
 public Task <IEnumerable <IGenre> > GetCommonGenre(CancellationToken cancellationToken)
 => this.client.Get("genre",
                    cancellationToken,
                    json => FragmentOf <IGenre> .FromJson(json, x => Api.Genre.FromJson(x, this.client)));
Ejemplo n.º 20
0
 public Task <IEnumerable <IPlaylist> > GetPlaylists(CancellationToken cancellationToken, uint start = 0, uint count = 25)
 => this.client.Get($"user/me/playlists?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    DeezerPermissions.ManageLibrary,
                    cancellationToken,
                    json => FragmentOf <IPlaylist> .FromJson(json, x => Api.Playlist.FromJson(x, this.client)));
Ejemplo n.º 21
0
 public Task <IEnumerable <IArtist> > GetArtistChartForGenre(ulong genreId, CancellationToken cancellationToken, uint start = 0, uint count = 50)
 => this.client.Get($"/chart/{genreId}/artists?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <IArtist> .FromJson(json, x => Api.Artist.FromJson(x, this.client)));
Ejemplo n.º 22
0
 public Task <IEnumerable <ITrack> > GetTracks(ulong playlistId, CancellationToken cancellationToken, uint start = 0, uint count = 50)
 => this.client.Get($"playlist/{playlistId}/tracks?{START_PARAM}={start}&{COUNT_PARAM}={count}",
                    cancellationToken,
                    json => FragmentOf <ITrack> .FromJson(json, x => Api.Track.FromJson(x, this.client)));