[CHANGE] Reworked cipher stuff
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Manager.YouTube.Util.Converters;
|
||||
|
||||
namespace Manager.YouTube.Models.Innertube;
|
||||
|
||||
@@ -8,6 +9,7 @@ public class StreamingData
|
||||
[JsonPropertyName("expiresInSeconds")]
|
||||
public int ExpiresInSeconds { get; set; }
|
||||
[JsonPropertyName("serverAbrStreamingUrl")]
|
||||
[JsonConverter(typeof(JsonUrlEscapeConverter))]
|
||||
public string ServerAbrStreamingUrl { get; set; } = "";
|
||||
[JsonPropertyName("formats")]
|
||||
public List<StreamingFormat> Formats { get; set; } = [];
|
||||
|
||||
@@ -112,7 +112,7 @@ public partial class CipherDecoder
|
||||
}
|
||||
|
||||
|
||||
[GeneratedRegex(@"(\w+)=function\(\w+\){(\w+)=\2\.split\(\x22{2}\);.*?return\s+\2\.join\(\x22{2}\)}")]
|
||||
[GeneratedRegex(@"([A-Za-z_$][A-Za-z0-9_$]*)=function\([A-Za-z_$][A-Za-z0-9_$]*\)\{\s*([A-Za-z_$][A-Za-z0-9_$]*)=\2\.split\(\x22\x22\);[\s\S]*?return\s+\2\.join\(\x22\x22\)\s*\}")]
|
||||
private static partial Regex FunctionBodyRegex();
|
||||
[GeneratedRegex("([\\$_\\w]+).\\w+\\(\\w+,\\d+\\);")]
|
||||
private static partial Regex DefinitionBodyRegex();
|
||||
|
||||
27
Manager.YouTube/Util/Converters/JsonUrlEscapeConverter.cs
Normal file
27
Manager.YouTube/Util/Converters/JsonUrlEscapeConverter.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Manager.YouTube.Util.Converters;
|
||||
|
||||
public partial class JsonUrlEscapeConverter : JsonConverter<string>
|
||||
{
|
||||
public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var url = reader.GetString();
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
return UrlPatternRegex().IsMatch(url) ? Uri.UnescapeDataString(url) : url;
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value);
|
||||
}
|
||||
|
||||
[GeneratedRegex("^(https?|ftp)://", RegexOptions.IgnoreCase | RegexOptions.Compiled, "nl-NL")]
|
||||
private static partial Regex UrlPatternRegex();
|
||||
}
|
||||
Reference in New Issue
Block a user