Cross reference local playlists with beatleader playlists
This commit is contained in:
+55
-1
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using IPA;
|
||||
using IPALogger = IPA.Logging.Logger;
|
||||
|
||||
@@ -45,15 +47,36 @@ namespace Setlist
|
||||
return;
|
||||
}
|
||||
|
||||
var entries = new List<(string Title, bool HasSyncUrl, string BeatLeaderGuid)>();
|
||||
foreach (var playlist in playlists)
|
||||
{
|
||||
var hasSyncUrl = false;
|
||||
string syncUrl = null;
|
||||
if (playlist.TryGetCustomData("syncURL", out var syncObj) && syncObj is string url)
|
||||
{
|
||||
syncUrl = url;
|
||||
hasSyncUrl = !string.IsNullOrWhiteSpace(url);
|
||||
}
|
||||
|
||||
Log.Info($"Playlist \"{playlist.Title}\": hasSyncUrl={hasSyncUrl}");
|
||||
string blGuid = null;
|
||||
if (hasSyncUrl && BeatLeaderPlaylistOwnership.TryExtractBeatLeaderPlaylistGuid(syncUrl, out var g))
|
||||
{
|
||||
blGuid = g;
|
||||
}
|
||||
|
||||
entries.Add((playlist.Title, hasSyncUrl, blGuid));
|
||||
}
|
||||
|
||||
if (entries.Any(e => e.BeatLeaderGuid != null))
|
||||
{
|
||||
BeatLeaderPlaylistOwnership.ScheduleVerifyAndLog(entries, Log);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var e in entries)
|
||||
{
|
||||
Log.Info(FormatPlaylistLogLine(e.Title, e.HasSyncUrl, e.BeatLeaderGuid, ownedGuids: null));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -66,5 +89,36 @@ namespace Setlist
|
||||
public void OnApplicationQuit()
|
||||
{
|
||||
}
|
||||
|
||||
internal static string FormatPlaylistLogLine(
|
||||
string title,
|
||||
bool hasSyncUrl,
|
||||
string beatLeaderGuid,
|
||||
HashSet<string> ownedGuids)
|
||||
{
|
||||
string ownerPart;
|
||||
if (!hasSyncUrl)
|
||||
{
|
||||
ownerPart = "beatLeaderOwnerConfirmed=n/a (no sync URL)";
|
||||
}
|
||||
else if (string.IsNullOrEmpty(beatLeaderGuid))
|
||||
{
|
||||
ownerPart = "beatLeaderOwnerConfirmed=n/a (sync URL is not a BeatLeader playlist)";
|
||||
}
|
||||
else if (ownedGuids == null)
|
||||
{
|
||||
ownerPart = "beatLeaderOwnerConfirmed=unknown (BeatLeader /user/playlists did not succeed; see prior log line)";
|
||||
}
|
||||
else if (ownedGuids.Contains(beatLeaderGuid))
|
||||
{
|
||||
ownerPart = "beatLeaderOwnerConfirmed=true";
|
||||
}
|
||||
else
|
||||
{
|
||||
ownerPart = "beatLeaderOwnerConfirmed=false";
|
||||
}
|
||||
|
||||
return $"Playlist \"{title}\": hasSyncUrl={hasSyncUrl}, {ownerPart}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user