Exemplo n.º 1
0
        public static YandexTrack FromJson(JToken jTrack)
        {
            try
            {
                var track = new YandexTrack
                {
                    Id        = jTrack.GetString("id"),
                    RealId    = jTrack.GetString("realId"),
                    Title     = jTrack.GetString("title"),
                    Major     = YandexMajor.FromJson(jTrack.Contains("major")),
                    Available = jTrack.GetBool("available"),
                    AvailableForPremiumUsers = jTrack.GetBool("availableForPremiumUsers"),
                    Albums     = jTrack.ContainField("albums") ? YandexAlbum.FromJsonArray(jTrack["albums"].ToObject <JArray>()) : null,
                    DurationMS = jTrack["durationMs"].ToObject <int>(),
                    StorageDir = jTrack.GetString("storageDir"),
                    FileSize   = jTrack.GetInt("fileSize"),
                    Artists    = YandexArtist.FromJsonArray(jTrack["artists"].ToObject <JArray>()),
                    OgImage    = jTrack.GetString("ogImage")
                };
                return(track);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(null);
        }
Exemplo n.º 2
0
        public static YandexMajor FromJson(JToken jMajor)
        {
            if (!jMajor.Contains("major"))
            {
                return(null);
            }

            var majot = new YandexMajor
            {
                Id   = jMajor.GetString("id"),
                Name = jMajor.GetString("name")
            };

            return(majot);
        }