forked from sim0n00ps/OF-DL
Compare commits
2 Commits
fix-widevi
...
master
Author | SHA1 | Date | |
---|---|---|---|
824d88a6b8 | |||
64ff74f753 |
@ -2805,11 +2805,11 @@ public class APIHelper : IAPIHelper
|
||||
|
||||
try
|
||||
{
|
||||
var resp1 = await PostData(licenceURL, drmHeaders, new byte[] { 0x08, 0x04 });
|
||||
var resp1 = PostData(licenceURL, drmHeaders, new byte[] { 0x08, 0x04 });
|
||||
var certDataB64 = Convert.ToBase64String(resp1);
|
||||
var cdm = new CDMApi();
|
||||
var challenge = cdm.GetChallenge(pssh, certDataB64, false, false);
|
||||
var resp2 = await PostData(licenceURL, drmHeaders, challenge);
|
||||
var resp2 = PostData(licenceURL, drmHeaders, challenge);
|
||||
var licenseB64 = Convert.ToBase64String(resp2);
|
||||
Log.Debug($"resp1: {resp1}");
|
||||
Log.Debug($"certDataB64: {certDataB64}");
|
||||
|
@ -3,7 +3,4 @@ namespace OF_DL.Helpers;
|
||||
public static class Constants
|
||||
{
|
||||
public const string API_URL = "https://onlyfans.com/api2/v2";
|
||||
|
||||
public const int WIDEVINE_RETRY_DELAY = 10;
|
||||
public const int WIDEVINE_MAX_RETRIES = 3;
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using OF_DL.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
@ -14,66 +13,46 @@ namespace WidevineClient
|
||||
//Proxy = null
|
||||
});
|
||||
|
||||
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers, string postData)
|
||||
public static byte[] PostData(string URL, Dictionary<string, string> headers, string postData)
|
||||
{
|
||||
var mediaType = postData.StartsWith("{") ? "application/json" : "application/x-www-form-urlencoded";
|
||||
var response = await PerformOperation(async () =>
|
||||
{
|
||||
StringContent content = new StringContent(postData, Encoding.UTF8, mediaType);
|
||||
//ByteArrayContent content = new ByteArrayContent(postData);
|
||||
StringContent content = new StringContent(postData, Encoding.UTF8, mediaType);
|
||||
//ByteArrayContent content = new ByteArrayContent(postData);
|
||||
|
||||
return await Post(URL, headers, content);
|
||||
});
|
||||
|
||||
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
||||
HttpResponseMessage response = Post(URL, headers, content);
|
||||
byte[] bytes = response.Content.ReadAsByteArrayAsync().Result;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers, byte[] postData)
|
||||
public static byte[] PostData(string URL, Dictionary<string, string> headers, byte[] postData)
|
||||
{
|
||||
var response = await PerformOperation(async () =>
|
||||
{
|
||||
ByteArrayContent content = new ByteArrayContent(postData);
|
||||
ByteArrayContent content = new ByteArrayContent(postData);
|
||||
|
||||
return await Post(URL, headers, content);
|
||||
});
|
||||
|
||||
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
||||
HttpResponseMessage response = Post(URL, headers, content);
|
||||
byte[] bytes = response.Content.ReadAsByteArrayAsync().Result;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers, Dictionary<string, string> postData)
|
||||
public static byte[] PostData(string URL, Dictionary<string, string> headers, Dictionary<string, string> postData)
|
||||
{
|
||||
var response = await PerformOperation(async () =>
|
||||
{
|
||||
FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
|
||||
FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
|
||||
|
||||
return await Post(URL, headers, content);
|
||||
});
|
||||
|
||||
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
||||
HttpResponseMessage response = Post(URL, headers, content);
|
||||
byte[] bytes = response.Content.ReadAsByteArrayAsync().Result;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static async Task<string> GetWebSource(string URL, Dictionary<string, string> headers = null)
|
||||
public static string GetWebSource(string URL, Dictionary<string, string> headers = null)
|
||||
{
|
||||
var response = await PerformOperation(async () =>
|
||||
{
|
||||
return await Get(URL, headers);
|
||||
});
|
||||
|
||||
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
||||
HttpResponseMessage response = Get(URL, headers);
|
||||
byte[] bytes = response.Content.ReadAsByteArrayAsync().Result;
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
|
||||
public static async Task<byte[]> GetBinary(string URL, Dictionary<string, string> headers = null)
|
||||
public static byte[] GetBinary(string URL, Dictionary<string, string> headers = null)
|
||||
{
|
||||
var response = await PerformOperation(async () =>
|
||||
{
|
||||
return await Get(URL, headers);
|
||||
});
|
||||
|
||||
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
||||
HttpResponseMessage response = Get(URL, headers);
|
||||
byte[] bytes = response.Content.ReadAsByteArrayAsync().Result;
|
||||
return bytes;
|
||||
}
|
||||
public static string GetString(byte[] bytes)
|
||||
@ -81,7 +60,7 @@ namespace WidevineClient
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
|
||||
private static async Task<HttpResponseMessage> Get(string URL, Dictionary<string, string> headers = null)
|
||||
static HttpResponseMessage Get(string URL, Dictionary<string, string> headers = null)
|
||||
{
|
||||
HttpRequestMessage request = new HttpRequestMessage()
|
||||
{
|
||||
@ -93,10 +72,10 @@ namespace WidevineClient
|
||||
foreach (KeyValuePair<string, string> header in headers)
|
||||
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
|
||||
|
||||
return await Send(request);
|
||||
return Send(request);
|
||||
}
|
||||
|
||||
private static async Task<HttpResponseMessage> Post(string URL, Dictionary<string, string> headers, HttpContent content)
|
||||
static HttpResponseMessage Post(string URL, Dictionary<string, string> headers, HttpContent content)
|
||||
{
|
||||
HttpRequestMessage request = new HttpRequestMessage()
|
||||
{
|
||||
@ -109,41 +88,12 @@ namespace WidevineClient
|
||||
foreach (KeyValuePair<string, string> header in headers)
|
||||
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
|
||||
|
||||
return await Send(request);
|
||||
return Send(request);
|
||||
}
|
||||
|
||||
private static async Task<HttpResponseMessage> Send(HttpRequestMessage request)
|
||||
static HttpResponseMessage Send(HttpRequestMessage request)
|
||||
{
|
||||
return await Client.SendAsync(request);
|
||||
}
|
||||
|
||||
private static async Task<HttpResponseMessage> PerformOperation(Func<Task<HttpResponseMessage>> operation)
|
||||
{
|
||||
var response = await operation();
|
||||
|
||||
var retryCount = 0;
|
||||
|
||||
while (retryCount < Constants.WIDEVINE_MAX_RETRIES && response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
|
||||
{
|
||||
//
|
||||
// We've hit a rate limit, so we should wait before retrying.
|
||||
//
|
||||
var retryAfterSeconds = Constants.WIDEVINE_RETRY_DELAY * (retryCount + 1); // Default retry time. Increases with each retry.
|
||||
if (response.Headers.RetryAfter != null && response.Headers.RetryAfter.Delta.HasValue)
|
||||
{
|
||||
if (response.Headers.RetryAfter.Delta.Value.TotalSeconds > 0)
|
||||
retryAfterSeconds = (int)response.Headers.RetryAfter.Delta.Value.TotalSeconds + 1; // Add 1 second to ensure we wait a bit longer than the suggested time
|
||||
}
|
||||
|
||||
await Task.Delay(retryAfterSeconds * 1000); // Peform the delay
|
||||
|
||||
response = await operation();
|
||||
retryCount++;
|
||||
}
|
||||
|
||||
response.EnsureSuccessStatusCode(); // Throw an exception if the response is not successful
|
||||
|
||||
return response;
|
||||
return Client.SendAsync(request).Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
mkdocs.yml
10
mkdocs.yml
@ -2,6 +2,11 @@ site_name: OF-DL Docs
|
||||
site_url: https://docs.ofdl.tools
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Installation:
|
||||
- Windows: installation/windows.md
|
||||
- macOS: installation/macos.md
|
||||
- Linux: installation/linux.md
|
||||
- Docker: installation/docker.md
|
||||
- Running the Program: running-the-program.md
|
||||
- Config:
|
||||
- Authentication: config/auth.md
|
||||
@ -9,11 +14,6 @@ nav:
|
||||
- Configuration: config/configuration.md
|
||||
- All Configuration Options: config/all-configuration-options.md
|
||||
- Custom Filename Formats: config/custom-filename-formats.md
|
||||
- Installation:
|
||||
- Windows: installation/windows.md
|
||||
- macOS: installation/macos.md
|
||||
- Linux: installation/linux.md
|
||||
- Docker: installation/docker.md
|
||||
theme:
|
||||
name: material
|
||||
features:
|
||||
|
Loading…
x
Reference in New Issue
Block a user