From f9a0e1669f9f35522fd60d6a847bf076bd115025 Mon Sep 17 00:00:00 2001 From: pleb Date: Sat, 18 Apr 2026 21:54:42 -0700 Subject: [PATCH] Minor cleanup of unused playlist owner detection --- Setlist/BeatLeaderPlaylistOwnership.cs | 119 ------------------------- Setlist/Properties/AssemblyInfo.cs | 4 +- Setlist/manifest.json | 2 +- 3 files changed, 3 insertions(+), 122 deletions(-) diff --git a/Setlist/BeatLeaderPlaylistOwnership.cs b/Setlist/BeatLeaderPlaylistOwnership.cs index f0c014a..dce563b 100644 --- a/Setlist/BeatLeaderPlaylistOwnership.cs +++ b/Setlist/BeatLeaderPlaylistOwnership.cs @@ -7,11 +7,6 @@ using System.Threading; using System.Threading.Tasks; using BeatSaberPlaylistsLib.Types; using UnityEngine; -#if false -using BeatLeader.Utils; -using Newtonsoft.Json; -using UnityEngine.Networking; -#endif using IPALogger = IPA.Logging.Logger; namespace Setlist @@ -242,120 +237,6 @@ namespace Setlist return last; } - - // SETLIST: Remove the entire #if false region below once we no longer need the old - // BeatLeader GET /user/playlists + login-wait verification path for reference. - -#if false - private const string AuthenticationTypeName = "BeatLeader.API.Authentication"; - private const string SignedInFieldName = "_signedIn"; - private const float LoginWaitTimeoutSeconds = 90f; - private const int RequestTimeoutSeconds = 30; - - private sealed class UserPlaylistSummary - { - [JsonProperty("guid")] - public string Guid { get; set; } - } - - private struct FetchResult - { - public HashSet OwnedGuids; - public string Failure; - } - - private IEnumerator FetchOwnedGuids(Action onDone) - { - var url = BLConstants.BEATLEADER_API_URL + "/user/playlists"; - using (var request = UnityWebRequest.Get(url)) - { - request.timeout = RequestTimeoutSeconds; - request.SetRequestHeader("User-Agent", "Setlist/" + GetAssemblyVersion()); - - yield return request.SendWebRequest(); - - if (request.result == UnityWebRequest.Result.ConnectionError) - { - onDone(new FetchResult { Failure = "network error: " + request.error }); - yield break; - } - - if (request.result == UnityWebRequest.Result.ProtocolError) - { - onDone(new FetchResult - { - Failure = $"HTTP {request.responseCode} (cookie session not shared? " - + "check BeatLeader login completed)", - }); - yield break; - } - - var body = request.downloadHandler != null ? request.downloadHandler.text : null; - if (string.IsNullOrEmpty(body)) - { - onDone(new FetchResult { OwnedGuids = new HashSet(StringComparer.OrdinalIgnoreCase) }); - yield break; - } - - HashSet set; - try - { - var summaries = JsonConvert.DeserializeObject>(body); - set = new HashSet(StringComparer.OrdinalIgnoreCase); - if (summaries != null) - { - foreach (var s in summaries) - { - if (!string.IsNullOrEmpty(s?.Guid)) - { - set.Add(s.Guid); - } - } - } - } - catch (Exception ex) - { - onDone(new FetchResult { Failure = "JSON parse failed: " + ex.Message }); - yield break; - } - - onDone(new FetchResult { OwnedGuids = set }); - } - } - - private static FieldInfo ResolveSignedInField(IPALogger log) - { - var beatLeaderAssembly = typeof(BLConstants).Assembly; - var authType = beatLeaderAssembly.GetType(AuthenticationTypeName); - if (authType == null) - { - log.Info($"BeatLeader assembly has no {AuthenticationTypeName} type; cannot detect login state."); - return null; - } - - var field = authType.GetField(SignedInFieldName, BindingFlags.NonPublic | BindingFlags.Static); - if (field == null) - { - log.Info($"{AuthenticationTypeName} has no static field '{SignedInFieldName}'; " - + "BeatLeader may have changed its API."); - return null; - } - - return field; - } - - private static bool IsSignedIn(FieldInfo signedInField) - { - var value = signedInField.GetValue(null); - return value is bool b && b; - } - - private static string GetAssemblyVersion() - { - var asm = typeof(BeatLeaderPlaylistOwnership).Assembly; - return asm.GetName().Version?.ToString() ?? "0.0.0"; - } -#endif } } } diff --git a/Setlist/Properties/AssemblyInfo.cs b/Setlist/Properties/AssemblyInfo.cs index f18d0d0..02773a7 100644 --- a/Setlist/Properties/AssemblyInfo.cs +++ b/Setlist/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("50F53E6E-21D5-4780-8E67-273877DAA28C")] -[assembly: AssemblyVersion("0.0.7.0")] -[assembly: AssemblyFileVersion("0.0.7.0")] +[assembly: AssemblyVersion("0.0.8.0")] +[assembly: AssemblyFileVersion("0.0.8.0")] diff --git a/Setlist/manifest.json b/Setlist/manifest.json index 9afa859..57b03ab 100644 --- a/Setlist/manifest.json +++ b/Setlist/manifest.json @@ -3,7 +3,7 @@ "id": "Setlist", "name": "Setlist", "author": "", - "version": "0.0.7", + "version": "0.0.8", "description": "Syncs playlists with external sources.", "gameVersion": "1.40.8", "dependsOn": {