71 lines
2.0 KiB
C#
71 lines
2.0 KiB
C#
using System;
|
|
using IPA;
|
|
using IPALogger = IPA.Logging.Logger;
|
|
|
|
namespace Setlist
|
|
{
|
|
[Plugin(RuntimeOptions.SingleStartInit)]
|
|
public class Plugin
|
|
{
|
|
internal static Plugin Instance { get; private set; }
|
|
|
|
/// <summary>
|
|
/// BSIPA logger (shows in BSIPA console / game logs when verbose).
|
|
/// </summary>
|
|
internal static IPALogger Log { get; private set; }
|
|
|
|
[Init]
|
|
public Plugin(IPALogger logger)
|
|
{
|
|
Instance = this;
|
|
Log = logger;
|
|
}
|
|
|
|
[OnStart]
|
|
public void OnApplicationStart()
|
|
{
|
|
try
|
|
{
|
|
var playlists = BeatSaberPlaylistsLib.PlaylistManager.DefaultManager.GetAllPlaylists(
|
|
includeChildren: true,
|
|
out AggregateException loadErrors);
|
|
|
|
if (loadErrors != null)
|
|
{
|
|
Log.Error(loadErrors.Message);
|
|
foreach (var inner in loadErrors.InnerExceptions)
|
|
{
|
|
Log.Error(inner.ToString());
|
|
}
|
|
}
|
|
|
|
if (playlists == null || playlists.Length == 0)
|
|
{
|
|
Log.Info("No playlists loaded (or playlist library not initialized yet).");
|
|
return;
|
|
}
|
|
|
|
foreach (var playlist in playlists)
|
|
{
|
|
var hasSyncUrl = false;
|
|
if (playlist.TryGetCustomData("syncURL", out var syncObj) && syncObj is string url)
|
|
{
|
|
hasSyncUrl = !string.IsNullOrWhiteSpace(url);
|
|
}
|
|
|
|
Log.Info($"Playlist \"{playlist.Title}\": hasSyncUrl={hasSyncUrl}");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error(ex.ToString());
|
|
}
|
|
}
|
|
|
|
[OnExit]
|
|
public void OnApplicationQuit()
|
|
{
|
|
}
|
|
}
|
|
}
|