Example #1
0
        public static YPlaylistResponse FromJson(JToken json)
        {
            var playlist = new YPlaylistResponse
            {
                Revision              = json.SelectToken("revision")?.ToObject <int>(),
                Kind                  = json.SelectToken("kind")?.ToObject <string>(),
                Title                 = json.SelectToken("title")?.ToObject <string>(),
                Description           = json.SelectToken("description")?.ToObject <string>(),
                DescriptionFormatted  = json.SelectToken("descriptionFormatted")?.ToObject <string>(),
                TrackCount            = json.SelectToken("trackCount")?.ToObject <int>(),
                Visibility            = json.SelectToken("visibility")?.ToObject <string>(),
                Cover                 = YPlaylistCover.FromJson(json.SelectToken("cover")),
                Owner                 = YOwner.FromJson(json["owner"]),
                Tracks                = json.SelectToken("tracks")?.Select(x => YTrack.FromJson(x)).ToList(),
                Modified              = json.SelectToken("modified")?.ToObject <string>(),
                TrackIds              = json.SelectToken("trackIds")?.Select(x => x.ToObject <int>()).ToList(),
                OgImage               = json.SelectToken("ogImage")?.ToObject <string>(),
                Tags                  = json.SelectToken("tags")?.Select(x => x.ToObject <string>()).ToList(),
                LikesCount            = json.SelectToken("likesCount")?.ToObject <int>(),
                Duration              = json.SelectToken("duration")?.ToObject <long>(),
                Collective            = json.SelectToken("collective")?.ToObject <bool>(),
                Prerolls              = json.SelectToken("prerolls")?.Select(x => YPlaylistPrerolls.FromJson(x)).ToList(),
                PlayCounter           = YPlaylistPlayCounter.FromJson(json.SelectToken("playCounter")),
                IdForFrom             = json.SelectToken("idForFrom")?.ToObject <string>(),
                GeneratedPlaylistType = json.SelectToken("generatedPlaylistType")?.ToObject <string>(),
                UrlPart               = json.SelectToken("urlPart")?.ToObject <string>(),
                MadeFor               = YPlaylistMadeFor.FromJson(json.SelectToken("madeFor")),
                OgTitle               = json.SelectToken("ogTitle")?.ToObject <string>(),
                DoNotIndex            = json.SelectToken("doNotIndex")?.ToObject <bool>()
            };

            return(playlist);
        }
Example #2
0
        internal static YPlaylistMadeFor FromJson(JToken json)
        {
            if (json == null)
            {
                return(null);
            }

            return(new YPlaylistMadeFor
            {
                UserInfo = YOwner.FromJson(json.SelectToken("userInfo")),
                MadeFor = YMadeForCaseForms.FromJson(json.SelectToken("caseForms"))
            });
        }
 internal static YPlaylistFavoritesResponse FromJson(JToken json)
 {
     return(new YPlaylistFavoritesResponse
     {
         Success = json["success"].ToObject <bool>(),
         CountsTracks = YCountsTracks.FromJson(json["countsTracks"]),
         Tracks = json["tracks"].Select(YTrack.FromJson).ToList(),
         ContestTracksIds = json["contestTracksIds"].Select(x => YTrackAlbumPair.FromJson(x)).ToList(),
         TrackIds = json["trackIds"].Select(x => x.ToObject <string>()).ToList(),
         Verified = json["verified"].ToObject <bool>(),
         Owner = YOwner.FromJson(json["owner"]),
         Visibility = json["visibility"].ToObject <bool>(),
         Profiles = json["profiles"].Select(x => YProfile.FromJson(x)).ToList(),
         Counts = YLikedCounts.FromJson(json["counts"]),
         HasTracks = json["hasTracks"].ToObject <bool>(),
         IsRadioAvailable = json["isRadioAvailable"].ToObject <bool>()
     });
 }
        internal static YSearchPlaylistModel FromJson(JToken json)
        {
            if (json == null)
            {
                return(null);
            }

            return(new YSearchPlaylistModel
            {
                Revision = json.SelectToken("revision")?.ToObject <int?>(),
                Kind = json.SelectToken("kind")?.ToObject <string>(),
                Title = json.SelectToken("title")?.ToObject <string>(),
                Description = json.SelectToken("description")?.ToObject <string>(),
                DescriptionFormatted = json.SelectToken("descriptionFormatted")?.ToObject <string>(),
                TrackCount = json.SelectToken("trackCount")?.ToObject <int>(),
                Cover = YCover.FromJson(json.SelectToken("cover")),
                Owner = YOwner.FromJson(json["owner"]),
                Tags = json.SelectToken("tags")?.Select(x => x.ToObject <string>()).ToList(),
                LikesCount = json.SelectToken("likesCount")?.ToObject <long>(),
            });
        }