Ejemplo n.º 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);
        }
        public static YInsertTrackToPlaylistResponse FromJson(JToken json)
        {
            var response = new YInsertTrackToPlaylistResponse
            {
                Success  = json["success"].ToObject <bool>(),
                Playlist = YPlaylistResponse.FromJson(json["playlist"])
            };

            return(response);
        }