Пример #1
0
        public static void ReloadPlaylists(bool fullRefresh = true)
        {
            try
            {
                List <string> playlistFiles        = new List <string>();
                string[]      localJSONPlaylists   = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory, "Playlists"), "*.json");
                string[]      localBPLISTPlaylists = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory, "Playlists"), "*.bplist");
                playlistFiles.AddRange(localJSONPlaylists);
                playlistFiles.AddRange(localBPLISTPlaylists);

                Logging.Log.Info($"Found {localJSONPlaylists.Length + localBPLISTPlaylists.Length} playlists in Playlists folder");

                if (fullRefresh)
                {
                    loadedPlaylists.Clear();

                    foreach (string path in playlistFiles)
                    {
                        try
                        {
                            Playlist playlist = Playlist.LoadPlaylist(path);
                            loadedPlaylists.Add(playlist);
                        }
                        catch (Exception e)
                        {
                            Logging.Log.Warn($"Unable to parse playlist @ {path}! Exception: {e}");
                        }
                    }
                }
                else
                {
                    foreach (string path in playlistFiles)
                    {
                        if (!loadedPlaylists.Any(x => x.fileLoc == path))
                        {
                            try
                            {
                                Playlist playlist = Playlist.LoadPlaylist(path);
                                if (Path.GetFileName(path) == "favorites.json" && playlist.playlistTitle == "Your favorite songs")
                                {
                                    continue;
                                }
                                loadedPlaylists.Add(playlist);
                                //bananbread songloader loaded playlist id
                                if (SongCore.Loader.AreSongsLoaded)
                                {
                                    MatchSongsForPlaylist(playlist);
                                }
                            }
                            catch (Exception e)
                            {
                                Logging.Log.Info($"Unable to parse playlist @ {path}! Exception: {e}");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logging.Log.Critical("Unable to load playlists! Exception: " + e);
            }
        }
Пример #2
0
 public static SongCore.OverrideClasses.SongCoreCustomBeatmapLevelPack CreateLevelPackFromPlaylist(Playlist playlist)
 {
     return(new SongCore.OverrideClasses.SongCoreCustomBeatmapLevelPack($"{CustomLevelLoaderSO.kCustomLevelPackPrefixId}Playlist_{playlist.playlistTitle}_{playlist.playlistAuthor}", "Playlist - " + playlist.playlistTitle, playlist.icon, new SongCore.OverrideClasses.SongCoreCustomLevelCollection(playlist.songs.Where(x => x.level != null).Select(x => x.level).ToArray())));
 }