[CHANGE] Split up json parsing, added getting account info

This commit is contained in:
max
2025-09-07 22:18:56 +02:00
parent 3db61b599d
commit b2c6003203
11 changed files with 198 additions and 48 deletions

View File

@@ -5,7 +5,7 @@ namespace Manager.YouTube.Parsers;
public static class HtmlParser
{
public static Result<(string, string)> GetStateJson(string html)
public static Result<(string, bool)> GetStateJson(string html)
{
if (string.IsNullOrWhiteSpace(html))
{
@@ -21,14 +21,15 @@ public static class HtmlParser
return ResultError.Fail($"Could not find {setFunction} in html script nodes!");
var json = ExtractJson(scriptNode.InnerText, "ytcfg.set(");
var jsonText = ExtractJson(scriptNode.InnerText, "setMessage(");
if (string.IsNullOrWhiteSpace(json) || string.IsNullOrWhiteSpace(jsonText))
if (string.IsNullOrWhiteSpace(json))
{
return ResultError.Fail($"Could not find {setFunction} in html script nodes!");
}
return (json, jsonText);
var isPremiumUser = html.Contains("logo-type=\"YOUTUBE_PREMIUM_LOGO\"", StringComparison.OrdinalIgnoreCase);
return (json, isPremiumUser);
}
static string? ExtractJson(string input, string marker)