Ejemplo n.º 1
0
        public Playlist(JObject playlistNode)
        {
            if (playlistNode.ContainsKey("image"))
            {
                image = (string)playlistNode["image"];
            }

            if (!string.IsNullOrWhiteSpace(image))
            {
                try
                {
                    icon = Sprites.Base64ToSprite(image.Substring(image.IndexOf(",") + 1));
                }
                catch
                {
                    Logging.Log.Critical("Unable to convert playlist image to sprite!");
                    icon = Sprites.PlaylistIcon;
                }
            }
            else
            {
                icon = Sprites.PlaylistIcon;
            }
            if (playlistNode.ContainsKey("playlistTitle"))
            {
                playlistTitle = (string)playlistNode["playlistTitle"];
            }
            if (playlistNode.ContainsKey("playlistAuthor"))
            {
                playlistAuthor = (string)playlistNode["playlistAuthor"];
            }
            if (playlistNode.ContainsKey("imcustomDetailUrlage"))
            {
                customDetailUrl = (string)playlistNode["customDetailUrl"];
            }
            if (playlistNode.ContainsKey("customArchiveUrl"))
            {
                customArchiveUrl = (string)playlistNode["customArchiveUrl"];
            }

            this.songs = new List <PlaylistSong>();

            JArray songs = (JArray)playlistNode["songs"];

            foreach (JObject song in songs)
            {
                PlaylistSong newSong = new PlaylistSong();
                if (song.ContainsKey("key"))
                {
                    newSong.key = (string)song["key"];
                }
                if (song.ContainsKey("songName"))
                {
                    newSong.songName = (string)song["songName"];
                }
                if (song.ContainsKey("hash"))
                {
                    newSong.hash = (string)song["hash"];
                }
                if (song.ContainsKey("levelId"))
                {
                    newSong.levelId = (string)song["levelId"];
                }

                this.songs.Add(newSong);
            }

            playlistSongCount = this.songs.Count;

            if (playlistNode.ContainsKey("fileLoc"))
            {
                fileLoc = (string)playlistNode["fileLoc"];
            }

            if (playlistNode.ContainsKey("playlistURL"))
            {
                fileLoc = (string)playlistNode["playlistURL"];
            }
        }