Пример #1
0
        public Playlist(JSONNode playlistNode)
        {
            string image = playlistNode["image"].Value;

            if (!string.IsNullOrEmpty(image))
            {
                try
                {
                    icon = Sprites.Base64ToSprite(image.Substring(image.IndexOf(",") + 1));
                }
                catch
                {
                    Logger.Exception("Unable to convert playlist image to sprite!");
                    icon = Sprites.BeastSaberLogo;
                }
            }
            else
            {
                icon = Sprites.BeastSaberLogo;
            }
            playlistTitle    = playlistNode["playlistTitle"];
            playlistAuthor   = playlistNode["playlistAuthor"];
            customDetailUrl  = playlistNode["customDetailUrl"];
            customArchiveUrl = playlistNode["customArchiveUrl"];
            if (!string.IsNullOrEmpty(customDetailUrl))
            {
                if (!customDetailUrl.EndsWith("/"))
                {
                    customDetailUrl += "/";
                }
                Logger.Log("Found playlist with customDetailUrl! Name: " + playlistTitle + ", CustomDetailUrl: " + customDetailUrl);
            }
            if (!string.IsNullOrEmpty(customArchiveUrl) && customArchiveUrl.Contains("[KEY]"))
            {
                Logger.Log("Found playlist with customArchiveUrl! Name: " + playlistTitle + ", CustomArchiveUrl: " + customArchiveUrl);
            }

            songs = new List <PlaylistSong>();

            foreach (JSONNode node in playlistNode["songs"].AsArray)
            {
                PlaylistSong song = new PlaylistSong();
                song.key      = node["key"];
                song.songName = node["songName"];
                song.hash     = node["hash"];
                song.levelId  = node["levelId"];

                songs.Add(song);
            }

            if (playlistNode["playlistSongCount"] != null)
            {
                playlistSongCount = playlistNode["playlistSongCount"].AsInt;
            }
            if (playlistNode["fileLoc"] != null)
            {
                fileLoc = playlistNode["fileLoc"];
            }

            if (playlistNode["playlistURL"] != null)
            {
                fileLoc = playlistNode["playlistURL"];
            }
        }
Пример #2
0
        public Playlist(JSONNode playlistNode)
        {
            string image = playlistNode["image"].Value;

            // If we cannot find an image or parse the provided one correctly, fall back to anything.
            // It will never be displayed by SongBrowser.
            if (!string.IsNullOrEmpty(image))
            {
                try
                {
                    icon = Sprites.Base64ToSprite(image.Substring(image.IndexOf(",") + 1));
                }
                catch
                {
                    Logger.Exception("Unable to convert playlist image to sprite!");
                    icon = Sprites.StarFullIcon;
                }
            }
            else
            {
                icon = Sprites.StarFullIcon;
            }
            playlistTitle    = playlistNode["playlistTitle"];
            playlistAuthor   = playlistNode["playlistAuthor"];
            customDetailUrl  = playlistNode["customDetailUrl"];
            customArchiveUrl = playlistNode["customArchiveUrl"];
            if (!string.IsNullOrEmpty(customDetailUrl))
            {
                if (!customDetailUrl.EndsWith("/"))
                {
                    customDetailUrl += "/";
                }
                Logger.Log("Found playlist with customDetailUrl! Name: " + playlistTitle + ", CustomDetailUrl: " + customDetailUrl);
            }
            if (!string.IsNullOrEmpty(customArchiveUrl) && customArchiveUrl.Contains("[KEY]"))
            {
                Logger.Log("Found playlist with customArchiveUrl! Name: " + playlistTitle + ", CustomArchiveUrl: " + customArchiveUrl);
            }

            songs = new List <PlaylistSong>();

            foreach (JSONNode node in playlistNode["songs"].AsArray)
            {
                PlaylistSong song = new PlaylistSong();
                song.key      = node["key"];
                song.songName = node["songName"];
                song.hash     = node["hash"];
                song.levelId  = node["levelId"];

                songs.Add(song);
            }

            if (playlistNode["playlistSongCount"] != null)
            {
                playlistSongCount = playlistNode["playlistSongCount"].AsInt;
            }
            if (playlistNode["fileLoc"] != null)
            {
                fileLoc = playlistNode["fileLoc"];
            }

            if (playlistNode["playlistURL"] != null)
            {
                fileLoc = playlistNode["playlistURL"];
            }
        }