Autoformat the entire solution
This commit is contained in:
parent
7af7bd8cfa
commit
6784ba0a18
@ -10,15 +10,9 @@ public class SpectreProgressReporter : IProgressReporter
|
|||||||
{
|
{
|
||||||
private readonly ProgressTask _task;
|
private readonly ProgressTask _task;
|
||||||
|
|
||||||
public SpectreProgressReporter(ProgressTask task)
|
public SpectreProgressReporter(ProgressTask task) => _task = task ?? throw new ArgumentNullException(nameof(task));
|
||||||
{
|
|
||||||
_task = task ?? throw new ArgumentNullException(nameof(task));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReportProgress(long increment)
|
public void ReportProgress(long increment) => _task.Increment(increment);
|
||||||
{
|
|
||||||
_task.Increment(increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReportStatus(string message)
|
public void ReportStatus(string message)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,21 +4,18 @@ using Org.BouncyCastle.Crypto.Engines;
|
|||||||
using Org.BouncyCastle.Crypto.Macs;
|
using Org.BouncyCastle.Crypto.Macs;
|
||||||
using Org.BouncyCastle.Crypto.Parameters;
|
using Org.BouncyCastle.Crypto.Parameters;
|
||||||
|
|
||||||
namespace OF_DL.Crypto
|
namespace OF_DL.Crypto;
|
||||||
|
|
||||||
|
public class CryptoUtils
|
||||||
{
|
{
|
||||||
public class CryptoUtils
|
public static byte[] GetHMACSHA256Digest(byte[] data, byte[] key) => new HMACSHA256(key).ComputeHash(data);
|
||||||
{
|
|
||||||
public static byte[] GetHMACSHA256Digest(byte[] data, byte[] key)
|
|
||||||
{
|
|
||||||
return new HMACSHA256(key).ComputeHash(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] GetCMACDigest(byte[] data, byte[] key)
|
public static byte[] GetCMACDigest(byte[] data, byte[] key)
|
||||||
{
|
{
|
||||||
IBlockCipher cipher = new AesEngine();
|
IBlockCipher cipher = new AesEngine();
|
||||||
IMac mac = new CMac(cipher, 128);
|
IMac mac = new CMac(cipher, 128);
|
||||||
|
|
||||||
KeyParameter keyParam = new KeyParameter(key);
|
KeyParameter keyParam = new(key);
|
||||||
|
|
||||||
mac.Init(keyParam);
|
mac.Init(keyParam);
|
||||||
|
|
||||||
@ -29,5 +26,4 @@ namespace OF_DL.Crypto
|
|||||||
mac.DoFinal(outBytes, 0);
|
mac.DoFinal(outBytes, 0);
|
||||||
return outBytes;
|
return outBytes;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace OF_DL.Crypto
|
namespace OF_DL.Crypto;
|
||||||
|
|
||||||
|
public class Padding
|
||||||
{
|
{
|
||||||
public class Padding
|
|
||||||
{
|
|
||||||
public static byte[] AddPKCS7Padding(byte[] data, int k)
|
public static byte[] AddPKCS7Padding(byte[] data, int k)
|
||||||
{
|
{
|
||||||
int m = k - (data.Length % k);
|
int m = k - data.Length % k;
|
||||||
|
|
||||||
byte[] padding = new byte[m];
|
byte[] padding = new byte[m];
|
||||||
Array.Fill(padding, (byte)m);
|
Array.Fill(padding, (byte)m);
|
||||||
@ -20,18 +20,18 @@ namespace OF_DL.Crypto
|
|||||||
|
|
||||||
public static byte[] RemovePKCS7Padding(byte[] paddedByteArray)
|
public static byte[] RemovePKCS7Padding(byte[] paddedByteArray)
|
||||||
{
|
{
|
||||||
var last = paddedByteArray[^1];
|
byte last = paddedByteArray[^1];
|
||||||
if (paddedByteArray.Length <= last)
|
if (paddedByteArray.Length <= last)
|
||||||
{
|
{
|
||||||
return paddedByteArray;
|
return paddedByteArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SubArray(paddedByteArray, 0, (paddedByteArray.Length - last));
|
return SubArray(paddedByteArray, 0, paddedByteArray.Length - last);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T[] SubArray<T>(T[] arr, int start, int length)
|
public static T[] SubArray<T>(T[] arr, int start, int length)
|
||||||
{
|
{
|
||||||
var result = new T[length];
|
T[] result = new T[length];
|
||||||
Buffer.BlockCopy(arr, start, result, 0, length);
|
Buffer.BlockCopy(arr, start, result, 0, length);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -45,7 +45,9 @@ namespace OF_DL.Crypto
|
|||||||
|
|
||||||
int lmask = 0;
|
int lmask = 0;
|
||||||
for (int i = 0; i < 8 * emLen - (modBits - 1); i++)
|
for (int i = 0; i < 8 * emLen - (modBits - 1); i++)
|
||||||
lmask = lmask >> 1 | 0x80;
|
{
|
||||||
|
lmask = (lmask >> 1) | 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
if (emLen < hLen + hLen + 2)
|
if (emLen < hLen + hLen + 2)
|
||||||
{
|
{
|
||||||
@ -65,7 +67,9 @@ namespace OF_DL.Crypto
|
|||||||
|
|
||||||
byte[] maskedDb = new byte[dbMask.Length];
|
byte[] maskedDb = new byte[dbMask.Length];
|
||||||
for (int i = 0; i < dbMask.Length; i++)
|
for (int i = 0; i < dbMask.Length; i++)
|
||||||
|
{
|
||||||
maskedDb[i] = (byte)(db[i] ^ dbMask[i]);
|
maskedDb[i] = (byte)(db[i] ^ dbMask[i]);
|
||||||
|
}
|
||||||
|
|
||||||
maskedDb[0] = (byte)(maskedDb[0] & ~lmask);
|
maskedDb[0] = (byte)(maskedDb[0] & ~lmask);
|
||||||
|
|
||||||
@ -86,13 +90,17 @@ namespace OF_DL.Crypto
|
|||||||
|
|
||||||
byte[] seed = new byte[maskedSeed.Length];
|
byte[] seed = new byte[maskedSeed.Length];
|
||||||
for (int i = 0; i < maskedSeed.Length; i++)
|
for (int i = 0; i < maskedSeed.Length; i++)
|
||||||
|
{
|
||||||
seed[i] = (byte)(maskedSeed[i] ^ seedMask[i]);
|
seed[i] = (byte)(maskedSeed[i] ^ seedMask[i]);
|
||||||
|
}
|
||||||
|
|
||||||
byte[] dbMask = MGF1(seed, k - hLen - 1);
|
byte[] dbMask = MGF1(seed, k - hLen - 1);
|
||||||
|
|
||||||
byte[] db = new byte[maskedDB.Length];
|
byte[] db = new byte[maskedDB.Length];
|
||||||
for (int i = 0; i < maskedDB.Length; i++)
|
for (int i = 0; i < maskedDB.Length; i++)
|
||||||
|
{
|
||||||
db[i] = (byte)(maskedDB[i] ^ dbMask[i]);
|
db[i] = (byte)(maskedDB[i] ^ dbMask[i]);
|
||||||
|
}
|
||||||
|
|
||||||
int onePos = BitConverter.ToString(db[hLen..]).Replace("-", "").IndexOf("01") / 2;
|
int onePos = BitConverter.ToString(db[hLen..]).Replace("-", "").IndexOf("01") / 2;
|
||||||
byte[] unpadded = db[(hLen + onePos + 1)..];
|
byte[] unpadded = db[(hLen + onePos + 1)..];
|
||||||
@ -100,19 +108,19 @@ namespace OF_DL.Crypto
|
|||||||
return unpadded;
|
return unpadded;
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte[] MGF1(byte[] seed, int maskLen)
|
private static byte[] MGF1(byte[] seed, int maskLen)
|
||||||
{
|
{
|
||||||
SHA1 hobj = SHA1.Create();
|
SHA1 hobj = SHA1.Create();
|
||||||
int hLen = hobj.HashSize / 8;
|
int hLen = hobj.HashSize / 8;
|
||||||
List<byte> T = new List<byte>();
|
List<byte> T = new();
|
||||||
for (int i = 0; i < (int)Math.Ceiling(((double)maskLen / (double)hLen)); i++)
|
for (int i = 0; i < (int)Math.Ceiling(maskLen / (double)hLen); i++)
|
||||||
{
|
{
|
||||||
byte[] c = BitConverter.GetBytes(i);
|
byte[] c = BitConverter.GetBytes(i);
|
||||||
Array.Reverse(c);
|
Array.Reverse(c);
|
||||||
byte[] digest = hobj.ComputeHash(seed.Concat(c).ToArray());
|
byte[] digest = hobj.ComputeHash(seed.Concat(c).ToArray());
|
||||||
T.AddRange(digest);
|
T.AddRange(digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return T.GetRange(0, maskLen).ToArray();
|
return T.GetRange(0, maskLen).ToArray();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using OF_DL.Utils;
|
using OF_DL.Utils;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Archived
|
namespace OF_DL.Entities.Archived;
|
||||||
|
|
||||||
|
public class Archived
|
||||||
{
|
{
|
||||||
public class Archived
|
|
||||||
{
|
|
||||||
public List<List> list { get; set; }
|
public List<List> list { get; set; }
|
||||||
public bool hasMore { get; set; }
|
public bool hasMore { get; set; }
|
||||||
public string headMarker { get; set; }
|
public string headMarker { get; set; }
|
||||||
public string tailMarker { get; set; }
|
public string tailMarker { get; set; }
|
||||||
public Counters counters { get; set; }
|
public Counters counters { get; set; }
|
||||||
|
|
||||||
public class Author
|
public class Author
|
||||||
{
|
{
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
@ -29,11 +30,9 @@ namespace OF_DL.Entities.Archived
|
|||||||
|
|
||||||
public class Dash
|
public class Dash
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
@ -81,11 +80,9 @@ namespace OF_DL.Entities.Archived
|
|||||||
|
|
||||||
public class Hls
|
public class Hls
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
@ -99,6 +96,7 @@ namespace OF_DL.Entities.Archived
|
|||||||
|
|
||||||
public class LinkedPost
|
public class LinkedPost
|
||||||
{
|
{
|
||||||
|
private string _rawText;
|
||||||
public string responseType { get; set; }
|
public string responseType { get; set; }
|
||||||
public long? id { get; set; }
|
public long? id { get; set; }
|
||||||
public DateTime? postedAt { get; set; }
|
public DateTime? postedAt { get; set; }
|
||||||
@ -106,7 +104,7 @@ namespace OF_DL.Entities.Archived
|
|||||||
public object expiredAt { get; set; }
|
public object expiredAt { get; set; }
|
||||||
public Author author { get; set; }
|
public Author author { get; set; }
|
||||||
public string text { get; set; }
|
public string text { get; set; }
|
||||||
private string _rawText;
|
|
||||||
public string rawText
|
public string rawText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -118,11 +116,9 @@ namespace OF_DL.Entities.Archived
|
|||||||
|
|
||||||
return _rawText;
|
return _rawText;
|
||||||
}
|
}
|
||||||
set
|
set => _rawText = value;
|
||||||
{
|
|
||||||
_rawText = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool? lockedText { get; set; }
|
public bool? lockedText { get; set; }
|
||||||
public bool? isFavorite { get; set; }
|
public bool? isFavorite { get; set; }
|
||||||
public bool? canReport { get; set; }
|
public bool? canReport { get; set; }
|
||||||
@ -156,6 +152,7 @@ namespace OF_DL.Entities.Archived
|
|||||||
|
|
||||||
public class List
|
public class List
|
||||||
{
|
{
|
||||||
|
private string _rawText;
|
||||||
public string responseType { get; set; }
|
public string responseType { get; set; }
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
public DateTime postedAt { get; set; }
|
public DateTime postedAt { get; set; }
|
||||||
@ -163,7 +160,7 @@ namespace OF_DL.Entities.Archived
|
|||||||
public object expiredAt { get; set; }
|
public object expiredAt { get; set; }
|
||||||
public Author author { get; set; }
|
public Author author { get; set; }
|
||||||
public string text { get; set; }
|
public string text { get; set; }
|
||||||
private string _rawText;
|
|
||||||
public string rawText
|
public string rawText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -175,11 +172,9 @@ namespace OF_DL.Entities.Archived
|
|||||||
|
|
||||||
return _rawText;
|
return _rawText;
|
||||||
}
|
}
|
||||||
set
|
set => _rawText = value;
|
||||||
{
|
|
||||||
_rawText = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool? lockedText { get; set; }
|
public bool? lockedText { get; set; }
|
||||||
public bool? isFavorite { get; set; }
|
public bool? isFavorite { get; set; }
|
||||||
public bool? canReport { get; set; }
|
public bool? canReport { get; set; }
|
||||||
@ -260,11 +255,8 @@ namespace OF_DL.Entities.Archived
|
|||||||
|
|
||||||
public class VideoSources
|
public class VideoSources
|
||||||
{
|
{
|
||||||
[JsonProperty("720")]
|
[JsonProperty("720")] public string _720 { get; set; }
|
||||||
public string _720 { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("240")]
|
[JsonProperty("240")] public string _240 { get; set; }
|
||||||
public string _240 { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
namespace OF_DL.Entities.Archived
|
namespace OF_DL.Entities.Archived;
|
||||||
|
|
||||||
|
public class ArchivedCollection
|
||||||
{
|
{
|
||||||
public class ArchivedCollection
|
public List<Archived.Medium> ArchivedPostMedia = new();
|
||||||
{
|
public List<Archived.List> ArchivedPostObjects = new();
|
||||||
public Dictionary<long, string> ArchivedPosts = new Dictionary<long, string>();
|
public Dictionary<long, string> ArchivedPosts = new();
|
||||||
public List<Archived.List> ArchivedPostObjects = new List<Archived.List>();
|
|
||||||
public List<Archived.Medium> ArchivedPostMedia = new List<Archived.Medium>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public class Auth
|
||||||
{
|
{
|
||||||
public class Auth
|
|
||||||
{
|
|
||||||
public string? USER_ID { get; set; } = string.Empty;
|
public string? USER_ID { get; set; } = string.Empty;
|
||||||
public string? USER_AGENT { get; set; } = string.Empty;
|
public string? USER_AGENT { get; set; } = string.Empty;
|
||||||
public string? X_BC { get; set; } = string.Empty;
|
public string? X_BC { get; set; } = string.Empty;
|
||||||
public string? COOKIE { get; set; } = string.Empty;
|
public string? COOKIE { get; set; } = string.Empty;
|
||||||
[JsonIgnore]
|
|
||||||
public string? FFMPEG_PATH { get; set; } = string.Empty;
|
[JsonIgnore] public string? FFMPEG_PATH { get; set; } = string.Empty;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,22 +1,16 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public class CDRMProjectRequest
|
||||||
{
|
{
|
||||||
public class CDRMProjectRequest
|
[JsonProperty("pssh")] public string PSSH { get; set; } = "";
|
||||||
{
|
|
||||||
[JsonProperty("pssh")]
|
|
||||||
public string PSSH { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonProperty("licurl")]
|
[JsonProperty("licurl")] public string LicenseURL { get; set; } = "";
|
||||||
public string LicenseURL { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonProperty("headers")]
|
[JsonProperty("headers")] public string Headers { get; set; } = "";
|
||||||
public string Headers { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonProperty("cookies")]
|
[JsonProperty("cookies")] public string Cookies { get; set; } = "";
|
||||||
public string Cookies { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonProperty("data")]
|
[JsonProperty("data")] public string Data { get; set; } = "";
|
||||||
public string Data { get; set; } = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,65 +3,60 @@ using Newtonsoft.Json.Converters;
|
|||||||
using OF_DL.Enumerations;
|
using OF_DL.Enumerations;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
{
|
|
||||||
|
|
||||||
public class Config : IFileNameFormatConfig
|
public class Config : IFileNameFormatConfig
|
||||||
{
|
{
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadAvatarHeaderPhoto { get; set; } = true;
|
||||||
public bool DownloadAvatarHeaderPhoto { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadPaidPosts { get; set; } = true;
|
||||||
public bool DownloadPaidPosts { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadPosts { get; set; } = true;
|
||||||
public bool DownloadPosts { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadArchived { get; set; } = true;
|
||||||
public bool DownloadArchived { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadStreams { get; set; } = true;
|
||||||
public bool DownloadStreams { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadStories { get; set; } = true;
|
||||||
public bool DownloadStories { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadHighlights { get; set; } = true;
|
||||||
public bool DownloadHighlights { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadMessages { get; set; } = true;
|
||||||
public bool DownloadMessages { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadPaidMessages { get; set; } = true;
|
||||||
public bool DownloadPaidMessages { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadImages { get; set; } = true;
|
||||||
public bool DownloadImages { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadVideos { get; set; } = true;
|
||||||
public bool DownloadVideos { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadAudios { get; set; } = true;
|
||||||
public bool DownloadAudios { get; set; } = true;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool IncludeExpiredSubscriptions { get; set; } = false;
|
||||||
public bool IncludeExpiredSubscriptions { get; set; } = false;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool IncludeRestrictedSubscriptions { get; set; } = false;
|
||||||
public bool IncludeRestrictedSubscriptions { get; set; } = false;
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool SkipAds { get; set; } = false;
|
||||||
public bool SkipAds { get; set; } = false;
|
|
||||||
|
|
||||||
public string? DownloadPath { get; set; } = string.Empty;
|
public string? DownloadPath { get; set; } = string.Empty;
|
||||||
public string? PaidPostFileNameFormat { get; set; } = string.Empty;
|
|
||||||
public string? PostFileNameFormat { get; set; } = string.Empty;
|
[ToggleableConfig] public bool RenameExistingFilesWhenCustomFormatIsSelected { get; set; } = false;
|
||||||
public string? PaidMessageFileNameFormat { get; set; } = string.Empty;
|
|
||||||
public string? MessageFileNameFormat { get; set; } = string.Empty;
|
|
||||||
[ToggleableConfig]
|
|
||||||
public bool RenameExistingFilesWhenCustomFormatIsSelected { get; set; } = false;
|
|
||||||
public int? Timeout { get; set; } = -1;
|
public int? Timeout { get; set; } = -1;
|
||||||
[ToggleableConfig]
|
|
||||||
public bool FolderPerPaidPost { get; set; } = false;
|
[ToggleableConfig] public bool FolderPerPaidPost { get; set; } = false;
|
||||||
[ToggleableConfig]
|
|
||||||
public bool FolderPerPost { get; set; } = false;
|
[ToggleableConfig] public bool FolderPerPost { get; set; } = false;
|
||||||
[ToggleableConfig]
|
|
||||||
public bool FolderPerPaidMessage { get; set; } = false;
|
[ToggleableConfig] public bool FolderPerPaidMessage { get; set; } = false;
|
||||||
[ToggleableConfig]
|
|
||||||
public bool FolderPerMessage { get; set; } = false;
|
[ToggleableConfig] public bool FolderPerMessage { get; set; } = false;
|
||||||
[ToggleableConfig]
|
|
||||||
public bool LimitDownloadRate { get; set; } = false;
|
[ToggleableConfig] public bool LimitDownloadRate { get; set; } = false;
|
||||||
|
|
||||||
public int DownloadLimitInMbPerSec { get; set; } = 4;
|
public int DownloadLimitInMbPerSec { get; set; } = 4;
|
||||||
|
|
||||||
// Indicates if you want to download only on specific dates.
|
// Indicates if you want to download only on specific dates.
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadOnlySpecificDates { get; set; } = false;
|
||||||
public bool DownloadOnlySpecificDates { get; set; } = false;
|
|
||||||
|
|
||||||
// This enum will define if we want data from before or after the CustomDate.
|
// This enum will define if we want data from before or after the CustomDate.
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
@ -71,57 +66,58 @@ namespace OF_DL.Entities
|
|||||||
[JsonConverter(typeof(ShortDateConverter))]
|
[JsonConverter(typeof(ShortDateConverter))]
|
||||||
public DateTime? CustomDate { get; set; } = null;
|
public DateTime? CustomDate { get; set; } = null;
|
||||||
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool ShowScrapeSize { get; set; } = false;
|
||||||
public bool ShowScrapeSize { get; set; } = false;
|
|
||||||
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadPostsIncrementally { get; set; } = false;
|
||||||
public bool DownloadPostsIncrementally { get; set; } = false;
|
|
||||||
|
|
||||||
public bool NonInteractiveMode { get; set; } = false;
|
public bool NonInteractiveMode { get; set; } = false;
|
||||||
public string NonInteractiveModeListName { get; set; } = string.Empty;
|
public string NonInteractiveModeListName { get; set; } = string.Empty;
|
||||||
[ToggleableConfig]
|
|
||||||
public bool NonInteractiveModePurchasedTab { get; set; } = false;
|
[ToggleableConfig] public bool NonInteractiveModePurchasedTab { get; set; } = false;
|
||||||
|
|
||||||
public string? FFmpegPath { get; set; } = string.Empty;
|
public string? FFmpegPath { get; set; } = string.Empty;
|
||||||
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool BypassContentForCreatorsWhoNoLongerExist { get; set; } = false;
|
||||||
public bool BypassContentForCreatorsWhoNoLongerExist { get; set; } = false;
|
|
||||||
|
|
||||||
public Dictionary<string, CreatorConfig> CreatorConfigs { get; set; } = new Dictionary<string, CreatorConfig>();
|
public Dictionary<string, CreatorConfig> CreatorConfigs { get; set; } = new();
|
||||||
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DownloadDuplicatedMedia { get; set; } = false;
|
||||||
public bool DownloadDuplicatedMedia { get; set; } = false;
|
|
||||||
|
|
||||||
public string IgnoredUsersListName { get; set; } = string.Empty;
|
public string IgnoredUsersListName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public LoggingLevel LoggingLevel { get; set; } = LoggingLevel.Error;
|
public LoggingLevel LoggingLevel { get; set; } = LoggingLevel.Error;
|
||||||
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool IgnoreOwnMessages { get; set; } = false;
|
||||||
public bool IgnoreOwnMessages { get; set; } = false;
|
|
||||||
|
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DisableBrowserAuth { get; set; } = false;
|
||||||
public bool DisableBrowserAuth { get; set; } = false;
|
|
||||||
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public VideoResolution DownloadVideoResolution { get; set; } = VideoResolution.source;
|
public VideoResolution DownloadVideoResolution { get; set; } = VideoResolution.source;
|
||||||
|
|
||||||
// When enabled, post/message text is stored as-is without XML stripping.
|
// When enabled, post/message text is stored as-is without XML stripping.
|
||||||
[ToggleableConfig]
|
[ToggleableConfig] public bool DisableTextSanitization { get; set; } = false;
|
||||||
public bool DisableTextSanitization { get; set; } = false;
|
|
||||||
|
public string? PaidPostFileNameFormat { get; set; } = string.Empty;
|
||||||
|
public string? PostFileNameFormat { get; set; } = string.Empty;
|
||||||
|
public string? PaidMessageFileNameFormat { get; set; } = string.Empty;
|
||||||
|
public string? MessageFileNameFormat { get; set; } = string.Empty;
|
||||||
|
|
||||||
public IFileNameFormatConfig GetCreatorFileNameFormatConfig(string username)
|
public IFileNameFormatConfig GetCreatorFileNameFormatConfig(string username)
|
||||||
{
|
{
|
||||||
FileNameFormatConfig createFileNameFormatConfig = new FileNameFormatConfig();
|
FileNameFormatConfig createFileNameFormatConfig = new();
|
||||||
|
|
||||||
Func<string?, string?, string?> func = (val1, val2) =>
|
Func<string?, string?, string?> func = (val1, val2) =>
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(val1))
|
if (string.IsNullOrEmpty(val1))
|
||||||
|
{
|
||||||
return val2;
|
return val2;
|
||||||
else
|
}
|
||||||
|
|
||||||
return val1;
|
return val1;
|
||||||
};
|
};
|
||||||
|
|
||||||
if(CreatorConfigs.TryGetValue(username, out CreatorConfig? creatorConfig))
|
if (CreatorConfigs.TryGetValue(username, out CreatorConfig? creatorConfig))
|
||||||
{
|
{
|
||||||
createFileNameFormatConfig.PaidMessageFileNameFormat = creatorConfig.PaidMessageFileNameFormat;
|
createFileNameFormatConfig.PaidMessageFileNameFormat = creatorConfig.PaidMessageFileNameFormat;
|
||||||
createFileNameFormatConfig.PostFileNameFormat = creatorConfig.PostFileNameFormat;
|
createFileNameFormatConfig.PostFileNameFormat = creatorConfig.PostFileNameFormat;
|
||||||
@ -129,26 +125,32 @@ namespace OF_DL.Entities
|
|||||||
createFileNameFormatConfig.PaidPostFileNameFormat = creatorConfig.PaidPostFileNameFormat;
|
createFileNameFormatConfig.PaidPostFileNameFormat = creatorConfig.PaidPostFileNameFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
createFileNameFormatConfig.PaidMessageFileNameFormat = func(createFileNameFormatConfig.PaidMessageFileNameFormat, PaidMessageFileNameFormat);
|
createFileNameFormatConfig.PaidMessageFileNameFormat =
|
||||||
createFileNameFormatConfig.PostFileNameFormat = func(createFileNameFormatConfig.PostFileNameFormat, PostFileNameFormat);
|
func(createFileNameFormatConfig.PaidMessageFileNameFormat, PaidMessageFileNameFormat);
|
||||||
createFileNameFormatConfig.MessageFileNameFormat = func(createFileNameFormatConfig.MessageFileNameFormat, MessageFileNameFormat);
|
createFileNameFormatConfig.PostFileNameFormat =
|
||||||
createFileNameFormatConfig.PaidPostFileNameFormat = func(createFileNameFormatConfig.PaidPostFileNameFormat, PaidPostFileNameFormat);
|
func(createFileNameFormatConfig.PostFileNameFormat, PostFileNameFormat);
|
||||||
|
createFileNameFormatConfig.MessageFileNameFormat =
|
||||||
|
func(createFileNameFormatConfig.MessageFileNameFormat, MessageFileNameFormat);
|
||||||
|
createFileNameFormatConfig.PaidPostFileNameFormat =
|
||||||
|
func(createFileNameFormatConfig.PaidPostFileNameFormat, PaidPostFileNameFormat);
|
||||||
|
|
||||||
Log.Debug("PaidMessageFilenameFormat: {CombinedConfigPaidMessageFileNameFormat}", createFileNameFormatConfig.PaidMessageFileNameFormat);
|
Log.Debug("PaidMessageFilenameFormat: {CombinedConfigPaidMessageFileNameFormat}",
|
||||||
Log.Debug("PostFileNameFormat: {CombinedConfigPostFileNameFormat}", createFileNameFormatConfig.PostFileNameFormat);
|
createFileNameFormatConfig.PaidMessageFileNameFormat);
|
||||||
Log.Debug("MessageFileNameFormat: {CombinedConfigMessageFileNameFormat}", createFileNameFormatConfig.MessageFileNameFormat);
|
Log.Debug("PostFileNameFormat: {CombinedConfigPostFileNameFormat}",
|
||||||
Log.Debug("PaidPostFileNameFormat: {CombinedConfigPaidPostFileNameFormat}", createFileNameFormatConfig.PaidPostFileNameFormat);
|
createFileNameFormatConfig.PostFileNameFormat);
|
||||||
|
Log.Debug("MessageFileNameFormat: {CombinedConfigMessageFileNameFormat}",
|
||||||
|
createFileNameFormatConfig.MessageFileNameFormat);
|
||||||
|
Log.Debug("PaidPostFileNameFormat: {CombinedConfigPaidPostFileNameFormat}",
|
||||||
|
createFileNameFormatConfig.PaidPostFileNameFormat);
|
||||||
|
|
||||||
return createFileNameFormatConfig;
|
return createFileNameFormatConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CreatorConfig : IFileNameFormatConfig
|
public class CreatorConfig : IFileNameFormatConfig
|
||||||
{
|
{
|
||||||
public string? PaidPostFileNameFormat { get; set; }
|
public string? PaidPostFileNameFormat { get; set; }
|
||||||
public string? PostFileNameFormat { get; set; }
|
public string? PostFileNameFormat { get; set; }
|
||||||
public string? PaidMessageFileNameFormat { get; set; }
|
public string? PaidMessageFileNameFormat { get; set; }
|
||||||
public string? MessageFileNameFormat { get; set; }
|
public string? MessageFileNameFormat { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,28 +1,30 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public class DynamicRules
|
||||||
{
|
{
|
||||||
public class DynamicRules
|
[JsonProperty(PropertyName = "app-token")]
|
||||||
{
|
|
||||||
[JsonProperty(PropertyName="app-token")]
|
|
||||||
public string? AppToken { get; set; }
|
public string? AppToken { get; set; }
|
||||||
|
|
||||||
[JsonProperty(PropertyName="app_token")]
|
[JsonProperty(PropertyName = "app_token")]
|
||||||
private string AppToken2 { set { AppToken = value; } }
|
private string AppToken2
|
||||||
|
{
|
||||||
|
set => AppToken = value;
|
||||||
|
}
|
||||||
|
|
||||||
[JsonProperty(PropertyName="static_param")]
|
[JsonProperty(PropertyName = "static_param")]
|
||||||
public string? StaticParam { get; set; }
|
public string? StaticParam { get; set; }
|
||||||
|
|
||||||
[JsonProperty(PropertyName="prefix")]
|
[JsonProperty(PropertyName = "prefix")]
|
||||||
public string? Prefix { get; set; }
|
public string? Prefix { get; set; }
|
||||||
|
|
||||||
[JsonProperty(PropertyName="suffix")]
|
[JsonProperty(PropertyName = "suffix")]
|
||||||
public string? Suffix { get; set; }
|
public string? Suffix { get; set; }
|
||||||
|
|
||||||
[JsonProperty(PropertyName="checksum_constant")]
|
[JsonProperty(PropertyName = "checksum_constant")]
|
||||||
public int? ChecksumConstant { get; set; }
|
public int? ChecksumConstant { get; set; }
|
||||||
|
|
||||||
[JsonProperty(PropertyName = "checksum_indexes")]
|
[JsonProperty(PropertyName = "checksum_indexes")]
|
||||||
public List<int> ChecksumIndexes { get; set; }
|
public List<int> ChecksumIndexes { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public class FileNameFormatConfig : IFileNameFormatConfig
|
||||||
{
|
{
|
||||||
public class FileNameFormatConfig : IFileNameFormatConfig
|
|
||||||
{
|
|
||||||
public string? PaidPostFileNameFormat { get; set; }
|
public string? PaidPostFileNameFormat { get; set; }
|
||||||
public string? PostFileNameFormat { get; set; }
|
public string? PostFileNameFormat { get; set; }
|
||||||
public string? PaidMessageFileNameFormat { get; set; }
|
public string? PaidMessageFileNameFormat { get; set; }
|
||||||
public string? MessageFileNameFormat { get; set; }
|
public string? MessageFileNameFormat { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Highlights
|
namespace OF_DL.Entities.Highlights;
|
||||||
|
|
||||||
|
public class HighlightMedia
|
||||||
{
|
{
|
||||||
public class HighlightMedia
|
|
||||||
{
|
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
public long userId { get; set; }
|
public long userId { get; set; }
|
||||||
public string title { get; set; }
|
public string title { get; set; }
|
||||||
@ -12,6 +12,7 @@ namespace OF_DL.Entities.Highlights
|
|||||||
public int storiesCount { get; set; }
|
public int storiesCount { get; set; }
|
||||||
public DateTime? createdAt { get; set; }
|
public DateTime? createdAt { get; set; }
|
||||||
public List<Story> stories { get; set; }
|
public List<Story> stories { get; set; }
|
||||||
|
|
||||||
public class Files
|
public class Files
|
||||||
{
|
{
|
||||||
public Full full { get; set; }
|
public Full full { get; set; }
|
||||||
@ -61,11 +62,10 @@ namespace OF_DL.Entities.Highlights
|
|||||||
|
|
||||||
public class Sources
|
public class Sources
|
||||||
{
|
{
|
||||||
[JsonProperty("720")]
|
[JsonProperty("720")] public string _720 { get; set; }
|
||||||
public string _720 { get; set; }
|
|
||||||
|
[JsonProperty("240")] public string _240 { get; set; }
|
||||||
|
|
||||||
[JsonProperty("240")]
|
|
||||||
public string _240 { get; set; }
|
|
||||||
public string w150 { get; set; }
|
public string w150 { get; set; }
|
||||||
public string w480 { get; set; }
|
public string w480 { get; set; }
|
||||||
}
|
}
|
||||||
@ -99,5 +99,4 @@ namespace OF_DL.Entities.Highlights
|
|||||||
public int height { get; set; }
|
public int height { get; set; }
|
||||||
public long size { get; set; }
|
public long size { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
namespace OF_DL.Entities.Highlights
|
namespace OF_DL.Entities.Highlights;
|
||||||
|
|
||||||
|
public class Highlights
|
||||||
{
|
{
|
||||||
public class Highlights
|
|
||||||
{
|
|
||||||
public List<List> list { get; set; }
|
public List<List> list { get; set; }
|
||||||
public bool hasMore { get; set; }
|
public bool hasMore { get; set; }
|
||||||
|
|
||||||
public class List
|
public class List
|
||||||
{
|
{
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
@ -14,5 +15,4 @@ namespace OF_DL.Entities.Highlights
|
|||||||
public int storiesCount { get; set; }
|
public int storiesCount { get; set; }
|
||||||
public DateTime? createdAt { get; set; }
|
public DateTime? createdAt { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public interface IFileNameFormatConfig
|
||||||
{
|
{
|
||||||
public interface IFileNameFormatConfig
|
|
||||||
{
|
|
||||||
string? PaidPostFileNameFormat { get; set; }
|
string? PaidPostFileNameFormat { get; set; }
|
||||||
string? PostFileNameFormat { get; set; }
|
string? PostFileNameFormat { get; set; }
|
||||||
string? PaidMessageFileNameFormat { get; set; }
|
string? PaidMessageFileNameFormat { get; set; }
|
||||||
string? MessageFileNameFormat { get; set; }
|
string? MessageFileNameFormat { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
namespace OF_DL.Entities.Lists
|
namespace OF_DL.Entities.Lists;
|
||||||
|
|
||||||
|
public class UserList
|
||||||
{
|
{
|
||||||
public class UserList
|
|
||||||
{
|
|
||||||
public List<List> list { get; set; }
|
public List<List> list { get; set; }
|
||||||
public bool? hasMore { get; set; }
|
public bool? hasMore { get; set; }
|
||||||
|
|
||||||
public class List
|
public class List
|
||||||
{
|
{
|
||||||
public string id { get; set; }
|
public string id { get; set; }
|
||||||
@ -31,5 +32,4 @@
|
|||||||
public long? id { get; set; }
|
public long? id { get; set; }
|
||||||
public string _view { get; set; }
|
public string _view { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
namespace OF_DL.Entities.Lists
|
namespace OF_DL.Entities.Lists;
|
||||||
|
|
||||||
|
public class UsersList
|
||||||
{
|
{
|
||||||
public class UsersList
|
|
||||||
{
|
|
||||||
public string view { get; set; }
|
public string view { get; set; }
|
||||||
public string avatar { get; set; }
|
public string avatar { get; set; }
|
||||||
public AvatarThumbs avatarThumbs { get; set; }
|
public AvatarThumbs avatarThumbs { get; set; }
|
||||||
@ -56,6 +56,7 @@ namespace OF_DL.Entities.Lists
|
|||||||
public bool? canTrialSend { get; set; }
|
public bool? canTrialSend { get; set; }
|
||||||
public bool? isBlocked { get; set; }
|
public bool? isBlocked { get; set; }
|
||||||
public List<object> promoOffers { get; set; }
|
public List<object> promoOffers { get; set; }
|
||||||
|
|
||||||
public class AvatarThumbs
|
public class AvatarThumbs
|
||||||
{
|
{
|
||||||
public string c50 { get; set; }
|
public string c50 { get; set; }
|
||||||
@ -160,6 +161,4 @@ namespace OF_DL.Entities.Lists
|
|||||||
public string? price { get; set; }
|
public string? price { get; set; }
|
||||||
public bool? canBuy { get; set; }
|
public bool? canBuy { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
namespace OF_DL.Entities.Messages
|
namespace OF_DL.Entities.Messages;
|
||||||
|
|
||||||
|
public class MessageCollection
|
||||||
{
|
{
|
||||||
public class MessageCollection
|
public List<Messages.Medium> MessageMedia = new();
|
||||||
{
|
public List<Messages.List> MessageObjects = new();
|
||||||
public Dictionary<long, string> Messages = new Dictionary<long, string>();
|
public Dictionary<long, string> Messages = new();
|
||||||
public List<Messages.List> MessageObjects = new List<Messages.List>();
|
|
||||||
public List<Messages.Medium> MessageMedia = new List<Messages.Medium>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,17 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Messages
|
namespace OF_DL.Entities.Messages;
|
||||||
|
|
||||||
|
public class Messages
|
||||||
{
|
{
|
||||||
public class Messages
|
|
||||||
{
|
|
||||||
public List<List> list { get; set; }
|
public List<List> list { get; set; }
|
||||||
public bool hasMore { get; set; }
|
public bool hasMore { get; set; }
|
||||||
|
|
||||||
public class Dash
|
public class Dash
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
@ -66,11 +65,9 @@ namespace OF_DL.Entities.Messages
|
|||||||
|
|
||||||
public class Hls
|
public class Hls
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
@ -169,11 +166,8 @@ namespace OF_DL.Entities.Messages
|
|||||||
|
|
||||||
public class VideoSources
|
public class VideoSources
|
||||||
{
|
{
|
||||||
[JsonProperty("720")]
|
[JsonProperty("720")] public string _720 { get; set; }
|
||||||
public string _720 { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("240")]
|
[JsonProperty("240")] public string _240 { get; set; }
|
||||||
public string _240 { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
using static OF_DL.Entities.Messages.Messages;
|
using static OF_DL.Entities.Messages.Messages;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Messages
|
namespace OF_DL.Entities.Messages;
|
||||||
|
|
||||||
|
public class AvatarThumbs
|
||||||
{
|
{
|
||||||
public class AvatarThumbs
|
|
||||||
{
|
|
||||||
public string c50 { get; set; }
|
public string c50 { get; set; }
|
||||||
public string c144 { get; set; }
|
public string c144 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FromUser
|
public class FromUser
|
||||||
{
|
{
|
||||||
public string view { get; set; }
|
public string view { get; set; }
|
||||||
public string avatar { get; set; }
|
public string avatar { get; set; }
|
||||||
public AvatarThumbs avatarThumbs { get; set; }
|
public AvatarThumbs avatarThumbs { get; set; }
|
||||||
@ -52,39 +52,39 @@ namespace OF_DL.Entities.Messages
|
|||||||
public int callPrice { get; set; }
|
public int callPrice { get; set; }
|
||||||
public DateTime? lastSeen { get; set; }
|
public DateTime? lastSeen { get; set; }
|
||||||
public bool canReport { get; set; }
|
public bool canReport { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HeaderSize
|
public class HeaderSize
|
||||||
{
|
{
|
||||||
public int width { get; set; }
|
public int width { get; set; }
|
||||||
public int height { get; set; }
|
public int height { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HeaderThumbs
|
public class HeaderThumbs
|
||||||
{
|
{
|
||||||
public string w480 { get; set; }
|
public string w480 { get; set; }
|
||||||
public string w760 { get; set; }
|
public string w760 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ListsState
|
public class ListsState
|
||||||
{
|
{
|
||||||
public string id { get; set; }
|
public string id { get; set; }
|
||||||
public string type { get; set; }
|
public string type { get; set; }
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
public bool hasUser { get; set; }
|
public bool hasUser { get; set; }
|
||||||
public bool canAddUser { get; set; }
|
public bool canAddUser { get; set; }
|
||||||
public string cannotAddUserReason { get; set; }
|
public string cannotAddUserReason { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Preview
|
public class Preview
|
||||||
{
|
{
|
||||||
public int width { get; set; }
|
public int width { get; set; }
|
||||||
public int height { get; set; }
|
public int height { get; set; }
|
||||||
public long size { get; set; }
|
public long size { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SingleMessage
|
public class SingleMessage
|
||||||
{
|
{
|
||||||
public string responseType { get; set; }
|
public string responseType { get; set; }
|
||||||
public string text { get; set; }
|
public string text { get; set; }
|
||||||
public object giphyId { get; set; }
|
public object giphyId { get; set; }
|
||||||
@ -112,7 +112,4 @@ namespace OF_DL.Entities.Messages
|
|||||||
public bool isLiked { get; set; }
|
public bool isLiked { get; set; }
|
||||||
public bool canPurchase { get; set; }
|
public bool canPurchase { get; set; }
|
||||||
public bool canReport { get; set; }
|
public bool canReport { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,12 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public class OFDLRequest
|
||||||
{
|
{
|
||||||
public class OFDLRequest
|
[JsonProperty("pssh")] public string PSSH { get; set; } = "";
|
||||||
{
|
|
||||||
[JsonProperty("pssh")]
|
|
||||||
public string PSSH { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonProperty("licenceURL")]
|
[JsonProperty("licenceURL")] public string LicenseURL { get; set; } = "";
|
||||||
public string LicenseURL { get; set; } = "";
|
|
||||||
|
|
||||||
[JsonProperty("headers")]
|
[JsonProperty("headers")] public string Headers { get; set; } = "";
|
||||||
public string Headers { get; set; } = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ public class Post
|
|||||||
public string headMarker { get; set; }
|
public string headMarker { get; set; }
|
||||||
|
|
||||||
public string tailMarker { get; set; }
|
public string tailMarker { get; set; }
|
||||||
|
|
||||||
public class Author
|
public class Author
|
||||||
{
|
{
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
@ -20,11 +21,9 @@ public class Post
|
|||||||
|
|
||||||
public class Dash
|
public class Dash
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
@ -72,11 +71,9 @@ public class Post
|
|||||||
|
|
||||||
public class Hls
|
public class Hls
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
@ -90,6 +87,7 @@ public class Post
|
|||||||
|
|
||||||
public class List
|
public class List
|
||||||
{
|
{
|
||||||
|
private string _rawText;
|
||||||
public string responseType { get; set; }
|
public string responseType { get; set; }
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
public DateTime postedAt { get; set; }
|
public DateTime postedAt { get; set; }
|
||||||
@ -98,23 +96,20 @@ public class Post
|
|||||||
public Author author { get; set; }
|
public Author author { get; set; }
|
||||||
public string text { get; set; }
|
public string text { get; set; }
|
||||||
|
|
||||||
private string _rawText;
|
|
||||||
public string rawText
|
public string rawText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(_rawText))
|
if (string.IsNullOrEmpty(_rawText))
|
||||||
{
|
{
|
||||||
_rawText = XmlUtils.EvaluateInnerText(text);
|
_rawText = XmlUtils.EvaluateInnerText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _rawText;
|
return _rawText;
|
||||||
}
|
}
|
||||||
set
|
set => _rawText = value;
|
||||||
{
|
|
||||||
_rawText = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool? lockedText { get; set; }
|
public bool? lockedText { get; set; }
|
||||||
public bool? isFavorite { get; set; }
|
public bool? isFavorite { get; set; }
|
||||||
public bool? canReport { get; set; }
|
public bool? canReport { get; set; }
|
||||||
@ -197,11 +192,9 @@ public class Post
|
|||||||
|
|
||||||
public class VideoSources
|
public class VideoSources
|
||||||
{
|
{
|
||||||
[JsonProperty("720")]
|
[JsonProperty("720")] public object _720 { get; set; }
|
||||||
public object _720 { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("240")]
|
[JsonProperty("240")] public object _240 { get; set; }
|
||||||
public object _240 { get; set; }
|
|
||||||
}
|
}
|
||||||
#pragma warning restore IDE1006 // Naming Styles
|
#pragma warning restore IDE1006 // Naming Styles
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
namespace OF_DL.Entities.Post
|
namespace OF_DL.Entities.Post;
|
||||||
|
|
||||||
|
public class PostCollection
|
||||||
{
|
{
|
||||||
public class PostCollection
|
public List<Post.Medium> PostMedia = new();
|
||||||
{
|
public List<Post.List> PostObjects = new();
|
||||||
public Dictionary<long, string> Posts = new Dictionary<long, string>();
|
public Dictionary<long, string> Posts = new();
|
||||||
public List<Post.List> PostObjects = new List<Post.List>();
|
|
||||||
public List<Post.Medium> PostMedia = new List<Post.Medium>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using OF_DL.Utils;
|
using OF_DL.Utils;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Post
|
namespace OF_DL.Entities.Post;
|
||||||
|
|
||||||
|
public class SinglePost
|
||||||
{
|
{
|
||||||
public class SinglePost
|
private string _rawText;
|
||||||
{
|
|
||||||
public string responseType { get; set; }
|
public string responseType { get; set; }
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
public DateTime postedAt { get; set; }
|
public DateTime postedAt { get; set; }
|
||||||
@ -12,7 +13,7 @@ namespace OF_DL.Entities.Post
|
|||||||
public object expiredAt { get; set; }
|
public object expiredAt { get; set; }
|
||||||
public Author author { get; set; }
|
public Author author { get; set; }
|
||||||
public string text { get; set; }
|
public string text { get; set; }
|
||||||
private string _rawText;
|
|
||||||
public string rawText
|
public string rawText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -24,11 +25,9 @@ namespace OF_DL.Entities.Post
|
|||||||
|
|
||||||
return _rawText;
|
return _rawText;
|
||||||
}
|
}
|
||||||
set
|
set => _rawText = value;
|
||||||
{
|
|
||||||
_rawText = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool lockedText { get; set; }
|
public bool lockedText { get; set; }
|
||||||
public bool isFavorite { get; set; }
|
public bool isFavorite { get; set; }
|
||||||
public bool canReport { get; set; }
|
public bool canReport { get; set; }
|
||||||
@ -59,6 +58,7 @@ namespace OF_DL.Entities.Post
|
|||||||
public List<Medium> media { get; set; }
|
public List<Medium> media { get; set; }
|
||||||
public bool canViewMedia { get; set; }
|
public bool canViewMedia { get; set; }
|
||||||
public List<object> preview { get; set; }
|
public List<object> preview { get; set; }
|
||||||
|
|
||||||
public class Author
|
public class Author
|
||||||
{
|
{
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
@ -143,19 +143,16 @@ namespace OF_DL.Entities.Post
|
|||||||
|
|
||||||
public class VideoSources
|
public class VideoSources
|
||||||
{
|
{
|
||||||
[JsonProperty("720")]
|
[JsonProperty("720")] public string _720 { get; set; }
|
||||||
public string _720 { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("240")]
|
[JsonProperty("240")] public string _240 { get; set; }
|
||||||
public string _240 { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Dash
|
public class Dash
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
@ -166,26 +163,26 @@ namespace OF_DL.Entities.Post
|
|||||||
public Manifest manifest { get; set; }
|
public Manifest manifest { get; set; }
|
||||||
public Signature signature { get; set; }
|
public Signature signature { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Hls
|
public class Hls
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Manifest
|
public class Manifest
|
||||||
{
|
{
|
||||||
public string? hls { get; set; }
|
public string? hls { get; set; }
|
||||||
public string? dash { get; set; }
|
public string? dash { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Signature
|
public class Signature
|
||||||
{
|
{
|
||||||
public Hls hls { get; set; }
|
public Hls hls { get; set; }
|
||||||
public Dash dash { get; set; }
|
public Dash dash { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
namespace OF_DL.Entities.Post
|
namespace OF_DL.Entities.Post;
|
||||||
|
|
||||||
|
public class SinglePostCollection
|
||||||
{
|
{
|
||||||
public class SinglePostCollection
|
public List<SinglePost.Medium> SinglePostMedia = new();
|
||||||
{
|
public List<SinglePost> SinglePostObjects = new();
|
||||||
public Dictionary<long, string> SinglePosts = new Dictionary<long, string>();
|
public Dictionary<long, string> SinglePosts = new();
|
||||||
public List<SinglePost> SinglePostObjects = new List<SinglePost>();
|
|
||||||
public List<SinglePost.Medium> SinglePostMedia = new List<SinglePost.Medium>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
using static OF_DL.Entities.Messages.Messages;
|
using static OF_DL.Entities.Messages.Messages;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Purchased
|
namespace OF_DL.Entities.Purchased;
|
||||||
|
|
||||||
|
public class PaidMessageCollection
|
||||||
{
|
{
|
||||||
public class PaidMessageCollection
|
public List<Medium> PaidMessageMedia = new();
|
||||||
{
|
public List<Purchased.List> PaidMessageObjects = new();
|
||||||
public Dictionary<long, string> PaidMessages = new Dictionary<long, string>();
|
public Dictionary<long, string> PaidMessages = new();
|
||||||
public List<Purchased.List> PaidMessageObjects = new List<Purchased.List>();
|
|
||||||
public List<Medium> PaidMessageMedia = new List<Medium>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
using static OF_DL.Entities.Messages.Messages;
|
using static OF_DL.Entities.Messages.Messages;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Purchased
|
namespace OF_DL.Entities.Purchased;
|
||||||
|
|
||||||
|
public class PaidPostCollection
|
||||||
{
|
{
|
||||||
public class PaidPostCollection
|
public List<Medium> PaidPostMedia = new();
|
||||||
{
|
public List<Purchased.List> PaidPostObjects = new();
|
||||||
public Dictionary<long, string> PaidPosts = new Dictionary<long, string>();
|
public Dictionary<long, string> PaidPosts = new();
|
||||||
public List<Purchased.List> PaidPostObjects = new List<Purchased.List>();
|
|
||||||
public List<Medium> PaidPostMedia = new List<Medium>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using static OF_DL.Entities.Messages.Messages;
|
using static OF_DL.Entities.Messages.Messages;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Purchased
|
namespace OF_DL.Entities.Purchased;
|
||||||
|
|
||||||
|
public class Purchased
|
||||||
{
|
{
|
||||||
public class Purchased
|
|
||||||
{
|
|
||||||
public List<List> list { get; set; }
|
public List<List> list { get; set; }
|
||||||
public bool hasMore { get; set; }
|
public bool hasMore { get; set; }
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ namespace OF_DL.Entities.Purchased
|
|||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
public string _view { get; set; }
|
public string _view { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Author
|
public class Author
|
||||||
{
|
{
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
@ -21,11 +22,9 @@ namespace OF_DL.Entities.Purchased
|
|||||||
|
|
||||||
public class Hls
|
public class Hls
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
@ -73,5 +72,4 @@ namespace OF_DL.Entities.Purchased
|
|||||||
public string hls { get; set; }
|
public string hls { get; set; }
|
||||||
public string dash { get; set; }
|
public string dash { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
namespace OF_DL.Entities.Purchased
|
namespace OF_DL.Entities.Purchased;
|
||||||
|
|
||||||
|
public class PurchasedTabCollection
|
||||||
{
|
{
|
||||||
public class PurchasedTabCollection
|
|
||||||
{
|
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
public string Username { get; set; } = string.Empty;
|
public string Username { get; set; } = string.Empty;
|
||||||
public PaidPostCollection PaidPosts { get; set; } = new PaidPostCollection();
|
public PaidPostCollection PaidPosts { get; set; } = new();
|
||||||
public PaidMessageCollection PaidMessages { get; set; } = new PaidMessageCollection();
|
public PaidMessageCollection PaidMessages { get; set; } = new();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
using OF_DL.Entities.Messages;
|
using OF_DL.Entities.Messages;
|
||||||
using static OF_DL.Entities.Messages.Messages;
|
using static OF_DL.Entities.Messages.Messages;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Purchased
|
namespace OF_DL.Entities.Purchased;
|
||||||
{
|
|
||||||
public class SinglePaidMessageCollection
|
|
||||||
{
|
|
||||||
public Dictionary<long, string> SingleMessages = new Dictionary<long, string>();
|
|
||||||
public List<SingleMessage> SingleMessageObjects = new List<SingleMessage>();
|
|
||||||
public List<Medium> SingleMessageMedia = new List<Medium>();
|
|
||||||
|
|
||||||
public Dictionary<long, string> PreviewSingleMessages = new Dictionary<long, string>();
|
public class SinglePaidMessageCollection
|
||||||
public List<Medium> PreviewSingleMessageMedia = new List<Medium>();
|
{
|
||||||
}
|
public List<Medium> PreviewSingleMessageMedia = new();
|
||||||
|
|
||||||
|
public Dictionary<long, string> PreviewSingleMessages = new();
|
||||||
|
public List<Medium> SingleMessageMedia = new();
|
||||||
|
public List<SingleMessage> SingleMessageObjects = new();
|
||||||
|
public Dictionary<long, string> SingleMessages = new();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public class ShortDateConverter : IsoDateTimeConverter
|
||||||
{
|
{
|
||||||
public class ShortDateConverter : IsoDateTimeConverter
|
public ShortDateConverter() => DateTimeFormat = "yyyy-MM-dd";
|
||||||
{
|
|
||||||
public ShortDateConverter()
|
|
||||||
{
|
|
||||||
DateTimeFormat = "yyyy-MM-dd";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Stories
|
namespace OF_DL.Entities.Stories;
|
||||||
|
|
||||||
|
public class Stories
|
||||||
{
|
{
|
||||||
public class Stories
|
|
||||||
{
|
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
public long userId { get; set; }
|
public long userId { get; set; }
|
||||||
public bool isWatched { get; set; }
|
public bool isWatched { get; set; }
|
||||||
@ -13,6 +13,7 @@ namespace OF_DL.Entities.Stories
|
|||||||
public object question { get; set; }
|
public object question { get; set; }
|
||||||
public bool canLike { get; set; }
|
public bool canLike { get; set; }
|
||||||
public bool isLiked { get; set; }
|
public bool isLiked { get; set; }
|
||||||
|
|
||||||
public class Files
|
public class Files
|
||||||
{
|
{
|
||||||
public Full full { get; set; }
|
public Full full { get; set; }
|
||||||
@ -62,11 +63,10 @@ namespace OF_DL.Entities.Stories
|
|||||||
|
|
||||||
public class Sources
|
public class Sources
|
||||||
{
|
{
|
||||||
[JsonProperty("720")]
|
[JsonProperty("720")] public object _720 { get; set; }
|
||||||
public object _720 { get; set; }
|
|
||||||
|
[JsonProperty("240")] public object _240 { get; set; }
|
||||||
|
|
||||||
[JsonProperty("240")]
|
|
||||||
public object _240 { get; set; }
|
|
||||||
public string w150 { get; set; }
|
public string w150 { get; set; }
|
||||||
public string w480 { get; set; }
|
public string w480 { get; set; }
|
||||||
}
|
}
|
||||||
@ -87,5 +87,4 @@ namespace OF_DL.Entities.Stories
|
|||||||
public int height { get; set; }
|
public int height { get; set; }
|
||||||
public long size { get; set; }
|
public long size { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using OF_DL.Utils;
|
using OF_DL.Utils;
|
||||||
|
|
||||||
namespace OF_DL.Entities.Streams
|
namespace OF_DL.Entities.Streams;
|
||||||
|
|
||||||
|
public class Streams
|
||||||
{
|
{
|
||||||
public class Streams
|
|
||||||
{
|
|
||||||
public List<List> list { get; set; }
|
public List<List> list { get; set; }
|
||||||
public bool hasMore { get; set; }
|
public bool hasMore { get; set; }
|
||||||
public string headMarker { get; set; }
|
public string headMarker { get; set; }
|
||||||
public string tailMarker { get; set; }
|
public string tailMarker { get; set; }
|
||||||
public Counters counters { get; set; }
|
public Counters counters { get; set; }
|
||||||
|
|
||||||
public class Author
|
public class Author
|
||||||
{
|
{
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
@ -69,6 +70,7 @@ namespace OF_DL.Entities.Streams
|
|||||||
|
|
||||||
public class List
|
public class List
|
||||||
{
|
{
|
||||||
|
private string _rawText;
|
||||||
public string responseType { get; set; }
|
public string responseType { get; set; }
|
||||||
public long id { get; set; }
|
public long id { get; set; }
|
||||||
public DateTime postedAt { get; set; }
|
public DateTime postedAt { get; set; }
|
||||||
@ -76,7 +78,7 @@ namespace OF_DL.Entities.Streams
|
|||||||
public object expiredAt { get; set; }
|
public object expiredAt { get; set; }
|
||||||
public Author author { get; set; }
|
public Author author { get; set; }
|
||||||
public string text { get; set; }
|
public string text { get; set; }
|
||||||
private string _rawText;
|
|
||||||
public string rawText
|
public string rawText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -88,11 +90,9 @@ namespace OF_DL.Entities.Streams
|
|||||||
|
|
||||||
return _rawText;
|
return _rawText;
|
||||||
}
|
}
|
||||||
set
|
set => _rawText = value;
|
||||||
{
|
|
||||||
_rawText = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool lockedText { get; set; }
|
public bool lockedText { get; set; }
|
||||||
public bool isFavorite { get; set; }
|
public bool isFavorite { get; set; }
|
||||||
public bool canReport { get; set; }
|
public bool canReport { get; set; }
|
||||||
@ -164,48 +164,46 @@ namespace OF_DL.Entities.Streams
|
|||||||
|
|
||||||
public class VideoSources
|
public class VideoSources
|
||||||
{
|
{
|
||||||
[JsonProperty("720")]
|
[JsonProperty("720")] public object _720 { get; set; }
|
||||||
public object _720 { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("240")]
|
[JsonProperty("240")] public object _240 { get; set; }
|
||||||
public object _240 { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Drm
|
public class Drm
|
||||||
{
|
{
|
||||||
public Manifest manifest { get; set; }
|
public Manifest manifest { get; set; }
|
||||||
public Signature signature { get; set; }
|
public Signature signature { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Manifest
|
public class Manifest
|
||||||
{
|
{
|
||||||
public string? hls { get; set; }
|
public string? hls { get; set; }
|
||||||
public string? dash { get; set; }
|
public string? dash { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Signature
|
public class Signature
|
||||||
{
|
{
|
||||||
public Hls hls { get; set; }
|
public Hls hls { get; set; }
|
||||||
public Dash dash { get; set; }
|
public Dash dash { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Hls
|
public class Hls
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Dash
|
public class Dash
|
||||||
{
|
{
|
||||||
[JsonProperty("CloudFront-Policy")]
|
[JsonProperty("CloudFront-Policy")] public string CloudFrontPolicy { get; set; }
|
||||||
public string CloudFrontPolicy { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Signature")]
|
[JsonProperty("CloudFront-Signature")] public string CloudFrontSignature { get; set; }
|
||||||
public string CloudFrontSignature { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("CloudFront-Key-Pair-Id")]
|
[JsonProperty("CloudFront-Key-Pair-Id")]
|
||||||
public string CloudFrontKeyPairId { get; set; }
|
public string CloudFrontKeyPairId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
namespace OF_DL.Entities.Streams
|
namespace OF_DL.Entities.Streams;
|
||||||
|
|
||||||
|
public class StreamsCollection
|
||||||
{
|
{
|
||||||
public class StreamsCollection
|
public List<Streams.Medium> StreamMedia = new();
|
||||||
{
|
public List<Streams.List> StreamObjects = new();
|
||||||
public Dictionary<long, string> Streams = new Dictionary<long, string>();
|
public Dictionary<long, string> Streams = new();
|
||||||
public List<Streams.List> StreamObjects = new List<Streams.List>();
|
|
||||||
public List<Streams.Medium> StreamMedia = new List<Streams.Medium>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public class Subscriptions
|
||||||
{
|
{
|
||||||
public class Subscriptions
|
|
||||||
{
|
|
||||||
public List<List> list { get; set; }
|
public List<List> list { get; set; }
|
||||||
public bool hasMore { get; set; }
|
public bool hasMore { get; set; }
|
||||||
|
|
||||||
public class AvatarThumbs
|
public class AvatarThumbs
|
||||||
{
|
{
|
||||||
public string c50 { get; set; }
|
public string c50 { get; set; }
|
||||||
@ -155,5 +156,4 @@ namespace OF_DL.Entities
|
|||||||
public List<Subscribe> subscribes { get; set; }
|
public List<Subscribe> subscribes { get; set; }
|
||||||
public bool? hasActivePaidSubscriptions { get; set; }
|
public bool? hasActivePaidSubscriptions { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Property)]
|
|
||||||
internal class ToggleableConfigAttribute : Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
internal class ToggleableConfigAttribute : Attribute
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
namespace OF_DL.Entities
|
namespace OF_DL.Entities;
|
||||||
|
|
||||||
|
public class User
|
||||||
{
|
{
|
||||||
public class User
|
|
||||||
{
|
|
||||||
public string view { get; set; }
|
public string view { get; set; }
|
||||||
public string? avatar { get; set; }
|
public string? avatar { get; set; }
|
||||||
public AvatarThumbs avatarThumbs { get; set; }
|
public AvatarThumbs avatarThumbs { get; set; }
|
||||||
@ -88,6 +88,7 @@ namespace OF_DL.Entities
|
|||||||
public bool? isFriend { get; set; }
|
public bool? isFriend { get; set; }
|
||||||
public bool? isBlocked { get; set; }
|
public bool? isBlocked { get; set; }
|
||||||
public bool? canReport { get; set; }
|
public bool? canReport { get; set; }
|
||||||
|
|
||||||
public class AvatarThumbs
|
public class AvatarThumbs
|
||||||
{
|
{
|
||||||
public string c50 { get; set; }
|
public string c50 { get; set; }
|
||||||
@ -181,5 +182,4 @@ namespace OF_DL.Entities
|
|||||||
public string? totalSumm { get; set; }
|
public string? totalSumm { get; set; }
|
||||||
public List<Subscribe>? subscribes { get; set; }
|
public List<Subscribe>? subscribes { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,5 +3,5 @@ namespace OF_DL.Enumerations;
|
|||||||
public enum CustomFileNameOption
|
public enum CustomFileNameOption
|
||||||
{
|
{
|
||||||
ReturnOriginal,
|
ReturnOriginal,
|
||||||
ReturnEmpty,
|
ReturnEmpty
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
namespace OF_DL.Enumerations
|
namespace OF_DL.Enumerations;
|
||||||
|
|
||||||
|
public enum DownloadDateSelection
|
||||||
{
|
{
|
||||||
public enum DownloadDateSelection
|
|
||||||
{
|
|
||||||
before,
|
before,
|
||||||
after,
|
after
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,30 +1,34 @@
|
|||||||
namespace OF_DL.Enumerations
|
namespace OF_DL.Enumerations;
|
||||||
|
|
||||||
|
public enum LoggingLevel
|
||||||
{
|
{
|
||||||
public enum LoggingLevel
|
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// Summary:
|
// Summary:
|
||||||
// Anything and everything you might want to know about a running block of code.
|
// Anything and everything you might want to know about a running block of code.
|
||||||
Verbose,
|
Verbose,
|
||||||
|
|
||||||
//
|
//
|
||||||
// Summary:
|
// Summary:
|
||||||
// Internal system events that aren't necessarily observable from the outside.
|
// Internal system events that aren't necessarily observable from the outside.
|
||||||
Debug,
|
Debug,
|
||||||
|
|
||||||
//
|
//
|
||||||
// Summary:
|
// Summary:
|
||||||
// The lifeblood of operational intelligence - things happen.
|
// The lifeblood of operational intelligence - things happen.
|
||||||
Information,
|
Information,
|
||||||
|
|
||||||
//
|
//
|
||||||
// Summary:
|
// Summary:
|
||||||
// Service is degraded or endangered.
|
// Service is degraded or endangered.
|
||||||
Warning,
|
Warning,
|
||||||
|
|
||||||
//
|
//
|
||||||
// Summary:
|
// Summary:
|
||||||
// Functionality is unavailable, invariants are broken or data is lost.
|
// Functionality is unavailable, invariants are broken or data is lost.
|
||||||
Error,
|
Error,
|
||||||
|
|
||||||
//
|
//
|
||||||
// Summary:
|
// Summary:
|
||||||
// If you have a pager, it goes off when one of these occurs.
|
// If you have a pager, it goes off when one of these occurs.
|
||||||
Fatal
|
Fatal
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
namespace OF_DL.Enumerations
|
namespace OF_DL.Enumerations;
|
||||||
|
|
||||||
|
public enum MediaType
|
||||||
{
|
{
|
||||||
public enum MediaType
|
|
||||||
{
|
|
||||||
PaidPosts = 10,
|
PaidPosts = 10,
|
||||||
Posts = 20,
|
Posts = 20,
|
||||||
Archived = 30,
|
Archived = 30,
|
||||||
@ -9,5 +9,4 @@
|
|||||||
Highlights = 50,
|
Highlights = 50,
|
||||||
Messages = 60,
|
Messages = 60,
|
||||||
PaidMessages = 70
|
PaidMessages = 70
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
namespace OF_DL.Enumerations
|
namespace OF_DL.Enumerations;
|
||||||
|
|
||||||
|
public enum VideoResolution
|
||||||
{
|
{
|
||||||
public enum VideoResolution
|
|
||||||
{
|
|
||||||
_240,
|
_240,
|
||||||
_720,
|
_720,
|
||||||
source
|
source
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,25 @@
|
|||||||
using OF_DL.Entities;
|
using OF_DL.Entities;
|
||||||
using OF_DL.Services;
|
using OF_DL.Services;
|
||||||
|
|
||||||
namespace OF_DL.Helpers
|
namespace OF_DL.Helpers;
|
||||||
|
|
||||||
|
internal interface IDownloadContext
|
||||||
{
|
{
|
||||||
internal interface IDownloadContext
|
|
||||||
{
|
|
||||||
public IFileNameFormatConfig FileNameFormatConfig { get; }
|
public IFileNameFormatConfig FileNameFormatConfig { get; }
|
||||||
public IAPIService ApiService { get; }
|
public IAPIService ApiService { get; }
|
||||||
public IDBService DBService { get; }
|
public IDBService DBService { get; }
|
||||||
public IDownloadService DownloadService { get; }
|
public IDownloadService DownloadService { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class DownloadContext(
|
internal class DownloadContext(
|
||||||
IFileNameFormatConfig fileNameFormatConfig,
|
IFileNameFormatConfig fileNameFormatConfig,
|
||||||
IAPIService apiService,
|
IAPIService apiService,
|
||||||
IDBService dBService,
|
IDBService dBService,
|
||||||
IDownloadService downloadService)
|
IDownloadService downloadService)
|
||||||
: IDownloadContext
|
: IDownloadContext
|
||||||
{
|
{
|
||||||
public IAPIService ApiService { get; } = apiService;
|
public IAPIService ApiService { get; } = apiService;
|
||||||
public IDBService DBService { get; } = dBService;
|
public IDBService DBService { get; } = dBService;
|
||||||
public IDownloadService DownloadService { get; } = downloadService;
|
public IDownloadService DownloadService { get; } = downloadService;
|
||||||
public IFileNameFormatConfig FileNameFormatConfig { get; } = fileNameFormatConfig;
|
public IFileNameFormatConfig FileNameFormatConfig { get; } = fileNameFormatConfig;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
namespace OF_DL.Helpers
|
namespace OF_DL.Helpers;
|
||||||
|
|
||||||
|
public interface IFileNameHelper
|
||||||
{
|
{
|
||||||
public interface IFileNameHelper
|
|
||||||
{
|
|
||||||
Task<string> BuildFilename(string fileFormat, Dictionary<string, string> values);
|
Task<string> BuildFilename(string fileFormat, Dictionary<string, string> values);
|
||||||
Task<Dictionary<string, string>> GetFilename(object obj1, object obj2, object obj3, List<string> selectedProperties, string username, Dictionary<string, long> users = null);
|
|
||||||
}
|
Task<Dictionary<string, string>> GetFilename(object obj1, object obj2, object obj3, List<string> selectedProperties,
|
||||||
|
string username, Dictionary<string, long> users = null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,15 +6,15 @@ namespace OF_DL.Helpers;
|
|||||||
|
|
||||||
public static class VersionHelper
|
public static class VersionHelper
|
||||||
{
|
{
|
||||||
private static readonly HttpClient httpClient = new HttpClient();
|
|
||||||
private const string url = "https://git.ofdl.tools/api/v1/repos/sim0n00ps/OF-DL/releases/latest";
|
private const string url = "https://git.ofdl.tools/api/v1/repos/sim0n00ps/OF-DL/releases/latest";
|
||||||
|
private static readonly HttpClient httpClient = new();
|
||||||
|
|
||||||
public static async Task<string?> GetLatestReleaseTag(CancellationToken cancellationToken = default)
|
public static async Task<string?> GetLatestReleaseTag(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
Log.Debug("Calling GetLatestReleaseTag");
|
Log.Debug("Calling GetLatestReleaseTag");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var response = await httpClient.GetAsync(url, cancellationToken);
|
HttpResponseMessage response = await httpClient.GetAsync(url, cancellationToken);
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
@ -22,12 +22,13 @@ public static class VersionHelper
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var body = await response.Content.ReadAsStringAsync();
|
string body = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
Log.Debug("GetLatestReleaseTag API Response: ");
|
Log.Debug("GetLatestReleaseTag API Response: ");
|
||||||
Log.Debug(body);
|
Log.Debug(body);
|
||||||
|
|
||||||
var versionCheckResponse = JsonConvert.DeserializeObject<LatestReleaseAPIResponse>(body);
|
LatestReleaseAPIResponse? versionCheckResponse =
|
||||||
|
JsonConvert.DeserializeObject<LatestReleaseAPIResponse>(body);
|
||||||
|
|
||||||
if (versionCheckResponse == null || versionCheckResponse.TagName == "")
|
if (versionCheckResponse == null || versionCheckResponse.TagName == "")
|
||||||
{
|
{
|
||||||
@ -48,10 +49,13 @@ public static class VersionHelper
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,23 +10,23 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Icon\download.ico" />
|
<Content Include="Icon\download.ico"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Akka" Version="1.5.39" />
|
<PackageReference Include="Akka" Version="1.5.39"/>
|
||||||
<PackageReference Include="BouncyCastle.NetCore" Version="2.2.1" />
|
<PackageReference Include="BouncyCastle.NetCore" Version="2.2.1"/>
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.12.0" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.12.0"/>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1"/>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
|
||||||
<PackageReference Include="protobuf-net" Version="3.2.46" />
|
<PackageReference Include="protobuf-net" Version="3.2.46"/>
|
||||||
<PackageReference Include="PuppeteerSharp" Version="20.2.5" />
|
<PackageReference Include="PuppeteerSharp" Version="20.2.5"/>
|
||||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
<PackageReference Include="Serilog" Version="4.2.0"/>
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0"/>
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0"/>
|
||||||
<PackageReference Include="System.Reactive" Version="6.0.1" />
|
<PackageReference Include="System.Reactive" Version="6.0.1"/>
|
||||||
<PackageReference Include="xFFmpeg.NET" Version="7.2.0" />
|
<PackageReference Include="xFFmpeg.NET" Version="7.2.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
1255
OF DL/Program.cs
1255
OF DL/Program.cs
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -4,10 +4,19 @@ using PuppeteerSharp;
|
|||||||
using PuppeteerSharp.BrowserData;
|
using PuppeteerSharp.BrowserData;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public class AuthService : IAuthService
|
||||||
{
|
{
|
||||||
public class AuthService : IAuthService
|
private const int LoginTimeout = 600000; // 10 minutes
|
||||||
{
|
private const int FeedLoadTimeout = 60000; // 1 minute
|
||||||
|
|
||||||
|
private readonly string[] _desiredCookies =
|
||||||
|
[
|
||||||
|
"auth_id",
|
||||||
|
"sess"
|
||||||
|
];
|
||||||
|
|
||||||
private readonly LaunchOptions _options = new()
|
private readonly LaunchOptions _options = new()
|
||||||
{
|
{
|
||||||
Headless = false,
|
Headless = false,
|
||||||
@ -17,15 +26,6 @@ namespace OF_DL.Services
|
|||||||
UserDataDir = Path.GetFullPath("chrome-data")
|
UserDataDir = Path.GetFullPath("chrome-data")
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly string[] _desiredCookies =
|
|
||||||
[
|
|
||||||
"auth_id",
|
|
||||||
"sess"
|
|
||||||
];
|
|
||||||
|
|
||||||
private const int LoginTimeout = 600000; // 10 minutes
|
|
||||||
private const int FeedLoadTimeout = 60000; // 1 minute
|
|
||||||
|
|
||||||
public Auth? CurrentAuth { get; set; }
|
public Auth? CurrentAuth { get; set; }
|
||||||
|
|
||||||
public async Task<bool> LoadFromFileAsync(string filePath = "auth.json")
|
public async Task<bool> LoadFromFileAsync(string filePath = "auth.json")
|
||||||
@ -38,7 +38,7 @@ namespace OF_DL.Services
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = await File.ReadAllTextAsync(filePath);
|
string json = await File.ReadAllTextAsync(filePath);
|
||||||
CurrentAuth = JsonConvert.DeserializeObject<Auth>(json);
|
CurrentAuth = JsonConvert.DeserializeObject<Auth>(json);
|
||||||
Log.Debug("Auth file loaded and deserialized successfully");
|
Log.Debug("Auth file loaded and deserialized successfully");
|
||||||
return CurrentAuth != null;
|
return CurrentAuth != null;
|
||||||
@ -78,7 +78,7 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var json = JsonConvert.SerializeObject(CurrentAuth, Formatting.Indented);
|
string json = JsonConvert.SerializeObject(CurrentAuth, Formatting.Indented);
|
||||||
await File.WriteAllTextAsync(filePath, json);
|
await File.WriteAllTextAsync(filePath, json);
|
||||||
Log.Debug($"Auth saved to file: {filePath}");
|
Log.Debug($"Auth saved to file: {filePath}");
|
||||||
}
|
}
|
||||||
@ -93,17 +93,19 @@ namespace OF_DL.Services
|
|||||||
string? executablePath = Environment.GetEnvironmentVariable("OFDL_PUPPETEER_EXECUTABLE_PATH");
|
string? executablePath = Environment.GetEnvironmentVariable("OFDL_PUPPETEER_EXECUTABLE_PATH");
|
||||||
if (executablePath != null)
|
if (executablePath != null)
|
||||||
{
|
{
|
||||||
Log.Information("OFDL_PUPPETEER_EXECUTABLE_PATH environment variable found. Using browser executable path: {executablePath}", executablePath);
|
Log.Information(
|
||||||
|
"OFDL_PUPPETEER_EXECUTABLE_PATH environment variable found. Using browser executable path: {executablePath}",
|
||||||
|
executablePath);
|
||||||
_options.ExecutablePath = executablePath;
|
_options.ExecutablePath = executablePath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var browserFetcher = new BrowserFetcher();
|
BrowserFetcher browserFetcher = new();
|
||||||
var installedBrowsers = browserFetcher.GetInstalledBrowsers().ToList();
|
List<InstalledBrowser> installedBrowsers = browserFetcher.GetInstalledBrowsers().ToList();
|
||||||
if (installedBrowsers.Count == 0)
|
if (installedBrowsers.Count == 0)
|
||||||
{
|
{
|
||||||
Log.Information("Downloading browser.");
|
Log.Information("Downloading browser.");
|
||||||
var downloadedBrowser = await browserFetcher.DownloadAsync();
|
InstalledBrowser? downloadedBrowser = await browserFetcher.DownloadAsync();
|
||||||
Log.Information("Browser downloaded. Path: {executablePath}",
|
Log.Information("Browser downloaded. Path: {executablePath}",
|
||||||
downloadedBrowser.GetExecutablePath());
|
downloadedBrowser.GetExecutablePath());
|
||||||
_options.ExecutablePath = downloadedBrowser.GetExecutablePath();
|
_options.ExecutablePath = downloadedBrowser.GetExecutablePath();
|
||||||
@ -121,10 +123,8 @@ namespace OF_DL.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> GetBcToken(IPage page)
|
private async Task<string> GetBcToken(IPage page) =>
|
||||||
{
|
await page.EvaluateExpressionAsync<string>("window.localStorage.getItem('bcTokenSha') || ''");
|
||||||
return await page.EvaluateExpressionAsync<string>("window.localStorage.getItem('bcTokenSha') || ''");
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<Auth?> GetAuthFromBrowser(bool isDocker = false)
|
private async Task<Auth?> GetAuthFromBrowser(bool isDocker = false)
|
||||||
{
|
{
|
||||||
@ -171,9 +171,9 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
await page.ReloadAsync();
|
await page.ReloadAsync();
|
||||||
|
|
||||||
await page.WaitForNavigationAsync(new NavigationOptions {
|
await page.WaitForNavigationAsync(new NavigationOptions
|
||||||
WaitUntil = [WaitUntilNavigation.Networkidle2],
|
{
|
||||||
Timeout = FeedLoadTimeout
|
WaitUntil = [WaitUntilNavigation.Networkidle2], Timeout = FeedLoadTimeout
|
||||||
});
|
});
|
||||||
Log.Debug("DOM loaded. Getting BC token and cookies ...");
|
Log.Debug("DOM loaded. Getting BC token and cookies ...");
|
||||||
|
|
||||||
@ -212,13 +212,7 @@ namespace OF_DL.Services
|
|||||||
string cookies = string.Join(" ", mappedCookies.Keys.Where(key => _desiredCookies.Contains(key))
|
string cookies = string.Join(" ", mappedCookies.Keys.Where(key => _desiredCookies.Contains(key))
|
||||||
.Select(key => $"${key}={mappedCookies[key]};"));
|
.Select(key => $"${key}={mappedCookies[key]};"));
|
||||||
|
|
||||||
return new Auth()
|
return new Auth { COOKIE = cookies, USER_AGENT = userAgent, USER_ID = userId, X_BC = xBc };
|
||||||
{
|
|
||||||
COOKIE = cookies,
|
|
||||||
USER_AGENT = userAgent,
|
|
||||||
USER_ID = userId,
|
|
||||||
X_BC = xBc
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -226,5 +220,4 @@ namespace OF_DL.Services
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,17 @@
|
|||||||
|
using System.Text;
|
||||||
using Akka.Configuration;
|
using Akka.Configuration;
|
||||||
|
using Akka.Configuration.Hocon;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using OF_DL.Entities;
|
using OF_DL.Entities;
|
||||||
using Serilog;
|
|
||||||
using System.Text;
|
|
||||||
using OF_DL.Enumerations;
|
using OF_DL.Enumerations;
|
||||||
|
using OF_DL.Utils;
|
||||||
|
using Serilog;
|
||||||
using Config = OF_DL.Entities.Config;
|
using Config = OF_DL.Entities.Config;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public class ConfigService(ILoggingService loggingService) : IConfigService
|
||||||
{
|
{
|
||||||
public class ConfigService(ILoggingService loggingService) : IConfigService
|
|
||||||
{
|
|
||||||
public Config CurrentConfig { get; private set; } = new();
|
public Config CurrentConfig { get; private set; } = new();
|
||||||
public bool IsCliNonInteractive { get; private set; }
|
public bool IsCliNonInteractive { get; private set; }
|
||||||
|
|
||||||
@ -77,7 +79,7 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var hoconConfig = BuildHoconFromConfig(CurrentConfig);
|
string hoconConfig = BuildHoconFromConfig(CurrentConfig);
|
||||||
await File.WriteAllTextAsync(filePath, hoconConfig);
|
await File.WriteAllTextAsync(filePath, hoconConfig);
|
||||||
Log.Debug($"Config saved to file: {filePath}");
|
Log.Debug($"Config saved to file: {filePath}");
|
||||||
}
|
}
|
||||||
@ -95,7 +97,7 @@ namespace OF_DL.Services
|
|||||||
loggingService.UpdateLoggingLevel(newConfig.LoggingLevel);
|
loggingService.UpdateLoggingLevel(newConfig.LoggingLevel);
|
||||||
|
|
||||||
// Apply text sanitization preference globally
|
// Apply text sanitization preference globally
|
||||||
OF_DL.Utils.XmlUtils.Passthrough = newConfig.DisableTextSanitization;
|
XmlUtils.Passthrough = newConfig.DisableTextSanitization;
|
||||||
|
|
||||||
Log.Debug("Configuration updated");
|
Log.Debug("Configuration updated");
|
||||||
string configString = JsonConvert.SerializeObject(newConfig, Formatting.Indented);
|
string configString = JsonConvert.SerializeObject(newConfig, Formatting.Indented);
|
||||||
@ -105,17 +107,19 @@ namespace OF_DL.Services
|
|||||||
private async Task MigrateFromJsonToConfAsync()
|
private async Task MigrateFromJsonToConfAsync()
|
||||||
{
|
{
|
||||||
if (!File.Exists("config.json"))
|
if (!File.Exists("config.json"))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.Debug("config.json found, migrating to config.conf");
|
Log.Debug("config.json found, migrating to config.conf");
|
||||||
string jsonText = await File.ReadAllTextAsync("config.json");
|
string jsonText = await File.ReadAllTextAsync("config.json");
|
||||||
var jsonConfig = JsonConvert.DeserializeObject<Config>(jsonText);
|
Config? jsonConfig = JsonConvert.DeserializeObject<Config>(jsonText);
|
||||||
|
|
||||||
if (jsonConfig != null)
|
if (jsonConfig != null)
|
||||||
{
|
{
|
||||||
var hoconConfig = BuildHoconFromConfig(jsonConfig);
|
string hoconConfig = BuildHoconFromConfig(jsonConfig);
|
||||||
await File.WriteAllTextAsync("config.conf", hoconConfig);
|
await File.WriteAllTextAsync("config.conf", hoconConfig);
|
||||||
File.Delete("config.json");
|
File.Delete("config.json");
|
||||||
Log.Information("config.conf created successfully from config.json");
|
Log.Information("config.conf created successfully from config.json");
|
||||||
@ -133,7 +137,7 @@ namespace OF_DL.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string hoconText = await File.ReadAllTextAsync(filePath);
|
string hoconText = await File.ReadAllTextAsync(filePath);
|
||||||
var hoconConfig = ConfigurationFactory.ParseString(hoconText);
|
Akka.Configuration.Config? hoconConfig = ConfigurationFactory.ParseString(hoconText);
|
||||||
|
|
||||||
CurrentConfig = new Config
|
CurrentConfig = new Config
|
||||||
{
|
{
|
||||||
@ -158,23 +162,33 @@ namespace OF_DL.Services
|
|||||||
DownloadAudios = hoconConfig.GetBoolean("Download.Media.DownloadAudios"),
|
DownloadAudios = hoconConfig.GetBoolean("Download.Media.DownloadAudios"),
|
||||||
IgnoreOwnMessages = hoconConfig.GetBoolean("Download.IgnoreOwnMessages"),
|
IgnoreOwnMessages = hoconConfig.GetBoolean("Download.IgnoreOwnMessages"),
|
||||||
DownloadPostsIncrementally = hoconConfig.GetBoolean("Download.DownloadPostsIncrementally"),
|
DownloadPostsIncrementally = hoconConfig.GetBoolean("Download.DownloadPostsIncrementally"),
|
||||||
BypassContentForCreatorsWhoNoLongerExist = hoconConfig.GetBoolean("Download.BypassContentForCreatorsWhoNoLongerExist"),
|
BypassContentForCreatorsWhoNoLongerExist =
|
||||||
|
hoconConfig.GetBoolean("Download.BypassContentForCreatorsWhoNoLongerExist"),
|
||||||
DownloadDuplicatedMedia = hoconConfig.GetBoolean("Download.DownloadDuplicatedMedia"),
|
DownloadDuplicatedMedia = hoconConfig.GetBoolean("Download.DownloadDuplicatedMedia"),
|
||||||
SkipAds = hoconConfig.GetBoolean("Download.SkipAds"),
|
SkipAds = hoconConfig.GetBoolean("Download.SkipAds"),
|
||||||
DownloadPath = hoconConfig.GetString("Download.DownloadPath"),
|
DownloadPath = hoconConfig.GetString("Download.DownloadPath"),
|
||||||
DownloadOnlySpecificDates = hoconConfig.GetBoolean("Download.DownloadOnlySpecificDates"),
|
DownloadOnlySpecificDates = hoconConfig.GetBoolean("Download.DownloadOnlySpecificDates"),
|
||||||
DownloadDateSelection = Enum.Parse<DownloadDateSelection>(hoconConfig.GetString("Download.DownloadDateSelection"), true),
|
DownloadDateSelection =
|
||||||
CustomDate = !string.IsNullOrWhiteSpace(hoconConfig.GetString("Download.CustomDate")) ? DateTime.Parse(hoconConfig.GetString("Download.CustomDate")) : null,
|
Enum.Parse<DownloadDateSelection>(hoconConfig.GetString("Download.DownloadDateSelection"), true),
|
||||||
|
CustomDate =
|
||||||
|
!string.IsNullOrWhiteSpace(hoconConfig.GetString("Download.CustomDate"))
|
||||||
|
? DateTime.Parse(hoconConfig.GetString("Download.CustomDate"))
|
||||||
|
: null,
|
||||||
ShowScrapeSize = hoconConfig.GetBoolean("Download.ShowScrapeSize"),
|
ShowScrapeSize = hoconConfig.GetBoolean("Download.ShowScrapeSize"),
|
||||||
DisableTextSanitization = bool.TryParse(hoconConfig.GetString("Download.DisableTextSanitization", "false"), out var dts) ? dts : false,
|
DisableTextSanitization =
|
||||||
DownloadVideoResolution = ParseVideoResolution(hoconConfig.GetString("Download.DownloadVideoResolution", "source")),
|
bool.TryParse(hoconConfig.GetString("Download.DisableTextSanitization", "false"), out bool dts)
|
||||||
|
? dts
|
||||||
|
: false,
|
||||||
|
DownloadVideoResolution =
|
||||||
|
ParseVideoResolution(hoconConfig.GetString("Download.DownloadVideoResolution", "source")),
|
||||||
|
|
||||||
// File Settings
|
// File Settings
|
||||||
PaidPostFileNameFormat = hoconConfig.GetString("File.PaidPostFileNameFormat"),
|
PaidPostFileNameFormat = hoconConfig.GetString("File.PaidPostFileNameFormat"),
|
||||||
PostFileNameFormat = hoconConfig.GetString("File.PostFileNameFormat"),
|
PostFileNameFormat = hoconConfig.GetString("File.PostFileNameFormat"),
|
||||||
PaidMessageFileNameFormat = hoconConfig.GetString("File.PaidMessageFileNameFormat"),
|
PaidMessageFileNameFormat = hoconConfig.GetString("File.PaidMessageFileNameFormat"),
|
||||||
MessageFileNameFormat = hoconConfig.GetString("File.MessageFileNameFormat"),
|
MessageFileNameFormat = hoconConfig.GetString("File.MessageFileNameFormat"),
|
||||||
RenameExistingFilesWhenCustomFormatIsSelected = hoconConfig.GetBoolean("File.RenameExistingFilesWhenCustomFormatIsSelected"),
|
RenameExistingFilesWhenCustomFormatIsSelected =
|
||||||
|
hoconConfig.GetBoolean("File.RenameExistingFilesWhenCustomFormatIsSelected"),
|
||||||
|
|
||||||
// Folder Settings
|
// Folder Settings
|
||||||
FolderPerPaidPost = hoconConfig.GetBoolean("Folder.FolderPerPaidPost"),
|
FolderPerPaidPost = hoconConfig.GetBoolean("Folder.FolderPerPaidPost"),
|
||||||
@ -193,7 +207,10 @@ namespace OF_DL.Services
|
|||||||
NonInteractiveModePurchasedTab = hoconConfig.GetBoolean("Interaction.NonInteractiveModePurchasedTab"),
|
NonInteractiveModePurchasedTab = hoconConfig.GetBoolean("Interaction.NonInteractiveModePurchasedTab"),
|
||||||
|
|
||||||
// Performance Settings
|
// Performance Settings
|
||||||
Timeout = string.IsNullOrWhiteSpace(hoconConfig.GetString("Performance.Timeout")) ? -1 : hoconConfig.GetInt("Performance.Timeout"),
|
Timeout =
|
||||||
|
string.IsNullOrWhiteSpace(hoconConfig.GetString("Performance.Timeout"))
|
||||||
|
? -1
|
||||||
|
: hoconConfig.GetInt("Performance.Timeout"),
|
||||||
LimitDownloadRate = hoconConfig.GetBoolean("Performance.LimitDownloadRate"),
|
LimitDownloadRate = hoconConfig.GetBoolean("Performance.LimitDownloadRate"),
|
||||||
DownloadLimitInMbPerSec = hoconConfig.GetInt("Performance.DownloadLimitInMbPerSec"),
|
DownloadLimitInMbPerSec = hoconConfig.GetInt("Performance.DownloadLimitInMbPerSec"),
|
||||||
|
|
||||||
@ -208,16 +225,17 @@ namespace OF_DL.Services
|
|||||||
ValidateFileNameFormat(CurrentConfig.MessageFileNameFormat, "MessageFileNameFormat");
|
ValidateFileNameFormat(CurrentConfig.MessageFileNameFormat, "MessageFileNameFormat");
|
||||||
|
|
||||||
// Load creator-specific configs
|
// Load creator-specific configs
|
||||||
var creatorConfigsSection = hoconConfig.GetConfig("CreatorConfigs");
|
Akka.Configuration.Config? creatorConfigsSection = hoconConfig.GetConfig("CreatorConfigs");
|
||||||
if (creatorConfigsSection != null)
|
if (creatorConfigsSection != null)
|
||||||
{
|
{
|
||||||
foreach (var key in creatorConfigsSection.AsEnumerable())
|
foreach (KeyValuePair<string, HoconValue> key in creatorConfigsSection.AsEnumerable())
|
||||||
{
|
{
|
||||||
var creatorKey = key.Key;
|
string creatorKey = key.Key;
|
||||||
var creatorHocon = creatorConfigsSection.GetConfig(creatorKey);
|
Akka.Configuration.Config? creatorHocon = creatorConfigsSection.GetConfig(creatorKey);
|
||||||
if (!CurrentConfig.CreatorConfigs.ContainsKey(creatorKey) && creatorHocon != null)
|
if (!CurrentConfig.CreatorConfigs.ContainsKey(creatorKey) && creatorHocon != null)
|
||||||
{
|
{
|
||||||
CurrentConfig.CreatorConfigs.Add(key.Key, new CreatorConfig
|
CurrentConfig.CreatorConfigs.Add(key.Key,
|
||||||
|
new CreatorConfig
|
||||||
{
|
{
|
||||||
PaidPostFileNameFormat = creatorHocon.GetString("PaidPostFileNameFormat"),
|
PaidPostFileNameFormat = creatorHocon.GetString("PaidPostFileNameFormat"),
|
||||||
PostFileNameFormat = creatorHocon.GetString("PostFileNameFormat"),
|
PostFileNameFormat = creatorHocon.GetString("PostFileNameFormat"),
|
||||||
@ -225,10 +243,14 @@ namespace OF_DL.Services
|
|||||||
MessageFileNameFormat = creatorHocon.GetString("MessageFileNameFormat")
|
MessageFileNameFormat = creatorHocon.GetString("MessageFileNameFormat")
|
||||||
});
|
});
|
||||||
|
|
||||||
ValidateFileNameFormat(CurrentConfig.CreatorConfigs[key.Key].PaidPostFileNameFormat, $"{key.Key}.PaidPostFileNameFormat");
|
ValidateFileNameFormat(CurrentConfig.CreatorConfigs[key.Key].PaidPostFileNameFormat,
|
||||||
ValidateFileNameFormat(CurrentConfig.CreatorConfigs[key.Key].PostFileNameFormat, $"{key.Key}.PostFileNameFormat");
|
$"{key.Key}.PaidPostFileNameFormat");
|
||||||
ValidateFileNameFormat(CurrentConfig.CreatorConfigs[key.Key].PaidMessageFileNameFormat, $"{key.Key}.PaidMessageFileNameFormat");
|
ValidateFileNameFormat(CurrentConfig.CreatorConfigs[key.Key].PostFileNameFormat,
|
||||||
ValidateFileNameFormat(CurrentConfig.CreatorConfigs[key.Key].MessageFileNameFormat, $"{key.Key}.MessageFileNameFormat");
|
$"{key.Key}.PostFileNameFormat");
|
||||||
|
ValidateFileNameFormat(CurrentConfig.CreatorConfigs[key.Key].PaidMessageFileNameFormat,
|
||||||
|
$"{key.Key}.PaidMessageFileNameFormat");
|
||||||
|
ValidateFileNameFormat(CurrentConfig.CreatorConfigs[key.Key].MessageFileNameFormat,
|
||||||
|
$"{key.Key}.MessageFileNameFormat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +259,7 @@ namespace OF_DL.Services
|
|||||||
loggingService.UpdateLoggingLevel(CurrentConfig.LoggingLevel);
|
loggingService.UpdateLoggingLevel(CurrentConfig.LoggingLevel);
|
||||||
|
|
||||||
// Apply text sanitization preference globally
|
// Apply text sanitization preference globally
|
||||||
OF_DL.Utils.XmlUtils.Passthrough = CurrentConfig.DisableTextSanitization;
|
XmlUtils.Passthrough = CurrentConfig.DisableTextSanitization;
|
||||||
|
|
||||||
Log.Debug("Configuration loaded successfully");
|
Log.Debug("Configuration loaded successfully");
|
||||||
string configString = JsonConvert.SerializeObject(CurrentConfig, Formatting.Indented);
|
string configString = JsonConvert.SerializeObject(CurrentConfig, Formatting.Indented);
|
||||||
@ -254,15 +276,15 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
private async Task CreateDefaultConfigFileAsync()
|
private async Task CreateDefaultConfigFileAsync()
|
||||||
{
|
{
|
||||||
Config defaultConfig = new Config();
|
Config defaultConfig = new();
|
||||||
var hoconConfig = BuildHoconFromConfig(defaultConfig);
|
string hoconConfig = BuildHoconFromConfig(defaultConfig);
|
||||||
await File.WriteAllTextAsync("config.conf", hoconConfig);
|
await File.WriteAllTextAsync("config.conf", hoconConfig);
|
||||||
Log.Information("Created default config.conf file");
|
Log.Information("Created default config.conf file");
|
||||||
}
|
}
|
||||||
|
|
||||||
private string BuildHoconFromConfig(Config config)
|
private string BuildHoconFromConfig(Config config)
|
||||||
{
|
{
|
||||||
var hocon = new StringBuilder();
|
StringBuilder hocon = new();
|
||||||
|
|
||||||
hocon.AppendLine("# Auth");
|
hocon.AppendLine("# Auth");
|
||||||
hocon.AppendLine("Auth {");
|
hocon.AppendLine("Auth {");
|
||||||
@ -292,7 +314,8 @@ namespace OF_DL.Services
|
|||||||
hocon.AppendLine(" }");
|
hocon.AppendLine(" }");
|
||||||
hocon.AppendLine($" IgnoreOwnMessages = {config.IgnoreOwnMessages.ToString().ToLower()}");
|
hocon.AppendLine($" IgnoreOwnMessages = {config.IgnoreOwnMessages.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" DownloadPostsIncrementally = {config.DownloadPostsIncrementally.ToString().ToLower()}");
|
hocon.AppendLine($" DownloadPostsIncrementally = {config.DownloadPostsIncrementally.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" BypassContentForCreatorsWhoNoLongerExist = {config.BypassContentForCreatorsWhoNoLongerExist.ToString().ToLower()}");
|
hocon.AppendLine(
|
||||||
|
$" BypassContentForCreatorsWhoNoLongerExist = {config.BypassContentForCreatorsWhoNoLongerExist.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" DownloadDuplicatedMedia = {config.DownloadDuplicatedMedia.ToString().ToLower()}");
|
hocon.AppendLine($" DownloadDuplicatedMedia = {config.DownloadDuplicatedMedia.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" SkipAds = {config.SkipAds.ToString().ToLower()}");
|
hocon.AppendLine($" SkipAds = {config.SkipAds.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" DownloadPath = \"{config.DownloadPath}\"");
|
hocon.AppendLine($" DownloadPath = \"{config.DownloadPath}\"");
|
||||||
@ -301,7 +324,8 @@ namespace OF_DL.Services
|
|||||||
hocon.AppendLine($" CustomDate = \"{config.CustomDate?.ToString("yyyy-MM-dd")}\"");
|
hocon.AppendLine($" CustomDate = \"{config.CustomDate?.ToString("yyyy-MM-dd")}\"");
|
||||||
hocon.AppendLine($" ShowScrapeSize = {config.ShowScrapeSize.ToString().ToLower()}");
|
hocon.AppendLine($" ShowScrapeSize = {config.ShowScrapeSize.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" DisableTextSanitization = {config.DisableTextSanitization.ToString().ToLower()}");
|
hocon.AppendLine($" DisableTextSanitization = {config.DisableTextSanitization.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" DownloadVideoResolution = \"{(config.DownloadVideoResolution == VideoResolution.source ? "source" : config.DownloadVideoResolution.ToString().TrimStart('_'))}\"");
|
hocon.AppendLine(
|
||||||
|
$" DownloadVideoResolution = \"{(config.DownloadVideoResolution == VideoResolution.source ? "source" : config.DownloadVideoResolution.ToString().TrimStart('_'))}\"");
|
||||||
hocon.AppendLine("}");
|
hocon.AppendLine("}");
|
||||||
|
|
||||||
hocon.AppendLine("# File Settings");
|
hocon.AppendLine("# File Settings");
|
||||||
@ -310,12 +334,13 @@ namespace OF_DL.Services
|
|||||||
hocon.AppendLine($" PostFileNameFormat = \"{config.PostFileNameFormat}\"");
|
hocon.AppendLine($" PostFileNameFormat = \"{config.PostFileNameFormat}\"");
|
||||||
hocon.AppendLine($" PaidMessageFileNameFormat = \"{config.PaidMessageFileNameFormat}\"");
|
hocon.AppendLine($" PaidMessageFileNameFormat = \"{config.PaidMessageFileNameFormat}\"");
|
||||||
hocon.AppendLine($" MessageFileNameFormat = \"{config.MessageFileNameFormat}\"");
|
hocon.AppendLine($" MessageFileNameFormat = \"{config.MessageFileNameFormat}\"");
|
||||||
hocon.AppendLine($" RenameExistingFilesWhenCustomFormatIsSelected = {config.RenameExistingFilesWhenCustomFormatIsSelected.ToString().ToLower()}");
|
hocon.AppendLine(
|
||||||
|
$" RenameExistingFilesWhenCustomFormatIsSelected = {config.RenameExistingFilesWhenCustomFormatIsSelected.ToString().ToLower()}");
|
||||||
hocon.AppendLine("}");
|
hocon.AppendLine("}");
|
||||||
|
|
||||||
hocon.AppendLine("# Creator-Specific Configurations");
|
hocon.AppendLine("# Creator-Specific Configurations");
|
||||||
hocon.AppendLine("CreatorConfigs {");
|
hocon.AppendLine("CreatorConfigs {");
|
||||||
foreach (var creatorConfig in config.CreatorConfigs)
|
foreach (KeyValuePair<string, CreatorConfig> creatorConfig in config.CreatorConfigs)
|
||||||
{
|
{
|
||||||
hocon.AppendLine($" \"{creatorConfig.Key}\" {{");
|
hocon.AppendLine($" \"{creatorConfig.Key}\" {{");
|
||||||
hocon.AppendLine($" PaidPostFileNameFormat = \"{creatorConfig.Value.PaidPostFileNameFormat}\"");
|
hocon.AppendLine($" PaidPostFileNameFormat = \"{creatorConfig.Value.PaidPostFileNameFormat}\"");
|
||||||
@ -324,6 +349,7 @@ namespace OF_DL.Services
|
|||||||
hocon.AppendLine($" MessageFileNameFormat = \"{creatorConfig.Value.MessageFileNameFormat}\"");
|
hocon.AppendLine($" MessageFileNameFormat = \"{creatorConfig.Value.MessageFileNameFormat}\"");
|
||||||
hocon.AppendLine(" }");
|
hocon.AppendLine(" }");
|
||||||
}
|
}
|
||||||
|
|
||||||
hocon.AppendLine("}");
|
hocon.AppendLine("}");
|
||||||
|
|
||||||
hocon.AppendLine("# Folder Settings");
|
hocon.AppendLine("# Folder Settings");
|
||||||
@ -337,7 +363,8 @@ namespace OF_DL.Services
|
|||||||
hocon.AppendLine("# Subscription Settings");
|
hocon.AppendLine("# Subscription Settings");
|
||||||
hocon.AppendLine("Subscriptions {");
|
hocon.AppendLine("Subscriptions {");
|
||||||
hocon.AppendLine($" IncludeExpiredSubscriptions = {config.IncludeExpiredSubscriptions.ToString().ToLower()}");
|
hocon.AppendLine($" IncludeExpiredSubscriptions = {config.IncludeExpiredSubscriptions.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" IncludeRestrictedSubscriptions = {config.IncludeRestrictedSubscriptions.ToString().ToLower()}");
|
hocon.AppendLine(
|
||||||
|
$" IncludeRestrictedSubscriptions = {config.IncludeRestrictedSubscriptions.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" IgnoredUsersListName = \"{config.IgnoredUsersListName}\"");
|
hocon.AppendLine($" IgnoredUsersListName = \"{config.IgnoredUsersListName}\"");
|
||||||
hocon.AppendLine("}");
|
hocon.AppendLine("}");
|
||||||
|
|
||||||
@ -345,7 +372,8 @@ namespace OF_DL.Services
|
|||||||
hocon.AppendLine("Interaction {");
|
hocon.AppendLine("Interaction {");
|
||||||
hocon.AppendLine($" NonInteractiveMode = {config.NonInteractiveMode.ToString().ToLower()}");
|
hocon.AppendLine($" NonInteractiveMode = {config.NonInteractiveMode.ToString().ToLower()}");
|
||||||
hocon.AppendLine($" NonInteractiveModeListName = \"{config.NonInteractiveModeListName}\"");
|
hocon.AppendLine($" NonInteractiveModeListName = \"{config.NonInteractiveModeListName}\"");
|
||||||
hocon.AppendLine($" NonInteractiveModePurchasedTab = {config.NonInteractiveModePurchasedTab.ToString().ToLower()}");
|
hocon.AppendLine(
|
||||||
|
$" NonInteractiveModePurchasedTab = {config.NonInteractiveModePurchasedTab.ToString().ToLower()}");
|
||||||
hocon.AppendLine("}");
|
hocon.AppendLine("}");
|
||||||
|
|
||||||
hocon.AppendLine("# Performance Settings");
|
hocon.AppendLine("# Performance Settings");
|
||||||
@ -377,9 +405,10 @@ namespace OF_DL.Services
|
|||||||
private VideoResolution ParseVideoResolution(string value)
|
private VideoResolution ParseVideoResolution(string value)
|
||||||
{
|
{
|
||||||
if (value.Equals("source", StringComparison.OrdinalIgnoreCase))
|
if (value.Equals("source", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
return VideoResolution.source;
|
return VideoResolution.source;
|
||||||
|
|
||||||
return Enum.Parse<VideoResolution>("_" + value, ignoreCase: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Enum.Parse<VideoResolution>("_" + value, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,10 +2,10 @@ using System.Text;
|
|||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public class DBService(IConfigService configService) : IDBService
|
||||||
{
|
{
|
||||||
public class DBService(IConfigService configService) : IDBService
|
|
||||||
{
|
|
||||||
public async Task CreateDB(string folder)
|
public async Task CreateDB(string folder)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -23,7 +23,10 @@ namespace OF_DL.Services
|
|||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
// create the 'medias' table
|
// create the 'medias' table
|
||||||
using (SqliteCommand cmd = new("CREATE TABLE IF NOT EXISTS medias (id INTEGER NOT NULL, media_id INTEGER, post_id INTEGER NOT NULL, link VARCHAR, directory VARCHAR, filename VARCHAR, size INTEGER, api_type VARCHAR, media_type VARCHAR, preview INTEGER, linked VARCHAR, downloaded INTEGER, created_at TIMESTAMP, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(media_id));", connection))
|
using (SqliteCommand cmd =
|
||||||
|
new(
|
||||||
|
"CREATE TABLE IF NOT EXISTS medias (id INTEGER NOT NULL, media_id INTEGER, post_id INTEGER NOT NULL, link VARCHAR, directory VARCHAR, filename VARCHAR, size INTEGER, api_type VARCHAR, media_type VARCHAR, preview INTEGER, linked VARCHAR, downloaded INTEGER, created_at TIMESTAMP, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(media_id));",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
@ -71,37 +74,55 @@ namespace OF_DL.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create the 'messages' table
|
// create the 'messages' table
|
||||||
using (SqliteCommand cmd = new("CREATE TABLE IF NOT EXISTS messages (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, user_id INTEGER, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));", connection))
|
using (SqliteCommand cmd =
|
||||||
|
new(
|
||||||
|
"CREATE TABLE IF NOT EXISTS messages (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, user_id INTEGER, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the 'posts' table
|
// create the 'posts' table
|
||||||
using (SqliteCommand cmd = new("CREATE TABLE IF NOT EXISTS posts (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));", connection))
|
using (SqliteCommand cmd =
|
||||||
|
new(
|
||||||
|
"CREATE TABLE IF NOT EXISTS posts (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the 'stories' table
|
// create the 'stories' table
|
||||||
using (SqliteCommand cmd = new("CREATE TABLE IF NOT EXISTS stories (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));", connection))
|
using (SqliteCommand cmd =
|
||||||
|
new(
|
||||||
|
"CREATE TABLE IF NOT EXISTS stories (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the 'others' table
|
// create the 'others' table
|
||||||
using (SqliteCommand cmd = new("CREATE TABLE IF NOT EXISTS others (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));", connection))
|
using (SqliteCommand cmd =
|
||||||
|
new(
|
||||||
|
"CREATE TABLE IF NOT EXISTS others (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the 'products' table
|
// create the 'products' table
|
||||||
using (SqliteCommand cmd = new("CREATE TABLE IF NOT EXISTS products (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, title VARCHAR, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));", connection))
|
using (SqliteCommand cmd =
|
||||||
|
new(
|
||||||
|
"CREATE TABLE IF NOT EXISTS products (id INTEGER NOT NULL, post_id INTEGER NOT NULL, text VARCHAR, price INTEGER, paid INTEGER, archived BOOLEAN, created_at TIMESTAMP, title VARCHAR, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(post_id));",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the 'profiles' table
|
// create the 'profiles' table
|
||||||
using (SqliteCommand cmd = new("CREATE TABLE IF NOT EXISTS profiles (id INTEGER NOT NULL, user_id INTEGER NOT NULL, username VARCHAR NOT NULL, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(username));", connection))
|
using (SqliteCommand cmd =
|
||||||
|
new(
|
||||||
|
"CREATE TABLE IF NOT EXISTS profiles (id INTEGER NOT NULL, user_id INTEGER NOT NULL, username VARCHAR NOT NULL, record_created_at TIMESTAMP, PRIMARY KEY(id), UNIQUE(username));",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
@ -115,8 +136,10 @@ namespace OF_DL.Services
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +153,10 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
using (SqliteCommand cmd = new("CREATE TABLE IF NOT EXISTS users (id INTEGER NOT NULL, user_id INTEGER NOT NULL, username VARCHAR NOT NULL, PRIMARY KEY(id), UNIQUE(username));", connection))
|
using (SqliteCommand cmd =
|
||||||
|
new(
|
||||||
|
"CREATE TABLE IF NOT EXISTS users (id INTEGER NOT NULL, user_id INTEGER NOT NULL, username VARCHAR NOT NULL, PRIMARY KEY(id), UNIQUE(username));",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
await cmd.ExecuteNonQueryAsync();
|
await cmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
@ -138,14 +164,17 @@ namespace OF_DL.Services
|
|||||||
Log.Debug("Adding missing creators");
|
Log.Debug("Adding missing creators");
|
||||||
foreach (KeyValuePair<string, long> user in users)
|
foreach (KeyValuePair<string, long> user in users)
|
||||||
{
|
{
|
||||||
using (SqliteCommand checkCmd = new($"SELECT user_id, username FROM users WHERE user_id = @userId;", connection))
|
using (SqliteCommand checkCmd = new("SELECT user_id, username FROM users WHERE user_id = @userId;",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
checkCmd.Parameters.AddWithValue("@userId", user.Value);
|
checkCmd.Parameters.AddWithValue("@userId", user.Value);
|
||||||
using (var reader = await checkCmd.ExecuteReaderAsync())
|
using (SqliteDataReader reader = await checkCmd.ExecuteReaderAsync())
|
||||||
{
|
{
|
||||||
if (!reader.Read())
|
if (!reader.Read())
|
||||||
{
|
{
|
||||||
using (SqliteCommand insertCmd = new($"INSERT INTO users (user_id, username) VALUES (@userId, @username);", connection))
|
using (SqliteCommand insertCmd =
|
||||||
|
new("INSERT INTO users (user_id, username) VALUES (@userId, @username);",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
insertCmd.Parameters.AddWithValue("@userId", user.Value);
|
insertCmd.Parameters.AddWithValue("@userId", user.Value);
|
||||||
insertCmd.Parameters.AddWithValue("@username", user.Key);
|
insertCmd.Parameters.AddWithValue("@username", user.Key);
|
||||||
@ -170,8 +199,10 @@ namespace OF_DL.Services
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,10 +215,11 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
using (SqliteCommand checkCmd = new($"SELECT user_id, username FROM users WHERE user_id = @userId;", connection))
|
using (SqliteCommand checkCmd = new("SELECT user_id, username FROM users WHERE user_id = @userId;",
|
||||||
|
connection))
|
||||||
{
|
{
|
||||||
checkCmd.Parameters.AddWithValue("@userId", user.Value);
|
checkCmd.Parameters.AddWithValue("@userId", user.Value);
|
||||||
using (var reader = await checkCmd.ExecuteReaderAsync())
|
using (SqliteDataReader reader = await checkCmd.ExecuteReaderAsync())
|
||||||
{
|
{
|
||||||
if (reader.Read())
|
if (reader.Read())
|
||||||
{
|
{
|
||||||
@ -196,7 +228,8 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
if (storedUsername != user.Key)
|
if (storedUsername != user.Key)
|
||||||
{
|
{
|
||||||
using (SqliteCommand updateCmd = new($"UPDATE users SET username = @newUsername WHERE user_id = @userId;", connection))
|
using (SqliteCommand updateCmd =
|
||||||
|
new("UPDATE users SET username = @newUsername WHERE user_id = @userId;", connection))
|
||||||
{
|
{
|
||||||
updateCmd.Parameters.AddWithValue("@newUsername", user.Key);
|
updateCmd.Parameters.AddWithValue("@newUsername", user.Key);
|
||||||
updateCmd.Parameters.AddWithValue("@userId", user.Value);
|
updateCmd.Parameters.AddWithValue("@userId", user.Value);
|
||||||
@ -223,26 +256,32 @@ namespace OF_DL.Services
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddMessage(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at, long user_id)
|
public async Task AddMessage(string folder, long post_id, string message_text, string price, bool is_paid,
|
||||||
|
bool is_archived, DateTime created_at, long user_id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
||||||
connection.Open();
|
connection.Open();
|
||||||
await EnsureCreatedAtColumnExists(connection, "messages");
|
await EnsureCreatedAtColumnExists(connection, "messages");
|
||||||
using SqliteCommand cmd = new($"SELECT COUNT(*) FROM messages WHERE post_id=@post_id", connection);
|
using SqliteCommand cmd = new("SELECT COUNT(*) FROM messages WHERE post_id=@post_id", connection);
|
||||||
cmd.Parameters.AddWithValue("@post_id", post_id);
|
cmd.Parameters.AddWithValue("@post_id", post_id);
|
||||||
int count = Convert.ToInt32(await cmd.ExecuteScalarAsync());
|
int count = Convert.ToInt32(await cmd.ExecuteScalarAsync());
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
// If the record doesn't exist, insert a new one
|
// If the record doesn't exist, insert a new one
|
||||||
using SqliteCommand insertCmd = new("INSERT INTO messages(post_id, text, price, paid, archived, created_at, user_id, record_created_at) VALUES(@post_id, @message_text, @price, @is_paid, @is_archived, @created_at, @user_id, @record_created_at)", connection);
|
using SqliteCommand insertCmd =
|
||||||
|
new(
|
||||||
|
"INSERT INTO messages(post_id, text, price, paid, archived, created_at, user_id, record_created_at) VALUES(@post_id, @message_text, @price, @is_paid, @is_archived, @created_at, @user_id, @record_created_at)",
|
||||||
|
connection);
|
||||||
insertCmd.Parameters.AddWithValue("@post_id", post_id);
|
insertCmd.Parameters.AddWithValue("@post_id", post_id);
|
||||||
insertCmd.Parameters.AddWithValue("@message_text", message_text ?? (object)DBNull.Value);
|
insertCmd.Parameters.AddWithValue("@message_text", message_text ?? (object)DBNull.Value);
|
||||||
insertCmd.Parameters.AddWithValue("@price", price ?? (object)DBNull.Value);
|
insertCmd.Parameters.AddWithValue("@price", price ?? (object)DBNull.Value);
|
||||||
@ -261,27 +300,33 @@ namespace OF_DL.Services
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task AddPost(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at)
|
public async Task AddPost(string folder, long post_id, string message_text, string price, bool is_paid,
|
||||||
|
bool is_archived, DateTime created_at)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
||||||
connection.Open();
|
connection.Open();
|
||||||
await EnsureCreatedAtColumnExists(connection, "posts");
|
await EnsureCreatedAtColumnExists(connection, "posts");
|
||||||
using SqliteCommand cmd = new($"SELECT COUNT(*) FROM posts WHERE post_id=@post_id", connection);
|
using SqliteCommand cmd = new("SELECT COUNT(*) FROM posts WHERE post_id=@post_id", connection);
|
||||||
cmd.Parameters.AddWithValue("@post_id", post_id);
|
cmd.Parameters.AddWithValue("@post_id", post_id);
|
||||||
int count = Convert.ToInt32(await cmd.ExecuteScalarAsync());
|
int count = Convert.ToInt32(await cmd.ExecuteScalarAsync());
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
// If the record doesn't exist, insert a new one
|
// If the record doesn't exist, insert a new one
|
||||||
using SqliteCommand insertCmd = new("INSERT INTO posts(post_id, text, price, paid, archived, created_at, record_created_at) VALUES(@post_id, @message_text, @price, @is_paid, @is_archived, @created_at, @record_created_at)", connection);
|
using SqliteCommand insertCmd =
|
||||||
|
new(
|
||||||
|
"INSERT INTO posts(post_id, text, price, paid, archived, created_at, record_created_at) VALUES(@post_id, @message_text, @price, @is_paid, @is_archived, @created_at, @record_created_at)",
|
||||||
|
connection);
|
||||||
insertCmd.Parameters.AddWithValue("@post_id", post_id);
|
insertCmd.Parameters.AddWithValue("@post_id", post_id);
|
||||||
insertCmd.Parameters.AddWithValue("@message_text", message_text ?? (object)DBNull.Value);
|
insertCmd.Parameters.AddWithValue("@message_text", message_text ?? (object)DBNull.Value);
|
||||||
insertCmd.Parameters.AddWithValue("@price", price ?? (object)DBNull.Value);
|
insertCmd.Parameters.AddWithValue("@price", price ?? (object)DBNull.Value);
|
||||||
@ -299,27 +344,33 @@ namespace OF_DL.Services
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task AddStory(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at)
|
public async Task AddStory(string folder, long post_id, string message_text, string price, bool is_paid,
|
||||||
|
bool is_archived, DateTime created_at)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
||||||
connection.Open();
|
connection.Open();
|
||||||
await EnsureCreatedAtColumnExists(connection, "stories");
|
await EnsureCreatedAtColumnExists(connection, "stories");
|
||||||
using SqliteCommand cmd = new($"SELECT COUNT(*) FROM stories WHERE post_id=@post_id", connection);
|
using SqliteCommand cmd = new("SELECT COUNT(*) FROM stories WHERE post_id=@post_id", connection);
|
||||||
cmd.Parameters.AddWithValue("@post_id", post_id);
|
cmd.Parameters.AddWithValue("@post_id", post_id);
|
||||||
int count = Convert.ToInt32(await cmd.ExecuteScalarAsync());
|
int count = Convert.ToInt32(await cmd.ExecuteScalarAsync());
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
// If the record doesn't exist, insert a new one
|
// If the record doesn't exist, insert a new one
|
||||||
using SqliteCommand insertCmd = new("INSERT INTO stories(post_id, text, price, paid, archived, created_at, record_created_at) VALUES(@post_id, @message_text, @price, @is_paid, @is_archived, @created_at, @record_created_at)", connection);
|
using SqliteCommand insertCmd =
|
||||||
|
new(
|
||||||
|
"INSERT INTO stories(post_id, text, price, paid, archived, created_at, record_created_at) VALUES(@post_id, @message_text, @price, @is_paid, @is_archived, @created_at, @record_created_at)",
|
||||||
|
connection);
|
||||||
insertCmd.Parameters.AddWithValue("@post_id", post_id);
|
insertCmd.Parameters.AddWithValue("@post_id", post_id);
|
||||||
insertCmd.Parameters.AddWithValue("@message_text", message_text ?? (object)DBNull.Value);
|
insertCmd.Parameters.AddWithValue("@message_text", message_text ?? (object)DBNull.Value);
|
||||||
insertCmd.Parameters.AddWithValue("@price", price ?? (object)DBNull.Value);
|
insertCmd.Parameters.AddWithValue("@price", price ?? (object)DBNull.Value);
|
||||||
@ -337,21 +388,25 @@ namespace OF_DL.Services
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task AddMedia(string folder, long media_id, long post_id, string link, string? directory, string? filename, long? size, string api_type, string media_type, bool preview, bool downloaded, DateTime? created_at)
|
public async Task AddMedia(string folder, long media_id, long post_id, string link, string? directory,
|
||||||
|
string? filename, long? size, string api_type, string media_type, bool preview, bool downloaded,
|
||||||
|
DateTime? created_at)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
||||||
connection.Open();
|
connection.Open();
|
||||||
await EnsureCreatedAtColumnExists(connection, "medias");
|
await EnsureCreatedAtColumnExists(connection, "medias");
|
||||||
StringBuilder sql = new StringBuilder("SELECT COUNT(*) FROM medias WHERE media_id=@media_id");
|
StringBuilder sql = new("SELECT COUNT(*) FROM medias WHERE media_id=@media_id");
|
||||||
if (configService.CurrentConfig.DownloadDuplicatedMedia)
|
if (configService.CurrentConfig.DownloadDuplicatedMedia)
|
||||||
{
|
{
|
||||||
sql.Append(" and api_type=@api_type");
|
sql.Append(" and api_type=@api_type");
|
||||||
@ -364,7 +419,9 @@ namespace OF_DL.Services
|
|||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
// If the record doesn't exist, insert a new one
|
// If the record doesn't exist, insert a new one
|
||||||
using SqliteCommand insertCmd = new($"INSERT INTO medias(media_id, post_id, link, directory, filename, size, api_type, media_type, preview, downloaded, created_at, record_created_at) VALUES({media_id}, {post_id}, '{link}', '{directory?.ToString() ?? "NULL"}', '{filename?.ToString() ?? "NULL"}', {size?.ToString() ?? "NULL"}, '{api_type}', '{media_type}', {Convert.ToInt32(preview)}, {Convert.ToInt32(downloaded)}, '{created_at?.ToString("yyyy-MM-dd HH:mm:ss")}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')", connection);
|
using SqliteCommand insertCmd = new(
|
||||||
|
$"INSERT INTO medias(media_id, post_id, link, directory, filename, size, api_type, media_type, preview, downloaded, created_at, record_created_at) VALUES({media_id}, {post_id}, '{link}', '{directory ?? "NULL"}', '{filename ?? "NULL"}', {size?.ToString() ?? "NULL"}, '{api_type}', '{media_type}', {Convert.ToInt32(preview)}, {Convert.ToInt32(downloaded)}, '{created_at?.ToString("yyyy-MM-dd HH:mm:ss")}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')",
|
||||||
|
connection);
|
||||||
await insertCmd.ExecuteNonQueryAsync();
|
await insertCmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -375,8 +432,10 @@ namespace OF_DL.Services
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,18 +449,19 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
using (SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db"))
|
using (SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db"))
|
||||||
{
|
{
|
||||||
StringBuilder sql = new StringBuilder("SELECT downloaded FROM medias WHERE media_id=@media_id");
|
StringBuilder sql = new("SELECT downloaded FROM medias WHERE media_id=@media_id");
|
||||||
if(configService.CurrentConfig.DownloadDuplicatedMedia)
|
if (configService.CurrentConfig.DownloadDuplicatedMedia)
|
||||||
{
|
{
|
||||||
sql.Append(" and api_type=@api_type");
|
sql.Append(" and api_type=@api_type");
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.Open();
|
connection.Open();
|
||||||
using SqliteCommand cmd = new (sql.ToString(), connection);
|
using SqliteCommand cmd = new(sql.ToString(), connection);
|
||||||
cmd.Parameters.AddWithValue("@media_id", media_id);
|
cmd.Parameters.AddWithValue("@media_id", media_id);
|
||||||
cmd.Parameters.AddWithValue("@api_type", api_type);
|
cmd.Parameters.AddWithValue("@api_type", api_type);
|
||||||
downloaded = Convert.ToBoolean(await cmd.ExecuteScalarAsync());
|
downloaded = Convert.ToBoolean(await cmd.ExecuteScalarAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
return downloaded;
|
return downloaded;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -411,21 +471,27 @@ namespace OF_DL.Services
|
|||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nInner Exception:");
|
Console.WriteLine("\nInner Exception:");
|
||||||
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message, ex.InnerException.StackTrace);
|
ex.InnerException.StackTrace);
|
||||||
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
||||||
|
ex.InnerException.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task UpdateMedia(string folder, long media_id, string api_type, string directory, string filename, long size, bool downloaded, DateTime created_at)
|
public async Task UpdateMedia(string folder, long media_id, string api_type, string directory, string filename,
|
||||||
|
long size, bool downloaded, DateTime created_at)
|
||||||
{
|
{
|
||||||
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
using SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db");
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
// Construct the update command
|
// Construct the update command
|
||||||
StringBuilder sql = new StringBuilder("UPDATE medias SET directory=@directory, filename=@filename, size=@size, downloaded=@downloaded, created_at=@created_at WHERE media_id=@media_id");
|
StringBuilder sql =
|
||||||
|
new(
|
||||||
|
"UPDATE medias SET directory=@directory, filename=@filename, size=@size, downloaded=@downloaded, created_at=@created_at WHERE media_id=@media_id");
|
||||||
if (configService.CurrentConfig.DownloadDuplicatedMedia)
|
if (configService.CurrentConfig.DownloadDuplicatedMedia)
|
||||||
{
|
{
|
||||||
sql.Append(" and api_type=@api_type");
|
sql.Append(" and api_type=@api_type");
|
||||||
@ -453,11 +519,13 @@ namespace OF_DL.Services
|
|||||||
using (SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db"))
|
using (SqliteConnection connection = new($"Data Source={folder}/Metadata/user_data.db"))
|
||||||
{
|
{
|
||||||
connection.Open();
|
connection.Open();
|
||||||
using SqliteCommand cmd = new($"SELECT size FROM medias WHERE media_id=@media_id and api_type=@api_type", connection);
|
using SqliteCommand cmd = new("SELECT size FROM medias WHERE media_id=@media_id and api_type=@api_type",
|
||||||
|
connection);
|
||||||
cmd.Parameters.AddWithValue("@media_id", media_id);
|
cmd.Parameters.AddWithValue("@media_id", media_id);
|
||||||
cmd.Parameters.AddWithValue("@api_type", api_type);
|
cmd.Parameters.AddWithValue("@api_type", api_type);
|
||||||
size = Convert.ToInt64(await cmd.ExecuteScalarAsync());
|
size = Convert.ToInt64(await cmd.ExecuteScalarAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,19 +551,20 @@ namespace OF_DL.Services
|
|||||||
ON P.post_id = m.post_id
|
ON P.post_id = m.post_id
|
||||||
WHERE m.downloaded = 0
|
WHERE m.downloaded = 0
|
||||||
)", connection);
|
)", connection);
|
||||||
var scalarValue = await cmd.ExecuteScalarAsync();
|
object? scalarValue = await cmd.ExecuteScalarAsync();
|
||||||
if(scalarValue != null && scalarValue != DBNull.Value)
|
if (scalarValue != null && scalarValue != DBNull.Value)
|
||||||
{
|
{
|
||||||
mostRecentDate = Convert.ToDateTime(scalarValue);
|
mostRecentDate = Convert.ToDateTime(scalarValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mostRecentDate;
|
return mostRecentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task EnsureCreatedAtColumnExists(SqliteConnection connection, string tableName)
|
private async Task EnsureCreatedAtColumnExists(SqliteConnection connection, string tableName)
|
||||||
{
|
{
|
||||||
using SqliteCommand cmd = new($"PRAGMA table_info({tableName});", connection);
|
using SqliteCommand cmd = new($"PRAGMA table_info({tableName});", connection);
|
||||||
using var reader = await cmd.ExecuteReaderAsync();
|
using SqliteDataReader reader = await cmd.ExecuteReaderAsync();
|
||||||
bool columnExists = false;
|
bool columnExists = false;
|
||||||
|
|
||||||
while (await reader.ReadAsync())
|
while (await reader.ReadAsync())
|
||||||
@ -509,9 +578,9 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
if (!columnExists)
|
if (!columnExists)
|
||||||
{
|
{
|
||||||
using SqliteCommand alterCmd = new($"ALTER TABLE {tableName} ADD COLUMN record_created_at TIMESTAMP;", connection);
|
using SqliteCommand alterCmd = new($"ALTER TABLE {tableName} ADD COLUMN record_created_at TIMESTAMP;",
|
||||||
|
connection);
|
||||||
await alterCmd.ExecuteNonQueryAsync();
|
await alterCmd.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,12 @@
|
|||||||
using HtmlAgilityPack;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using HtmlAgilityPack;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public class FileNameService(IAuthService authService) : IFileNameService
|
||||||
{
|
{
|
||||||
public class FileNameService(IAuthService authService) : IFileNameService
|
public async Task<Dictionary<string, string>> GetFilename(object obj1, object obj2, object obj3,
|
||||||
{
|
List<string> selectedProperties, string username, Dictionary<string, long> users = null)
|
||||||
public async Task<Dictionary<string, string>> GetFilename(object obj1, object obj2, object obj3, List<string> selectedProperties, string username, Dictionary<string, long> users = null)
|
|
||||||
{
|
{
|
||||||
Dictionary<string, string> values = new();
|
Dictionary<string, string> values = new();
|
||||||
Type type1 = obj1.GetType();
|
Type type1 = obj1.GetType();
|
||||||
@ -19,34 +20,36 @@ namespace OF_DL.Services
|
|||||||
{
|
{
|
||||||
object drmProperty = null;
|
object drmProperty = null;
|
||||||
object fileProperty = GetNestedPropertyValue(obj2, "files");
|
object fileProperty = GetNestedPropertyValue(obj2, "files");
|
||||||
if(fileProperty != null)
|
if (fileProperty != null)
|
||||||
{
|
{
|
||||||
drmProperty = GetNestedPropertyValue(obj2, "files.drm");
|
drmProperty = GetNestedPropertyValue(obj2, "files.drm");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileProperty != null && drmProperty != null && propertyName == "mediaCreatedAt")
|
if (fileProperty != null && drmProperty != null && propertyName == "mediaCreatedAt")
|
||||||
{
|
{
|
||||||
object mpdurl = GetNestedPropertyValue(obj2, "files.drm.manifest.dash");
|
object mpdurl = GetNestedPropertyValue(obj2, "files.drm.manifest.dash");
|
||||||
object policy = GetNestedPropertyValue(obj2, "files.drm.signature.dash.CloudFrontPolicy");
|
object policy = GetNestedPropertyValue(obj2, "files.drm.signature.dash.CloudFrontPolicy");
|
||||||
object signature = GetNestedPropertyValue(obj2, "files.drm.signature.dash.CloudFrontSignature");
|
object signature = GetNestedPropertyValue(obj2, "files.drm.signature.dash.CloudFrontSignature");
|
||||||
object kvp = GetNestedPropertyValue(obj2, "files.drm.signature.dash.CloudFrontKeyPairId");
|
object kvp = GetNestedPropertyValue(obj2, "files.drm.signature.dash.CloudFrontKeyPairId");
|
||||||
DateTime lastModified = await DownloadService.GetDRMVideoLastModified(string.Join(",", mpdurl, policy, signature, kvp), authService.CurrentAuth);
|
DateTime lastModified =
|
||||||
|
await DownloadService.GetDRMVideoLastModified(string.Join(",", mpdurl, policy, signature, kvp),
|
||||||
|
authService.CurrentAuth);
|
||||||
values.Add(propertyName, lastModified.ToString("yyyy-MM-dd"));
|
values.Add(propertyName, lastModified.ToString("yyyy-MM-dd"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if((fileProperty == null || drmProperty == null) && propertyName == "mediaCreatedAt")
|
|
||||||
|
if ((fileProperty == null || drmProperty == null) && propertyName == "mediaCreatedAt")
|
||||||
{
|
{
|
||||||
object source = GetNestedPropertyValue(obj2, "files.full.url");
|
object source = GetNestedPropertyValue(obj2, "files.full.url");
|
||||||
if(source != null)
|
if (source != null)
|
||||||
{
|
{
|
||||||
DateTime lastModified = await DownloadService.GetMediaLastModified(source.ToString());
|
DateTime lastModified = await DownloadService.GetMediaLastModified(source.ToString());
|
||||||
values.Add(propertyName, lastModified.ToString("yyyy-MM-dd"));
|
values.Add(propertyName, lastModified.ToString("yyyy-MM-dd"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
object preview = GetNestedPropertyValue(obj2, "preview");
|
object preview = GetNestedPropertyValue(obj2, "preview");
|
||||||
if(preview != null)
|
if (preview != null)
|
||||||
{
|
{
|
||||||
DateTime lastModified = await DownloadService.GetMediaLastModified(preview.ToString());
|
DateTime lastModified = await DownloadService.GetMediaLastModified(preview.ToString());
|
||||||
values.Add(propertyName, lastModified.ToString("yyyy-MM-dd"));
|
values.Add(propertyName, lastModified.ToString("yyyy-MM-dd"));
|
||||||
@ -54,8 +57,8 @@ namespace OF_DL.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
PropertyInfo? property = Array.Find(properties2,
|
||||||
PropertyInfo? property = Array.Find(properties2, p => p.Name.Equals(propertyName.Replace("media", ""), StringComparison.OrdinalIgnoreCase));
|
p => p.Name.Equals(propertyName.Replace("media", ""), StringComparison.OrdinalIgnoreCase));
|
||||||
if (property != null)
|
if (property != null)
|
||||||
{
|
{
|
||||||
object? propertyValue = property.GetValue(obj2);
|
object? propertyValue = property.GetValue(obj2);
|
||||||
@ -79,7 +82,7 @@ namespace OF_DL.Services
|
|||||||
if (sourcePropertyValue != null)
|
if (sourcePropertyValue != null)
|
||||||
{
|
{
|
||||||
Uri uri = new(sourcePropertyValue.ToString());
|
Uri uri = new(sourcePropertyValue.ToString());
|
||||||
string filename = System.IO.Path.GetFileName(uri.LocalPath);
|
string filename = Path.GetFileName(uri.LocalPath);
|
||||||
values.Add(propertyName, filename.Split(".")[0]);
|
values.Add(propertyName, filename.Split(".")[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -89,14 +92,14 @@ namespace OF_DL.Services
|
|||||||
if (nestedPropertyValue != null)
|
if (nestedPropertyValue != null)
|
||||||
{
|
{
|
||||||
Uri uri = new(nestedPropertyValue.ToString());
|
Uri uri = new(nestedPropertyValue.ToString());
|
||||||
string filename = System.IO.Path.GetFileName(uri.LocalPath);
|
string filename = Path.GetFileName(uri.LocalPath);
|
||||||
values.Add(propertyName, filename.Split(".")[0] + "_source");
|
values.Add(propertyName, filename.Split(".")[0] + "_source");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (propertyName.Contains("username"))
|
else if (propertyName.Contains("username"))
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrEmpty(username))
|
if (!string.IsNullOrEmpty(username))
|
||||||
{
|
{
|
||||||
values.Add(propertyName, username);
|
values.Add(propertyName, username);
|
||||||
}
|
}
|
||||||
@ -106,30 +109,36 @@ namespace OF_DL.Services
|
|||||||
object nestedPropertyValue = GetNestedPropertyValue(obj3, propertyPath);
|
object nestedPropertyValue = GetNestedPropertyValue(obj3, propertyPath);
|
||||||
if (nestedPropertyValue != null)
|
if (nestedPropertyValue != null)
|
||||||
{
|
{
|
||||||
values.Add(propertyName, users.FirstOrDefault(u => u.Value == Convert.ToInt32(nestedPropertyValue.ToString())).Key);
|
values.Add(propertyName,
|
||||||
|
users.FirstOrDefault(u => u.Value == Convert.ToInt32(nestedPropertyValue.ToString())).Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (propertyName.Contains("text", StringComparison.OrdinalIgnoreCase))
|
else if (propertyName.Contains("text", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
PropertyInfo property = Array.Find(properties1, p => p.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase));
|
PropertyInfo property = Array.Find(properties1,
|
||||||
|
p => p.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase));
|
||||||
if (property != null)
|
if (property != null)
|
||||||
{
|
{
|
||||||
object propertyValue = property.GetValue(obj1);
|
object propertyValue = property.GetValue(obj1);
|
||||||
if (propertyValue != null)
|
if (propertyValue != null)
|
||||||
{
|
{
|
||||||
var pageDoc = new HtmlDocument();
|
HtmlDocument pageDoc = new();
|
||||||
pageDoc.LoadHtml(propertyValue.ToString());
|
pageDoc.LoadHtml(propertyValue.ToString());
|
||||||
var str = pageDoc.DocumentNode.InnerText;
|
string str = pageDoc.DocumentNode.InnerText;
|
||||||
if (str.Length > 100) // todo: add length limit to config
|
if (str.Length > 100) // todo: add length limit to config
|
||||||
|
{
|
||||||
str = str.Substring(0, 100);
|
str = str.Substring(0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
values.Add(propertyName, str);
|
values.Add(propertyName, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PropertyInfo property = Array.Find(properties1, p => p.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase));
|
PropertyInfo property = Array.Find(properties1,
|
||||||
|
p => p.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase));
|
||||||
if (property != null)
|
if (property != null)
|
||||||
{
|
{
|
||||||
object propertyValue = property.GetValue(obj1);
|
object propertyValue = property.GetValue(obj1);
|
||||||
@ -147,23 +156,13 @@ namespace OF_DL.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
static object GetNestedPropertyValue(object source, string propertyPath)
|
return values;
|
||||||
{
|
|
||||||
object value = source;
|
|
||||||
foreach (var propertyName in propertyPath.Split('.'))
|
|
||||||
{
|
|
||||||
PropertyInfo property = value.GetType().GetProperty(propertyName) ?? throw new ArgumentException($"Property '{propertyName}' not found.");
|
|
||||||
value = property.GetValue(value);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> BuildFilename(string fileFormat, Dictionary<string, string> values)
|
public async Task<string> BuildFilename(string fileFormat, Dictionary<string, string> values)
|
||||||
{
|
{
|
||||||
foreach (var kvp in values)
|
foreach (KeyValuePair<string, string> kvp in values)
|
||||||
{
|
{
|
||||||
string placeholder = "{" + kvp.Key + "}";
|
string placeholder = "{" + kvp.Key + "}";
|
||||||
fileFormat = fileFormat.Replace(placeholder, kvp.Value);
|
fileFormat = fileFormat.Replace(placeholder, kvp.Value);
|
||||||
@ -172,10 +171,20 @@ namespace OF_DL.Services
|
|||||||
return RemoveInvalidFileNameChars($"{fileFormat}");
|
return RemoveInvalidFileNameChars($"{fileFormat}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string RemoveInvalidFileNameChars(string fileName)
|
private static object GetNestedPropertyValue(object source, string propertyPath)
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(fileName) ? fileName : string.Concat(fileName.Split(Path.GetInvalidFileNameChars()));
|
object value = source;
|
||||||
|
foreach (string propertyName in propertyPath.Split('.'))
|
||||||
|
{
|
||||||
|
PropertyInfo property = value.GetType().GetProperty(propertyName) ??
|
||||||
|
throw new ArgumentException($"Property '{propertyName}' not found.");
|
||||||
|
value = property.GetValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string RemoveInvalidFileNameChars(string fileName) => string.IsNullOrEmpty(fileName)
|
||||||
|
? fileName
|
||||||
|
: string.Concat(fileName.Split(Path.GetInvalidFileNameChars()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,18 +8,23 @@ using OF_DL.Entities.Streams;
|
|||||||
using OF_DL.Enumerations;
|
using OF_DL.Enumerations;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public interface IAPIService
|
||||||
{
|
{
|
||||||
public interface IAPIService
|
|
||||||
{
|
|
||||||
Task<string> GetDecryptionKeyCDRMProject(Dictionary<string, string> drmHeaders, string licenceURL, string pssh);
|
Task<string> GetDecryptionKeyCDRMProject(Dictionary<string, string> drmHeaders, string licenceURL, string pssh);
|
||||||
Task<string> GetDecryptionKeyCDM(Dictionary<string, string> drmHeaders, string licenceURL, string pssh);
|
Task<string> GetDecryptionKeyCDM(Dictionary<string, string> drmHeaders, string licenceURL, string pssh);
|
||||||
Task<DateTime> GetDRMMPDLastModified(string mpdUrl, string policy, string signature, string kvp);
|
Task<DateTime> GetDRMMPDLastModified(string mpdUrl, string policy, string signature, string kvp);
|
||||||
Task<string> GetDRMMPDPSSH(string mpdUrl, string policy, string signature, string kvp);
|
Task<string> GetDRMMPDPSSH(string mpdUrl, string policy, string signature, string kvp);
|
||||||
Task<Dictionary<string, long>> GetLists(string endpoint);
|
Task<Dictionary<string, long>> GetLists(string endpoint);
|
||||||
Task<List<string>> GetListUsers(string endpoint);
|
Task<List<string>> GetListUsers(string endpoint);
|
||||||
Task<Dictionary<long, string>> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, List<long> paid_post_ids);
|
|
||||||
Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, List<long> paid_post_ids, StatusContext ctx);
|
Task<Dictionary<long, string>> GetMedia(MediaType mediatype, string endpoint, string? username, string folder,
|
||||||
|
List<long> paid_post_ids);
|
||||||
|
|
||||||
|
Task<PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username, List<long> paid_post_ids,
|
||||||
|
StatusContext ctx);
|
||||||
|
|
||||||
Task<PostCollection> GetPosts(string endpoint, string folder, List<long> paid_post_ids, StatusContext ctx);
|
Task<PostCollection> GetPosts(string endpoint, string folder, List<long> paid_post_ids, StatusContext ctx);
|
||||||
Task<SinglePostCollection> GetPost(string endpoint, string folder);
|
Task<SinglePostCollection> GetPost(string endpoint, string folder);
|
||||||
Task<StreamsCollection> GetStreams(string endpoint, string folder, List<long> paid_post_ids, StatusContext ctx);
|
Task<StreamsCollection> GetStreams(string endpoint, string folder, List<long> paid_post_ids, StatusContext ctx);
|
||||||
@ -35,5 +40,4 @@ namespace OF_DL.Services
|
|||||||
Task<Dictionary<string, long>> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions);
|
Task<Dictionary<string, long>> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions);
|
||||||
Task<Dictionary<string, long>> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions);
|
Task<Dictionary<string, long>> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions);
|
||||||
Task<string> GetDecryptionKeyOFDL(Dictionary<string, string> drmHeaders, string licenceURL, string pssh);
|
Task<string> GetDecryptionKeyOFDL(Dictionary<string, string> drmHeaders, string licenceURL, string pssh);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
using OF_DL.Entities;
|
using OF_DL.Entities;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public interface IAuthService
|
||||||
{
|
{
|
||||||
public interface IAuthService
|
|
||||||
{
|
|
||||||
Auth? CurrentAuth { get; set; }
|
Auth? CurrentAuth { get; set; }
|
||||||
Task<bool> LoadFromFileAsync(string filePath = "auth.json");
|
Task<bool> LoadFromFileAsync(string filePath = "auth.json");
|
||||||
Task<bool> LoadFromBrowserAsync();
|
Task<bool> LoadFromBrowserAsync();
|
||||||
Task SaveToFileAsync(string filePath = "auth.json");
|
Task SaveToFileAsync(string filePath = "auth.json");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
using OF_DL.Entities;
|
using OF_DL.Entities;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public interface IConfigService
|
||||||
{
|
{
|
||||||
public interface IConfigService
|
|
||||||
{
|
|
||||||
Config CurrentConfig { get; }
|
Config CurrentConfig { get; }
|
||||||
bool IsCliNonInteractive { get; }
|
bool IsCliNonInteractive { get; }
|
||||||
Task<bool> LoadConfigurationAsync(string[] args);
|
Task<bool> LoadConfigurationAsync(string[] args);
|
||||||
Task SaveConfigurationAsync(string filePath = "config.conf");
|
Task SaveConfigurationAsync(string filePath = "config.conf");
|
||||||
void UpdateConfig(Config newConfig);
|
void UpdateConfig(Config newConfig);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,27 @@
|
|||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public interface IDBService
|
||||||
{
|
{
|
||||||
public interface IDBService
|
Task AddMessage(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived,
|
||||||
{
|
DateTime created_at, long user_id);
|
||||||
Task AddMessage(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at, long user_id);
|
|
||||||
Task AddPost(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at);
|
Task AddPost(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived,
|
||||||
Task AddStory(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived, DateTime created_at);
|
DateTime created_at);
|
||||||
|
|
||||||
|
Task AddStory(string folder, long post_id, string message_text, string price, bool is_paid, bool is_archived,
|
||||||
|
DateTime created_at);
|
||||||
|
|
||||||
Task CreateDB(string folder);
|
Task CreateDB(string folder);
|
||||||
Task CreateUsersDB(Dictionary<string, long> users);
|
Task CreateUsersDB(Dictionary<string, long> users);
|
||||||
Task CheckUsername(KeyValuePair<string, long> user, string path);
|
Task CheckUsername(KeyValuePair<string, long> user, string path);
|
||||||
Task AddMedia(string folder, long media_id, long post_id, string link, string? directory, string? filename, long? size, string api_type, string media_type, bool preview, bool downloaded, DateTime? created_at);
|
|
||||||
Task UpdateMedia(string folder, long media_id, string api_type, string directory, string filename, long size, bool downloaded, DateTime created_at);
|
Task AddMedia(string folder, long media_id, long post_id, string link, string? directory, string? filename,
|
||||||
|
long? size, string api_type, string media_type, bool preview, bool downloaded, DateTime? created_at);
|
||||||
|
|
||||||
|
Task UpdateMedia(string folder, long media_id, string api_type, string directory, string filename, long size,
|
||||||
|
bool downloaded, DateTime created_at);
|
||||||
|
|
||||||
Task<long> GetStoredFileSize(string folder, long media_id, string api_type);
|
Task<long> GetStoredFileSize(string folder, long media_id, string api_type);
|
||||||
Task<bool> CheckDownloaded(string folder, long media_id, string api_type);
|
Task<bool> CheckDownloaded(string folder, long media_id, string api_type);
|
||||||
Task<DateTime?> GetMostRecentPostDate(string folder);
|
Task<DateTime?> GetMostRecentPostDate(string folder);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,44 +7,128 @@ using OF_DL.Entities.Streams;
|
|||||||
using static OF_DL.Entities.Messages.Messages;
|
using static OF_DL.Entities.Messages.Messages;
|
||||||
using FromUser = OF_DL.Entities.Messages.FromUser;
|
using FromUser = OF_DL.Entities.Messages.FromUser;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public interface IDownloadService
|
||||||
{
|
{
|
||||||
public interface IDownloadService
|
|
||||||
{
|
|
||||||
Task<long> CalculateTotalFileSize(List<string> urls);
|
Task<long> CalculateTotalFileSize(List<string> urls);
|
||||||
Task<bool> ProcessMediaDownload(string folder, long media_id, string api_type, string url, string path, string serverFileName, string resolvedFileName, string extension, IProgressReporter progressReporter);
|
|
||||||
Task<bool> DownloadArchivedMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Archived.List? messageInfo, Archived.Medium? messageMedia, Archived.Author? author, Dictionary<string, long> users);
|
Task<bool> ProcessMediaDownload(string folder, long media_id, string api_type, string url, string path,
|
||||||
Task<bool> DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Archived.List? postInfo, Archived.Medium? postMedia, Archived.Author? author, Dictionary<string, long> users);
|
string serverFileName, string resolvedFileName, string extension, IProgressReporter progressReporter);
|
||||||
Task<bool> DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter, string filenameFormat, SinglePost postInfo, SinglePost.Medium postMedia, SinglePost.Author author, Dictionary<string, long> users);
|
|
||||||
Task<bool> DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author, Dictionary<string, long> users);
|
Task<bool> DownloadArchivedMedia(string url, string folder, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, Archived.List? messageInfo,
|
||||||
|
Archived.Medium? messageMedia, Archived.Author? author, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadArchivedPostDRMVideo(string policy, string signature, string kvp, string url,
|
||||||
|
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, Archived.List? postInfo, Archived.Medium? postMedia,
|
||||||
|
Archived.Author? author, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
|
||||||
|
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
|
||||||
|
string filenameFormat, SinglePost postInfo, SinglePost.Medium postMedia, SinglePost.Author author,
|
||||||
|
Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
|
||||||
|
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
|
||||||
|
string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author,
|
||||||
|
Dictionary<string, long> users);
|
||||||
|
|
||||||
Task DownloadAvatarHeader(string? avatarUrl, string? headerUrl, string folder, string username);
|
Task DownloadAvatarHeader(string? avatarUrl, string? headerUrl, string folder, string username);
|
||||||
Task<bool> DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Messages.List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser, Dictionary<string, long> users);
|
|
||||||
Task<bool> DownloadMessageMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Messages.List? messageInfo, Messages.Medium? messageMedia, Messages.FromUser? fromUser, Dictionary<string, long> users);
|
Task<bool> DownloadMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
|
||||||
Task<bool> DownloadPostMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia, Post.Author? author, Dictionary<string, long> users);
|
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
|
||||||
Task<bool> DownloadPostMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, SinglePost? postInfo, SinglePost.Medium? postMedia, SinglePost.Author? author, Dictionary<string, long> users);
|
string? filenameFormat, List? messageInfo, Medium? messageMedia, Messages.FromUser? fromUser,
|
||||||
Task<bool> DownloadPurchasedMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia, Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
Dictionary<string, long> users);
|
||||||
Task<bool> DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary<string, long> users);
|
|
||||||
Task<bool> DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia, Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
Task<bool> DownloadMessageMedia(string url, string folder, long media_id, string api_type,
|
||||||
Task<bool> DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia, Entities.Messages.FromUser? fromUser, Dictionary<string, long> users);
|
IProgressReporter progressReporter, string? filenameFormat, List? messageInfo, Medium? messageMedia,
|
||||||
Task<bool> DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Purchased.List? postInfo, Medium? postMedia, Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
Messages.FromUser? fromUser, Dictionary<string, long> users);
|
||||||
Task<bool> DownloadPurchasedPostMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia, Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
|
||||||
Task<bool> DownloadStoryMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter);
|
Task<bool> DownloadPostMedia(string url, string folder, long media_id, string api_type,
|
||||||
Task<bool> DownloadStreamMedia(string url, string folder, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author, Dictionary<string, long> users);
|
IProgressReporter progressReporter, string? filenameFormat, Post.List? postInfo, Post.Medium? postMedia,
|
||||||
Task<bool> DownloadStreamsDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter, string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author, Dictionary<string, long> users);
|
Post.Author? author, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadPostMedia(string url, string folder, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, SinglePost? postInfo, SinglePost.Medium? postMedia,
|
||||||
|
SinglePost.Author? author, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadPurchasedMedia(string url, string folder, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia,
|
||||||
|
Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadSinglePurchasedMedia(string url, string folder, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia,
|
||||||
|
FromUser? fromUser, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadPurchasedMessageDRMVideo(string policy, string signature, string kvp, string url,
|
||||||
|
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia,
|
||||||
|
Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadSinglePurchasedMessageDRMVideo(string policy, string signature, string kvp, string url,
|
||||||
|
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia,
|
||||||
|
FromUser? fromUser, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadPurchasedPostDRMVideo(string policy, string signature, string kvp, string url,
|
||||||
|
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? postInfo, Medium? postMedia,
|
||||||
|
Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadPurchasedPostMedia(string url, string folder, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, Purchased.List? messageInfo, Medium? messageMedia,
|
||||||
|
Purchased.FromUser? fromUser, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadStoryMedia(string url, string folder, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter);
|
||||||
|
|
||||||
|
Task<bool> DownloadStreamMedia(string url, string folder, long media_id, string api_type,
|
||||||
|
IProgressReporter progressReporter, string? filenameFormat, Streams.List? streamInfo,
|
||||||
|
Streams.Medium? streamMedia, Streams.Author? author, Dictionary<string, long> users);
|
||||||
|
|
||||||
|
Task<bool> DownloadStreamsDRMVideo(string policy, string signature, string kvp, string url, string decryptionKey,
|
||||||
|
string folder, DateTime lastModified, long media_id, string api_type, IProgressReporter progressReporter,
|
||||||
|
string? filenameFormat, Streams.List? streamInfo, Streams.Medium? streamMedia, Streams.Author? author,
|
||||||
|
Dictionary<string, long> users);
|
||||||
|
|
||||||
Task<bool> DownloadSingleMessagePreviewDRMVideo(string policy, string signature, string kvp, string url,
|
Task<bool> DownloadSingleMessagePreviewDRMVideo(string policy, string signature, string kvp, string url,
|
||||||
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
string decryptionKey, string folder, DateTime lastModified, long media_id, string api_type,
|
||||||
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia,
|
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia,
|
||||||
FromUser? fromUser, Dictionary<string, long> users);
|
FromUser? fromUser, Dictionary<string, long> users);
|
||||||
|
|
||||||
Task<bool> DownloadMessagePreviewMedia(string url, string folder, long media_id, string api_type,
|
Task<bool> DownloadMessagePreviewMedia(string url, string folder, long media_id, string api_type,
|
||||||
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia,
|
IProgressReporter progressReporter, string? filenameFormat, SingleMessage? messageInfo, Medium? messageMedia,
|
||||||
FromUser? fromUser, Dictionary<string, long> users);
|
FromUser? fromUser, Dictionary<string, long> users);
|
||||||
Task<DownloadResult> DownloadHighlights(string username, long userId, string path, HashSet<long> paidPostIds, IProgressReporter progressReporter);
|
|
||||||
Task<DownloadResult> DownloadStories(string username, long userId, string path, HashSet<long> paidPostIds, IProgressReporter progressReporter);
|
Task<DownloadResult> DownloadHighlights(string username, long userId, string path, HashSet<long> paidPostIds,
|
||||||
Task<DownloadResult> DownloadArchived(string username, long userId, string path, Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing, ArchivedCollection archived, IProgressReporter progressReporter);
|
IProgressReporter progressReporter);
|
||||||
Task<DownloadResult> DownloadMessages(string username, long userId, string path, Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing, MessageCollection messages, IProgressReporter progressReporter);
|
|
||||||
Task<DownloadResult> DownloadPaidMessages(string username, string path, Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing, PaidMessageCollection paidMessageCollection, IProgressReporter progressReporter);
|
Task<DownloadResult> DownloadStories(string username, long userId, string path, HashSet<long> paidPostIds,
|
||||||
Task<DownloadResult> DownloadStreams(string username, long userId, string path, Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing, StreamsCollection streams, IProgressReporter progressReporter);
|
IProgressReporter progressReporter);
|
||||||
Task<DownloadResult> DownloadFreePosts(string username, long userId, string path, Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing, PostCollection posts, IProgressReporter progressReporter);
|
|
||||||
Task<DownloadResult> DownloadPaidPosts(string username, long userId, string path, Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing, PaidPostCollection purchasedPosts, IProgressReporter progressReporter);
|
Task<DownloadResult> DownloadArchived(string username, long userId, string path, Dictionary<string, long> users,
|
||||||
}
|
bool clientIdBlobMissing, bool devicePrivateKeyMissing, ArchivedCollection archived,
|
||||||
|
IProgressReporter progressReporter);
|
||||||
|
|
||||||
|
Task<DownloadResult> DownloadMessages(string username, long userId, string path, Dictionary<string, long> users,
|
||||||
|
bool clientIdBlobMissing, bool devicePrivateKeyMissing, MessageCollection messages,
|
||||||
|
IProgressReporter progressReporter);
|
||||||
|
|
||||||
|
Task<DownloadResult> DownloadPaidMessages(string username, string path, Dictionary<string, long> users,
|
||||||
|
bool clientIdBlobMissing, bool devicePrivateKeyMissing, PaidMessageCollection paidMessageCollection,
|
||||||
|
IProgressReporter progressReporter);
|
||||||
|
|
||||||
|
Task<DownloadResult> DownloadStreams(string username, long userId, string path, Dictionary<string, long> users,
|
||||||
|
bool clientIdBlobMissing, bool devicePrivateKeyMissing, StreamsCollection streams,
|
||||||
|
IProgressReporter progressReporter);
|
||||||
|
|
||||||
|
Task<DownloadResult> DownloadFreePosts(string username, long userId, string path, Dictionary<string, long> users,
|
||||||
|
bool clientIdBlobMissing, bool devicePrivateKeyMissing, PostCollection posts,
|
||||||
|
IProgressReporter progressReporter);
|
||||||
|
|
||||||
|
Task<DownloadResult> DownloadPaidPosts(string username, long userId, string path, Dictionary<string, long> users,
|
||||||
|
bool clientIdBlobMissing, bool devicePrivateKeyMissing, PaidPostCollection purchasedPosts,
|
||||||
|
IProgressReporter progressReporter);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public interface IFileNameService
|
||||||
{
|
{
|
||||||
public interface IFileNameService
|
|
||||||
{
|
|
||||||
Task<string> BuildFilename(string fileFormat, Dictionary<string, string> values);
|
Task<string> BuildFilename(string fileFormat, Dictionary<string, string> values);
|
||||||
Task<Dictionary<string, string>> GetFilename(object obj1, object obj2, object obj3, List<string> selectedProperties, string username, Dictionary<string, long> users = null);
|
|
||||||
}
|
Task<Dictionary<string, string>> GetFilename(object obj1, object obj2, object obj3, List<string> selectedProperties,
|
||||||
|
string username, Dictionary<string, long> users = null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
using OF_DL.Enumerations;
|
using OF_DL.Enumerations;
|
||||||
using Serilog.Core;
|
using Serilog.Core;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
|
|
||||||
|
public interface ILoggingService
|
||||||
{
|
{
|
||||||
public interface ILoggingService
|
|
||||||
{
|
|
||||||
LoggingLevelSwitch LevelSwitch { get; }
|
LoggingLevelSwitch LevelSwitch { get; }
|
||||||
void UpdateLoggingLevel(LoggingLevel newLevel);
|
void UpdateLoggingLevel(LoggingLevel newLevel);
|
||||||
LoggingLevel GetCurrentLoggingLevel();
|
LoggingLevel GetCurrentLoggingLevel();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,18 +3,26 @@ using Serilog;
|
|||||||
using Serilog.Core;
|
using Serilog.Core;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace OF_DL.Services
|
namespace OF_DL.Services;
|
||||||
{
|
|
||||||
public class LoggingService : ILoggingService
|
|
||||||
{
|
|
||||||
public LoggingLevelSwitch LevelSwitch { get; }
|
|
||||||
|
|
||||||
|
public class LoggingService : ILoggingService
|
||||||
|
{
|
||||||
public LoggingService()
|
public LoggingService()
|
||||||
{
|
{
|
||||||
LevelSwitch = new LoggingLevelSwitch();
|
LevelSwitch = new LoggingLevelSwitch();
|
||||||
InitializeLogger();
|
InitializeLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoggingLevelSwitch LevelSwitch { get; }
|
||||||
|
|
||||||
|
public void UpdateLoggingLevel(LoggingLevel newLevel)
|
||||||
|
{
|
||||||
|
LevelSwitch.MinimumLevel = (LogEventLevel)newLevel;
|
||||||
|
Log.Debug("Logging level updated to: {LoggingLevel}", newLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoggingLevel GetCurrentLoggingLevel() => (LoggingLevel)LevelSwitch.MinimumLevel;
|
||||||
|
|
||||||
private void InitializeLogger()
|
private void InitializeLogger()
|
||||||
{
|
{
|
||||||
// Set the initial level to Error (until we've read from config)
|
// Set the initial level to Error (until we've read from config)
|
||||||
@ -27,16 +35,4 @@ namespace OF_DL.Services
|
|||||||
|
|
||||||
Log.Debug("Logging service initialized");
|
Log.Debug("Logging service initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateLoggingLevel(LoggingLevel newLevel)
|
|
||||||
{
|
|
||||||
LevelSwitch.MinimumLevel = (LogEventLevel)newLevel;
|
|
||||||
Log.Debug("Logging level updated to: {LoggingLevel}", newLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoggingLevel GetCurrentLoggingLevel()
|
|
||||||
{
|
|
||||||
return (LoggingLevel)LevelSwitch.MinimumLevel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,22 +1,23 @@
|
|||||||
using OF_DL.Helpers;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using OF_DL.Helpers;
|
||||||
|
|
||||||
namespace OF_DL.Utils
|
namespace OF_DL.Utils;
|
||||||
|
|
||||||
|
internal class HttpUtil
|
||||||
{
|
{
|
||||||
class HttpUtil
|
public static HttpClient Client { get; set; } = new(new HttpClientHandler
|
||||||
{
|
{
|
||||||
public static HttpClient Client { get; set; } = new HttpClient(new HttpClientHandler
|
AllowAutoRedirect = true
|
||||||
{
|
|
||||||
AllowAutoRedirect = true,
|
|
||||||
//Proxy = null
|
//Proxy = null
|
||||||
});
|
});
|
||||||
|
|
||||||
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers, string postData)
|
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers, string postData)
|
||||||
{
|
{
|
||||||
var mediaType = postData.StartsWith("{") ? "application/json" : "application/x-www-form-urlencoded";
|
string mediaType = postData.StartsWith("{") ? "application/json" : "application/x-www-form-urlencoded";
|
||||||
var response = await PerformOperation(async () =>
|
HttpResponseMessage response = await PerformOperation(async () =>
|
||||||
{
|
{
|
||||||
StringContent content = new StringContent(postData, Encoding.UTF8, mediaType);
|
StringContent content = new(postData, Encoding.UTF8, mediaType);
|
||||||
//ByteArrayContent content = new ByteArrayContent(postData);
|
//ByteArrayContent content = new ByteArrayContent(postData);
|
||||||
|
|
||||||
return await Post(URL, headers, content);
|
return await Post(URL, headers, content);
|
||||||
@ -28,9 +29,9 @@ namespace OF_DL.Utils
|
|||||||
|
|
||||||
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers, byte[] postData)
|
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers, byte[] postData)
|
||||||
{
|
{
|
||||||
var response = await PerformOperation(async () =>
|
HttpResponseMessage response = await PerformOperation(async () =>
|
||||||
{
|
{
|
||||||
ByteArrayContent content = new ByteArrayContent(postData);
|
ByteArrayContent content = new(postData);
|
||||||
|
|
||||||
return await Post(URL, headers, content);
|
return await Post(URL, headers, content);
|
||||||
});
|
});
|
||||||
@ -39,11 +40,12 @@ namespace OF_DL.Utils
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers, Dictionary<string, string> postData)
|
public static async Task<byte[]> PostData(string URL, Dictionary<string, string> headers,
|
||||||
|
Dictionary<string, string> postData)
|
||||||
{
|
{
|
||||||
var response = await PerformOperation(async () =>
|
HttpResponseMessage response = await PerformOperation(async () =>
|
||||||
{
|
{
|
||||||
FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
|
FormUrlEncodedContent content = new(postData);
|
||||||
|
|
||||||
return await Post(URL, headers, content);
|
return await Post(URL, headers, content);
|
||||||
});
|
});
|
||||||
@ -54,10 +56,7 @@ namespace OF_DL.Utils
|
|||||||
|
|
||||||
public static async Task<string> GetWebSource(string URL, Dictionary<string, string> headers = null)
|
public static async Task<string> GetWebSource(string URL, Dictionary<string, string> headers = null)
|
||||||
{
|
{
|
||||||
var response = await PerformOperation(async () =>
|
HttpResponseMessage response = await PerformOperation(async () => { return await Get(URL, headers); });
|
||||||
{
|
|
||||||
return await Get(URL, headers);
|
|
||||||
});
|
|
||||||
|
|
||||||
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
||||||
return Encoding.UTF8.GetString(bytes);
|
return Encoding.UTF8.GetString(bytes);
|
||||||
@ -65,71 +64,68 @@ namespace OF_DL.Utils
|
|||||||
|
|
||||||
public static async Task<byte[]> GetBinary(string URL, Dictionary<string, string> headers = null)
|
public static async Task<byte[]> GetBinary(string URL, Dictionary<string, string> headers = null)
|
||||||
{
|
{
|
||||||
var response = await PerformOperation(async () =>
|
HttpResponseMessage response = await PerformOperation(async () => { return await Get(URL, headers); });
|
||||||
{
|
|
||||||
return await Get(URL, headers);
|
|
||||||
});
|
|
||||||
|
|
||||||
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
public static string GetString(byte[] bytes)
|
|
||||||
{
|
public static string GetString(byte[] bytes) => Encoding.UTF8.GetString(bytes);
|
||||||
return Encoding.UTF8.GetString(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<HttpResponseMessage> Get(string URL, Dictionary<string, string> headers = null)
|
private static async Task<HttpResponseMessage> Get(string URL, Dictionary<string, string> headers = null)
|
||||||
{
|
{
|
||||||
HttpRequestMessage request = new HttpRequestMessage()
|
HttpRequestMessage request = new() { RequestUri = new Uri(URL), Method = HttpMethod.Get };
|
||||||
{
|
|
||||||
RequestUri = new Uri(URL),
|
|
||||||
Method = HttpMethod.Get
|
|
||||||
};
|
|
||||||
|
|
||||||
if (headers != null)
|
if (headers != null)
|
||||||
|
{
|
||||||
foreach (KeyValuePair<string, string> header in headers)
|
foreach (KeyValuePair<string, string> header in headers)
|
||||||
|
{
|
||||||
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
|
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return await Send(request);
|
return await Send(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<HttpResponseMessage> Post(string URL, Dictionary<string, string> headers, HttpContent content)
|
private static async Task<HttpResponseMessage> Post(string URL, Dictionary<string, string> headers,
|
||||||
|
HttpContent content)
|
||||||
{
|
{
|
||||||
HttpRequestMessage request = new HttpRequestMessage()
|
HttpRequestMessage request = new() { RequestUri = new Uri(URL), Method = HttpMethod.Post, Content = content };
|
||||||
{
|
|
||||||
RequestUri = new Uri(URL),
|
|
||||||
Method = HttpMethod.Post,
|
|
||||||
Content = content
|
|
||||||
};
|
|
||||||
|
|
||||||
if (headers != null)
|
if (headers != null)
|
||||||
|
{
|
||||||
foreach (KeyValuePair<string, string> header in headers)
|
foreach (KeyValuePair<string, string> header in headers)
|
||||||
|
{
|
||||||
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
|
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return await Send(request);
|
return await Send(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<HttpResponseMessage> Send(HttpRequestMessage request)
|
private static async Task<HttpResponseMessage> Send(HttpRequestMessage request) => await Client.SendAsync(request);
|
||||||
{
|
|
||||||
return await Client.SendAsync(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<HttpResponseMessage> PerformOperation(Func<Task<HttpResponseMessage>> operation)
|
private static async Task<HttpResponseMessage> PerformOperation(Func<Task<HttpResponseMessage>> operation)
|
||||||
{
|
{
|
||||||
var response = await operation();
|
HttpResponseMessage response = await operation();
|
||||||
|
|
||||||
var retryCount = 0;
|
int retryCount = 0;
|
||||||
|
|
||||||
while (retryCount < Constants.WIDEVINE_MAX_RETRIES && response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
|
while (retryCount < Constants.WIDEVINE_MAX_RETRIES && response.StatusCode == HttpStatusCode.TooManyRequests)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// We've hit a rate limit, so we should wait before retrying.
|
// 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.
|
int 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 != null && response.Headers.RetryAfter.Delta.HasValue)
|
||||||
{
|
{
|
||||||
if (response.Headers.RetryAfter.Delta.Value.TotalSeconds > 0)
|
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
|
{
|
||||||
|
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
|
await Task.Delay(retryAfterSeconds * 1000); // Peform the delay
|
||||||
@ -142,5 +138,4 @@ namespace OF_DL.Utils
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,15 +2,14 @@ using System.Reactive.Concurrency;
|
|||||||
|
|
||||||
namespace OF_DL.Utils;
|
namespace OF_DL.Utils;
|
||||||
|
|
||||||
|
|
||||||
public class ThrottledStream : Stream
|
public class ThrottledStream : Stream
|
||||||
|
|
||||||
{
|
{
|
||||||
private readonly Stream parent;
|
|
||||||
private readonly int maxBytesPerSecond;
|
private readonly int maxBytesPerSecond;
|
||||||
|
private readonly Stream parent;
|
||||||
private readonly IScheduler scheduler;
|
private readonly IScheduler scheduler;
|
||||||
private readonly IStopwatch stopwatch;
|
|
||||||
private readonly bool shouldThrottle;
|
private readonly bool shouldThrottle;
|
||||||
|
private readonly IStopwatch stopwatch;
|
||||||
|
|
||||||
private long processed;
|
private long processed;
|
||||||
|
|
||||||
@ -30,16 +29,39 @@ public class ThrottledStream : Stream
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool CanRead => parent.CanRead;
|
||||||
|
|
||||||
|
|
||||||
|
public override bool CanSeek => parent.CanSeek;
|
||||||
|
|
||||||
|
|
||||||
|
public override bool CanWrite => parent.CanWrite;
|
||||||
|
|
||||||
|
|
||||||
|
public override long Length => parent.Length;
|
||||||
|
|
||||||
|
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get => parent.Position;
|
||||||
|
set => parent.Position = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void Throttle(int bytes)
|
protected void Throttle(int bytes)
|
||||||
{
|
{
|
||||||
if (!shouldThrottle) return;
|
if (!shouldThrottle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
processed += bytes;
|
processed += bytes;
|
||||||
var targetTime = TimeSpan.FromSeconds((double)processed / maxBytesPerSecond);
|
TimeSpan targetTime = TimeSpan.FromSeconds((double)processed / maxBytesPerSecond);
|
||||||
var actualTime = stopwatch.Elapsed;
|
TimeSpan actualTime = stopwatch.Elapsed;
|
||||||
var sleep = targetTime - actualTime;
|
TimeSpan sleep = targetTime - actualTime;
|
||||||
if (sleep > TimeSpan.Zero)
|
if (sleep > TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
using var waitHandle = new AutoResetEvent(initialState: false);
|
using AutoResetEvent waitHandle = new(false);
|
||||||
scheduler.Sleep(sleep).GetAwaiter().OnCompleted(() => waitHandle.Set());
|
scheduler.Sleep(sleep).GetAwaiter().OnCompleted(() => waitHandle.Set());
|
||||||
waitHandle.WaitOne();
|
waitHandle.WaitOne();
|
||||||
}
|
}
|
||||||
@ -47,11 +69,15 @@ public class ThrottledStream : Stream
|
|||||||
|
|
||||||
protected async Task ThrottleAsync(int bytes)
|
protected async Task ThrottleAsync(int bytes)
|
||||||
{
|
{
|
||||||
if (!shouldThrottle) return;
|
if (!shouldThrottle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
processed += bytes;
|
processed += bytes;
|
||||||
var targetTime = TimeSpan.FromSeconds((double)processed / maxBytesPerSecond);
|
TimeSpan targetTime = TimeSpan.FromSeconds((double)processed / maxBytesPerSecond);
|
||||||
var actualTime = stopwatch.Elapsed;
|
TimeSpan actualTime = stopwatch.Elapsed;
|
||||||
var sleep = targetTime - actualTime;
|
TimeSpan sleep = targetTime - actualTime;
|
||||||
|
|
||||||
if (sleep > TimeSpan.Zero)
|
if (sleep > TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
@ -61,7 +87,7 @@ public class ThrottledStream : Stream
|
|||||||
|
|
||||||
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var read = await parent.ReadAsync(buffer.AsMemory(offset, count), cancellationToken).ConfigureAwait(false);
|
int read = await parent.ReadAsync(buffer.AsMemory(offset, count), cancellationToken).ConfigureAwait(false);
|
||||||
await ThrottleAsync(read).ConfigureAwait(false);
|
await ThrottleAsync(read).ConfigureAwait(false);
|
||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
@ -79,71 +105,26 @@ public class ThrottledStream : Stream
|
|||||||
await parent.WriteAsync(buffer.AsMemory(offset, count), cancellationToken).ConfigureAwait(false);
|
await parent.WriteAsync(buffer.AsMemory(offset, count), cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)
|
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer,
|
||||||
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
await ThrottleAsync(buffer.Length).ConfigureAwait(false);
|
await ThrottleAsync(buffer.Length).ConfigureAwait(false);
|
||||||
await parent.WriteAsync(buffer, cancellationToken).ConfigureAwait(false);
|
await parent.WriteAsync(buffer, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override bool CanRead
|
public override void Flush() => parent.Flush();
|
||||||
{
|
|
||||||
get { return parent.CanRead; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override bool CanSeek
|
|
||||||
{
|
|
||||||
get { return parent.CanSeek; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override bool CanWrite
|
|
||||||
{
|
|
||||||
get { return parent.CanWrite; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void Flush()
|
|
||||||
{
|
|
||||||
parent.Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override long Length
|
|
||||||
{
|
|
||||||
get { return parent.Length; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override long Position
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return parent.Position;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
parent.Position = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int Read(byte[] buffer, int offset, int count)
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
{
|
{
|
||||||
var read = parent.Read(buffer, offset, count);
|
int read = parent.Read(buffer, offset, count);
|
||||||
Throttle(read);
|
Throttle(read);
|
||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override long Seek(long offset, SeekOrigin origin)
|
public override long Seek(long offset, SeekOrigin origin) => parent.Seek(offset, origin);
|
||||||
{
|
|
||||||
return parent.Seek(offset, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetLength(long value)
|
public override void SetLength(long value) => parent.SetLength(value);
|
||||||
{
|
|
||||||
parent.SetLength(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(byte[] buffer, int offset, int count)
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace OF_DL.Utils
|
namespace OF_DL.Utils;
|
||||||
|
|
||||||
|
internal static class XmlUtils
|
||||||
{
|
{
|
||||||
internal static class XmlUtils
|
|
||||||
{
|
|
||||||
// When true, return original text without parsing/stripping.
|
// When true, return original text without parsing/stripping.
|
||||||
public static bool Passthrough { get; set; } = false;
|
public static bool Passthrough { get; set; } = false;
|
||||||
|
|
||||||
@ -16,13 +16,13 @@ namespace OF_DL.Utils
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var parsedText = XElement.Parse($"<root>{xmlValue}</root>");
|
XElement parsedText = XElement.Parse($"<root>{xmlValue}</root>");
|
||||||
return parsedText.Value;
|
return parsedText.Value;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,54 +4,55 @@ using System.Text;
|
|||||||
using OF_DL.Crypto;
|
using OF_DL.Crypto;
|
||||||
using ProtoBuf;
|
using ProtoBuf;
|
||||||
|
|
||||||
namespace OF_DL.Widevine
|
namespace OF_DL.Widevine;
|
||||||
{
|
|
||||||
public class CDM
|
|
||||||
{
|
|
||||||
static Dictionary<string, CDMDevice> Devices { get; } = new Dictionary<string, CDMDevice>()
|
|
||||||
{
|
|
||||||
[Constants.DEVICE_NAME] = new CDMDevice(Constants.DEVICE_NAME, null, null, null)
|
|
||||||
};
|
|
||||||
static Dictionary<string, Session> Sessions { get; set; } = new Dictionary<string, Session>();
|
|
||||||
|
|
||||||
static byte[] CheckPSSH(string psshB64)
|
public class CDM
|
||||||
|
{
|
||||||
|
private static Dictionary<string, CDMDevice> Devices { get; } = new()
|
||||||
|
{
|
||||||
|
[Constants.DEVICE_NAME] = new CDMDevice(Constants.DEVICE_NAME)
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Dictionary<string, Session> Sessions { get; } = new();
|
||||||
|
|
||||||
|
private static byte[] CheckPSSH(string psshB64)
|
||||||
{
|
{
|
||||||
byte[] systemID = new byte[] { 237, 239, 139, 169, 121, 214, 74, 206, 163, 200, 39, 220, 213, 29, 33, 237 };
|
byte[] systemID = new byte[] { 237, 239, 139, 169, 121, 214, 74, 206, 163, 200, 39, 220, 213, 29, 33, 237 };
|
||||||
|
|
||||||
if (psshB64.Length % 4 != 0)
|
if (psshB64.Length % 4 != 0)
|
||||||
{
|
{
|
||||||
psshB64 = psshB64.PadRight(psshB64.Length + (4 - (psshB64.Length % 4)), '=');
|
psshB64 = psshB64.PadRight(psshB64.Length + (4 - psshB64.Length % 4), '=');
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] pssh = Convert.FromBase64String(psshB64);
|
byte[] pssh = Convert.FromBase64String(psshB64);
|
||||||
|
|
||||||
if (pssh.Length < 30)
|
if (pssh.Length < 30)
|
||||||
|
{
|
||||||
return pssh;
|
return pssh;
|
||||||
|
}
|
||||||
|
|
||||||
if (!pssh[12..28].SequenceEqual(systemID))
|
if (!pssh[12..28].SequenceEqual(systemID))
|
||||||
{
|
{
|
||||||
List<byte> newPssh = new List<byte>() { 0, 0, 0 };
|
List<byte> newPssh = new() { 0, 0, 0 };
|
||||||
newPssh.Add((byte)(32 + pssh.Length));
|
newPssh.Add((byte)(32 + pssh.Length));
|
||||||
newPssh.AddRange(Encoding.UTF8.GetBytes("pssh"));
|
newPssh.AddRange(Encoding.UTF8.GetBytes("pssh"));
|
||||||
newPssh.AddRange(new byte[] { 0, 0, 0, 0 });
|
newPssh.AddRange(new byte[] { 0, 0, 0, 0 });
|
||||||
newPssh.AddRange(systemID);
|
newPssh.AddRange(systemID);
|
||||||
newPssh.AddRange(new byte[] { 0, 0, 0, 0 });
|
newPssh.AddRange(new byte[] { 0, 0, 0, 0 });
|
||||||
newPssh[31] = (byte)(pssh.Length);
|
newPssh[31] = (byte)pssh.Length;
|
||||||
newPssh.AddRange(pssh);
|
newPssh.AddRange(pssh);
|
||||||
|
|
||||||
return newPssh.ToArray();
|
return newPssh.ToArray();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return pssh;
|
return pssh;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static string OpenSession(string initDataB64, string deviceName, bool offline = false, bool raw = false)
|
public static string OpenSession(string initDataB64, string deviceName, bool offline = false, bool raw = false)
|
||||||
{
|
{
|
||||||
byte[] initData = CheckPSSH(initDataB64);
|
byte[] initData = CheckPSSH(initDataB64);
|
||||||
|
|
||||||
var device = Devices[deviceName];
|
CDMDevice device = Devices[deviceName];
|
||||||
|
|
||||||
byte[] sessionId = new byte[16];
|
byte[] sessionId = new byte[16];
|
||||||
|
|
||||||
@ -59,10 +60,12 @@ namespace OF_DL.Widevine
|
|||||||
{
|
{
|
||||||
string randHex = "";
|
string randHex = "";
|
||||||
|
|
||||||
Random rand = new Random();
|
Random rand = new();
|
||||||
string choice = "ABCDEF0123456789";
|
string choice = "ABCDEF0123456789";
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
randHex += choice[rand.Next(16)];
|
randHex += choice[rand.Next(16)];
|
||||||
|
}
|
||||||
|
|
||||||
string counter = "01";
|
string counter = "01";
|
||||||
string rest = "00000000000000";
|
string rest = "00000000000000";
|
||||||
@ -70,7 +73,7 @@ namespace OF_DL.Widevine
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Random rand = new Random();
|
Random rand = new();
|
||||||
rand.NextBytes(sessionId);
|
rand.NextBytes(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +98,7 @@ namespace OF_DL.Widevine
|
|||||||
return BytesToHex(sessionId);
|
return BytesToHex(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WidevineCencHeader ParseInitData(byte[] initData)
|
private static WidevineCencHeader ParseInitData(byte[] initData)
|
||||||
{
|
{
|
||||||
WidevineCencHeader cencHeader;
|
WidevineCencHeader cencHeader;
|
||||||
|
|
||||||
@ -133,12 +136,10 @@ namespace OF_DL.Widevine
|
|||||||
//Logger.Verbose("CDM session closed");
|
//Logger.Verbose("CDM session closed");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//Logger.Info($"Session {sessionId} not found");
|
//Logger.Info($"Session {sessionId} not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static bool SetServiceCertificate(string sessionId, byte[] certData)
|
public static bool SetServiceCertificate(string sessionId, byte[] certData)
|
||||||
{
|
{
|
||||||
@ -151,7 +152,7 @@ namespace OF_DL.Widevine
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SignedMessage signedMessage = new SignedMessage();
|
SignedMessage signedMessage = new();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -168,7 +169,8 @@ namespace OF_DL.Widevine
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Logger.Debug("Service cert provided as signedmessage");
|
//Logger.Debug("Service cert provided as signedmessage");
|
||||||
serviceCertificate = Serializer.Deserialize<SignedDeviceCertificate>(new MemoryStream(signedMessage.Msg));
|
serviceCertificate =
|
||||||
|
Serializer.Deserialize<SignedDeviceCertificate>(new MemoryStream(signedMessage.Msg));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -199,7 +201,7 @@ namespace OF_DL.Widevine
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var session = Sessions[sessionId];
|
Session session = Sessions[sessionId];
|
||||||
|
|
||||||
//Logger.Debug("Building license request");
|
//Logger.Debug("Building license request");
|
||||||
|
|
||||||
@ -254,34 +256,35 @@ namespace OF_DL.Widevine
|
|||||||
{
|
{
|
||||||
//Logger.Debug("Privacy mode & serivce certificate loaded, encrypting client id");
|
//Logger.Debug("Privacy mode & serivce certificate loaded, encrypting client id");
|
||||||
|
|
||||||
EncryptedClientIdentification encryptedClientIdProto = new EncryptedClientIdentification();
|
EncryptedClientIdentification encryptedClientIdProto = new();
|
||||||
|
|
||||||
//Logger.Debug("Unencrypted client id " + Utils.SerializeToString(clientId));
|
//Logger.Debug("Unencrypted client id " + Utils.SerializeToString(clientId));
|
||||||
|
|
||||||
using var memoryStream = new MemoryStream();
|
using MemoryStream memoryStream = new();
|
||||||
Serializer.Serialize(memoryStream, session.Device.ClientID);
|
Serializer.Serialize(memoryStream, session.Device.ClientID);
|
||||||
byte[] data = Padding.AddPKCS7Padding(memoryStream.ToArray(), 16);
|
byte[] data = Padding.AddPKCS7Padding(memoryStream.ToArray(), 16);
|
||||||
|
|
||||||
using AesCryptoServiceProvider aesProvider = new AesCryptoServiceProvider
|
using AesCryptoServiceProvider aesProvider = new()
|
||||||
{
|
{
|
||||||
BlockSize = 128,
|
BlockSize = 128, Padding = PaddingMode.PKCS7, Mode = CipherMode.CBC
|
||||||
Padding = PaddingMode.PKCS7,
|
|
||||||
Mode = CipherMode.CBC
|
|
||||||
};
|
};
|
||||||
aesProvider.GenerateKey();
|
aesProvider.GenerateKey();
|
||||||
aesProvider.GenerateIV();
|
aesProvider.GenerateIV();
|
||||||
|
|
||||||
using MemoryStream mstream = new MemoryStream();
|
using MemoryStream mstream = new();
|
||||||
using CryptoStream cryptoStream = new CryptoStream(mstream, aesProvider.CreateEncryptor(aesProvider.Key, aesProvider.IV), CryptoStreamMode.Write);
|
using CryptoStream cryptoStream = new(mstream, aesProvider.CreateEncryptor(aesProvider.Key, aesProvider.IV),
|
||||||
|
CryptoStreamMode.Write);
|
||||||
cryptoStream.Write(data, 0, data.Length);
|
cryptoStream.Write(data, 0, data.Length);
|
||||||
encryptedClientIdProto.EncryptedClientId = mstream.ToArray();
|
encryptedClientIdProto.EncryptedClientId = mstream.ToArray();
|
||||||
|
|
||||||
using RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
|
using RSACryptoServiceProvider RSA = new();
|
||||||
RSA.ImportRSAPublicKey(session.ServiceCertificate.DeviceCertificate.PublicKey, out int bytesRead);
|
RSA.ImportRSAPublicKey(session.ServiceCertificate.DeviceCertificate.PublicKey, out int bytesRead);
|
||||||
encryptedClientIdProto.EncryptedPrivacyKey = RSA.Encrypt(aesProvider.Key, RSAEncryptionPadding.OaepSHA1);
|
encryptedClientIdProto.EncryptedPrivacyKey = RSA.Encrypt(aesProvider.Key, RSAEncryptionPadding.OaepSHA1);
|
||||||
encryptedClientIdProto.EncryptedClientIdIv = aesProvider.IV;
|
encryptedClientIdProto.EncryptedClientIdIv = aesProvider.IV;
|
||||||
encryptedClientIdProto.ServiceId = Encoding.UTF8.GetString(session.ServiceCertificate.DeviceCertificate.ServiceId);
|
encryptedClientIdProto.ServiceId =
|
||||||
encryptedClientIdProto.ServiceCertificateSerialNumber = session.ServiceCertificate.DeviceCertificate.SerialNumber;
|
Encoding.UTF8.GetString(session.ServiceCertificate.DeviceCertificate.ServiceId);
|
||||||
|
encryptedClientIdProto.ServiceCertificateSerialNumber =
|
||||||
|
session.ServiceCertificate.DeviceCertificate.SerialNumber;
|
||||||
|
|
||||||
licenseRequest.Msg.EncryptedClientId = encryptedClientIdProto;
|
licenseRequest.Msg.EncryptedClientId = encryptedClientIdProto;
|
||||||
}
|
}
|
||||||
@ -292,7 +295,7 @@ namespace OF_DL.Widevine
|
|||||||
|
|
||||||
//Logger.Debug("Signing license request");
|
//Logger.Debug("Signing license request");
|
||||||
|
|
||||||
using (var memoryStream = new MemoryStream())
|
using (MemoryStream memoryStream = new())
|
||||||
{
|
{
|
||||||
Serializer.Serialize(memoryStream, licenseRequest.Msg);
|
Serializer.Serialize(memoryStream, licenseRequest.Msg);
|
||||||
byte[] data = memoryStream.ToArray();
|
byte[] data = memoryStream.ToArray();
|
||||||
@ -304,7 +307,7 @@ namespace OF_DL.Widevine
|
|||||||
//Logger.Verbose("License request created");
|
//Logger.Verbose("License request created");
|
||||||
|
|
||||||
byte[] requestBytes;
|
byte[] requestBytes;
|
||||||
using (var memoryStream = new MemoryStream())
|
using (MemoryStream memoryStream = new())
|
||||||
{
|
{
|
||||||
Serializer.Serialize(memoryStream, licenseRequest);
|
Serializer.Serialize(memoryStream, licenseRequest);
|
||||||
requestBytes = memoryStream.ToArray();
|
requestBytes = memoryStream.ToArray();
|
||||||
@ -326,7 +329,7 @@ namespace OF_DL.Widevine
|
|||||||
throw new Exception("Session ID doesn't exist");
|
throw new Exception("Session ID doesn't exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
var session = Sessions[sessionId];
|
Session session = Sessions[sessionId];
|
||||||
|
|
||||||
if (session.LicenseRequest == null)
|
if (session.LicenseRequest == null)
|
||||||
{
|
{
|
||||||
@ -351,7 +354,7 @@ namespace OF_DL.Widevine
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sessionKey = session.Device.Decrypt(session.License.SessionKey);
|
byte[] sessionKey = session.Device.Decrypt(session.License.SessionKey);
|
||||||
|
|
||||||
if (sessionKey.Length != 16)
|
if (sessionKey.Length != 16)
|
||||||
{
|
{
|
||||||
@ -372,11 +375,12 @@ namespace OF_DL.Widevine
|
|||||||
//Logger.Debug("Verifying license signature");
|
//Logger.Debug("Verifying license signature");
|
||||||
|
|
||||||
byte[] licenseBytes;
|
byte[] licenseBytes;
|
||||||
using (var memoryStream = new MemoryStream())
|
using (MemoryStream memoryStream = new())
|
||||||
{
|
{
|
||||||
Serializer.Serialize(memoryStream, signedLicense.Msg);
|
Serializer.Serialize(memoryStream, signedLicense.Msg);
|
||||||
licenseBytes = memoryStream.ToArray();
|
licenseBytes = memoryStream.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] hmacHash = CryptoUtils.GetHMACSHA256Digest(licenseBytes, session.DerivedKeys.Auth1);
|
byte[] hmacHash = CryptoUtils.GetHMACSHA256Digest(licenseBytes, session.DerivedKeys.Auth1);
|
||||||
|
|
||||||
if (!hmacHash.SequenceEqual(signedLicense.Signature))
|
if (!hmacHash.SequenceEqual(signedLicense.Signature))
|
||||||
@ -389,7 +393,9 @@ namespace OF_DL.Widevine
|
|||||||
string type = key.Type.ToString();
|
string type = key.Type.ToString();
|
||||||
|
|
||||||
if (type == "Signing")
|
if (type == "Signing")
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
byte[] keyId;
|
byte[] keyId;
|
||||||
byte[] encryptedKey = key.Key;
|
byte[] encryptedKey = key.Key;
|
||||||
@ -402,17 +408,14 @@ namespace OF_DL.Widevine
|
|||||||
|
|
||||||
byte[] decryptedKey;
|
byte[] decryptedKey;
|
||||||
|
|
||||||
using MemoryStream mstream = new MemoryStream();
|
using MemoryStream mstream = new();
|
||||||
using AesCryptoServiceProvider aesProvider = new AesCryptoServiceProvider
|
using AesCryptoServiceProvider aesProvider = new() { Mode = CipherMode.CBC, Padding = PaddingMode.PKCS7 };
|
||||||
{
|
using CryptoStream cryptoStream = new(mstream, aesProvider.CreateDecryptor(session.DerivedKeys.Enc, iv),
|
||||||
Mode = CipherMode.CBC,
|
CryptoStreamMode.Write);
|
||||||
Padding = PaddingMode.PKCS7
|
|
||||||
};
|
|
||||||
using CryptoStream cryptoStream = new CryptoStream(mstream, aesProvider.CreateDecryptor(session.DerivedKeys.Enc, iv), CryptoStreamMode.Write);
|
|
||||||
cryptoStream.Write(encryptedKey, 0, encryptedKey.Length);
|
cryptoStream.Write(encryptedKey, 0, encryptedKey.Length);
|
||||||
decryptedKey = mstream.ToArray();
|
decryptedKey = mstream.ToArray();
|
||||||
|
|
||||||
List<string> permissions = new List<string>();
|
List<string> permissions = new();
|
||||||
if (type == "OperatorSession")
|
if (type == "OperatorSession")
|
||||||
{
|
{
|
||||||
foreach (PropertyInfo perm in key._OperatorSessionKeyPermissions.GetType().GetProperties())
|
foreach (PropertyInfo perm in key._OperatorSessionKeyPermissions.GetType().GetProperties())
|
||||||
@ -423,12 +426,10 @@ namespace OF_DL.Widevine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.ContentKeys.Add(new ContentKey
|
session.ContentKeys.Add(new ContentKey
|
||||||
{
|
{
|
||||||
KeyID = keyId,
|
KeyID = keyId, Type = type, Bytes = decryptedKey, Permissions = permissions
|
||||||
Type = type,
|
|
||||||
Bytes = decryptedKey,
|
|
||||||
Permissions = permissions
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,8 +442,10 @@ namespace OF_DL.Widevine
|
|||||||
|
|
||||||
public static DerivedKeys DeriveKeys(byte[] message, byte[] key)
|
public static DerivedKeys DeriveKeys(byte[] message, byte[] key)
|
||||||
{
|
{
|
||||||
byte[] encKeyBase = Encoding.UTF8.GetBytes("ENCRYPTION").Concat(new byte[] { 0x0, }).Concat(message).Concat(new byte[] { 0x0, 0x0, 0x0, 0x80 }).ToArray();
|
byte[] encKeyBase = Encoding.UTF8.GetBytes("ENCRYPTION").Concat(new byte[] { 0x0 }).Concat(message)
|
||||||
byte[] authKeyBase = Encoding.UTF8.GetBytes("AUTHENTICATION").Concat(new byte[] { 0x0, }).Concat(message).Concat(new byte[] { 0x0, 0x0, 0x2, 0x0 }).ToArray();
|
.Concat(new byte[] { 0x0, 0x0, 0x0, 0x80 }).ToArray();
|
||||||
|
byte[] authKeyBase = Encoding.UTF8.GetBytes("AUTHENTICATION").Concat(new byte[] { 0x0 }).Concat(message)
|
||||||
|
.Concat(new byte[] { 0x0, 0x0, 0x2, 0x0 }).ToArray();
|
||||||
|
|
||||||
byte[] encKey = new byte[] { 0x01 }.Concat(encKeyBase).ToArray();
|
byte[] encKey = new byte[] { 0x01 }.Concat(encKeyBase).ToArray();
|
||||||
byte[] authKey1 = new byte[] { 0x01 }.Concat(authKeyBase).ToArray();
|
byte[] authKey1 = new byte[] { 0x01 }.Concat(authKeyBase).ToArray();
|
||||||
@ -459,33 +462,22 @@ namespace OF_DL.Widevine
|
|||||||
byte[] authCmacCombined1 = authCmacKey1.Concat(authCmacKey2).ToArray();
|
byte[] authCmacCombined1 = authCmacKey1.Concat(authCmacKey2).ToArray();
|
||||||
byte[] authCmacCombined2 = authCmacKey3.Concat(authCmacKey4).ToArray();
|
byte[] authCmacCombined2 = authCmacKey3.Concat(authCmacKey4).ToArray();
|
||||||
|
|
||||||
return new DerivedKeys
|
return new DerivedKeys { Auth1 = authCmacCombined1, Auth2 = authCmacCombined2, Enc = encCmacKey };
|
||||||
{
|
|
||||||
Auth1 = authCmacCombined1,
|
|
||||||
Auth2 = authCmacCombined2,
|
|
||||||
Enc = encCmacKey
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ContentKey> GetKeys(string sessionId)
|
public static List<ContentKey> GetKeys(string sessionId)
|
||||||
{
|
{
|
||||||
if (Sessions.ContainsKey(sessionId))
|
if (Sessions.ContainsKey(sessionId))
|
||||||
return Sessions[sessionId].ContentKeys;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
return Sessions[sessionId].ContentKeys;
|
||||||
|
}
|
||||||
|
|
||||||
throw new Exception("Session not found");
|
throw new Exception("Session not found");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static string BytesToHex(byte[] data)
|
private static string BytesToHex(byte[] data) => BitConverter.ToString(data).Replace("-", "");
|
||||||
{
|
|
||||||
return BitConverter.ToString(data).Replace("-", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public static List<string> ProvideLicense(string requestB64, string licenseB64)
|
public static List<string> ProvideLicense(string requestB64, string licenseB64)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
namespace OF_DL.Widevine
|
namespace OF_DL.Widevine;
|
||||||
|
|
||||||
|
public class CDMApi
|
||||||
{
|
{
|
||||||
public class CDMApi
|
private string SessionId { get; set; }
|
||||||
{
|
|
||||||
string SessionId { get; set; }
|
|
||||||
|
|
||||||
public byte[] GetChallenge(string initDataB64, string certDataB64, bool offline = false, bool raw = false)
|
public byte[] GetChallenge(string initDataB64, string certDataB64, bool offline = false, bool raw = false)
|
||||||
{
|
{
|
||||||
@ -17,9 +17,5 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ContentKey> GetKeys()
|
public List<ContentKey> GetKeys() => CDM.GetKeys(SessionId);
|
||||||
{
|
|
||||||
return CDM.GetKeys(SessionId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,17 +7,12 @@ using Org.BouncyCastle.Crypto.Signers;
|
|||||||
using Org.BouncyCastle.OpenSsl;
|
using Org.BouncyCastle.OpenSsl;
|
||||||
using ProtoBuf;
|
using ProtoBuf;
|
||||||
|
|
||||||
namespace OF_DL.Widevine
|
namespace OF_DL.Widevine;
|
||||||
|
|
||||||
|
public class CDMDevice
|
||||||
{
|
{
|
||||||
public class CDMDevice
|
public CDMDevice(string deviceName, byte[] clientIdBlobBytes = null, byte[] privateKeyBytes = null,
|
||||||
{
|
byte[] vmpBytes = null)
|
||||||
public string DeviceName { get; set; }
|
|
||||||
public ClientIdentification ClientID { get; set; }
|
|
||||||
AsymmetricCipherKeyPair DeviceKeys { get; set; }
|
|
||||||
|
|
||||||
public virtual bool IsAndroid { get; set; } = true;
|
|
||||||
|
|
||||||
public CDMDevice(string deviceName, byte[] clientIdBlobBytes = null, byte[] privateKeyBytes = null, byte[] vmpBytes = null)
|
|
||||||
{
|
{
|
||||||
DeviceName = deviceName;
|
DeviceName = deviceName;
|
||||||
|
|
||||||
@ -29,7 +24,9 @@ namespace OF_DL.Widevine
|
|||||||
string clientIDPath = Path.Join(Constants.DEVICES_FOLDER, deviceName, "device_client_id_blob");
|
string clientIDPath = Path.Join(Constants.DEVICES_FOLDER, deviceName, "device_client_id_blob");
|
||||||
|
|
||||||
if (!File.Exists(clientIDPath))
|
if (!File.Exists(clientIDPath))
|
||||||
|
{
|
||||||
throw new Exception("No client id blob found");
|
throw new Exception("No client id blob found");
|
||||||
|
}
|
||||||
|
|
||||||
clientIdBlobBytes = File.ReadAllBytes(clientIDPath);
|
clientIdBlobBytes = File.ReadAllBytes(clientIDPath);
|
||||||
}
|
}
|
||||||
@ -38,36 +35,42 @@ namespace OF_DL.Widevine
|
|||||||
|
|
||||||
if (privateKeyBytes != null)
|
if (privateKeyBytes != null)
|
||||||
{
|
{
|
||||||
using var reader = new StringReader(Encoding.UTF8.GetString(privateKeyBytes));
|
using StringReader reader = new(Encoding.UTF8.GetString(privateKeyBytes));
|
||||||
DeviceKeys = (AsymmetricCipherKeyPair)new PemReader(reader).ReadObject();
|
DeviceKeys = (AsymmetricCipherKeyPair)new PemReader(reader).ReadObject();
|
||||||
}
|
}
|
||||||
else if (File.Exists(privateKeyPath))
|
else if (File.Exists(privateKeyPath))
|
||||||
{
|
{
|
||||||
using var reader = File.OpenText(privateKeyPath);
|
using StreamReader reader = File.OpenText(privateKeyPath);
|
||||||
DeviceKeys = (AsymmetricCipherKeyPair)new PemReader(reader).ReadObject();
|
DeviceKeys = (AsymmetricCipherKeyPair)new PemReader(reader).ReadObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vmpBytes != null)
|
if (vmpBytes != null)
|
||||||
{
|
{
|
||||||
var vmp = Serializer.Deserialize<FileHashes>(new MemoryStream(vmpBytes));
|
FileHashes? vmp = Serializer.Deserialize<FileHashes>(new MemoryStream(vmpBytes));
|
||||||
ClientID.FileHashes = vmp;
|
ClientID.FileHashes = vmp;
|
||||||
}
|
}
|
||||||
else if (File.Exists(vmpPath))
|
else if (File.Exists(vmpPath))
|
||||||
{
|
{
|
||||||
var vmp = Serializer.Deserialize<FileHashes>(new MemoryStream(File.ReadAllBytes(vmpPath)));
|
FileHashes? vmp = Serializer.Deserialize<FileHashes>(new MemoryStream(File.ReadAllBytes(vmpPath)));
|
||||||
ClientID.FileHashes = vmp;
|
ClientID.FileHashes = vmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string DeviceName { get; set; }
|
||||||
|
public ClientIdentification ClientID { get; set; }
|
||||||
|
private AsymmetricCipherKeyPair DeviceKeys { get; }
|
||||||
|
|
||||||
|
public virtual bool IsAndroid { get; set; } = true;
|
||||||
|
|
||||||
public virtual byte[] Decrypt(byte[] data)
|
public virtual byte[] Decrypt(byte[] data)
|
||||||
{
|
{
|
||||||
OaepEncoding eng = new OaepEncoding(new RsaEngine());
|
OaepEncoding eng = new(new RsaEngine());
|
||||||
eng.Init(false, DeviceKeys.Private);
|
eng.Init(false, DeviceKeys.Private);
|
||||||
|
|
||||||
int length = data.Length;
|
int length = data.Length;
|
||||||
int blockSize = eng.GetInputBlockSize();
|
int blockSize = eng.GetInputBlockSize();
|
||||||
|
|
||||||
List<byte> plainText = new List<byte>();
|
List<byte> plainText = new();
|
||||||
|
|
||||||
for (int chunkPosition = 0; chunkPosition < length; chunkPosition += blockSize)
|
for (int chunkPosition = 0; chunkPosition < length; chunkPosition += blockSize)
|
||||||
{
|
{
|
||||||
@ -80,11 +83,10 @@ namespace OF_DL.Widevine
|
|||||||
|
|
||||||
public virtual byte[] Sign(byte[] data)
|
public virtual byte[] Sign(byte[] data)
|
||||||
{
|
{
|
||||||
PssSigner eng = new PssSigner(new RsaEngine(), new Sha1Digest());
|
PssSigner eng = new(new RsaEngine(), new Sha1Digest());
|
||||||
|
|
||||||
eng.Init(true, DeviceKeys.Private);
|
eng.Init(true, DeviceKeys.Private);
|
||||||
eng.BlockUpdate(data, 0, data.Length);
|
eng.BlockUpdate(data, 0, data.Length);
|
||||||
return eng.GenerateSignature();
|
return eng.GenerateSignature();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
namespace OF_DL.Widevine
|
namespace OF_DL.Widevine;
|
||||||
|
|
||||||
|
public class Constants
|
||||||
{
|
{
|
||||||
public class Constants
|
public static string WORKING_FOLDER { get; set; } =
|
||||||
{
|
Path.GetFullPath(Path.Join(Directory.GetCurrentDirectory(), "cdm"));
|
||||||
public static string WORKING_FOLDER { get; set; } = System.IO.Path.GetFullPath(System.IO.Path.Join(System.IO.Directory.GetCurrentDirectory(), "cdm"));
|
|
||||||
public static string DEVICES_FOLDER { get; set; } = System.IO.Path.GetFullPath(System.IO.Path.Join(WORKING_FOLDER, "devices"));
|
public static string DEVICES_FOLDER { get; set; } = Path.GetFullPath(Path.Join(WORKING_FOLDER, "devices"));
|
||||||
public static string DEVICE_NAME { get; set; } = "chrome_1610";
|
public static string DEVICE_NAME { get; set; } = "chrome_1610";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,39 +1,27 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace OF_DL.Widevine
|
namespace OF_DL.Widevine;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ContentKey
|
||||||
{
|
{
|
||||||
[Serializable]
|
[JsonPropertyName("key_id")] public byte[] KeyID { get; set; }
|
||||||
public class ContentKey
|
|
||||||
{
|
|
||||||
[JsonPropertyName("key_id")]
|
|
||||||
public byte[] KeyID { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("type")]
|
[JsonPropertyName("type")] public string Type { get; set; }
|
||||||
public string Type { get; set; }
|
|
||||||
|
|
||||||
[JsonPropertyName("bytes")]
|
[JsonPropertyName("bytes")] public byte[] Bytes { get; set; }
|
||||||
public byte[] Bytes { get; set; }
|
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[JsonPropertyName("permissions")]
|
[JsonPropertyName("permissions")]
|
||||||
public List<string> Permissions {
|
public List<string> Permissions
|
||||||
get
|
|
||||||
{
|
{
|
||||||
return PermissionsString.Split(",").ToList();
|
get => PermissionsString.Split(",").ToList();
|
||||||
}
|
set => PermissionsString = string.Join(",", value);
|
||||||
set
|
|
||||||
{
|
|
||||||
PermissionsString = string.Join(",", value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore] public string PermissionsString { get; set; }
|
||||||
public string PermissionsString { get; set; }
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString() =>
|
||||||
{
|
$"{BitConverter.ToString(KeyID).Replace("-", "").ToLower()}:{BitConverter.ToString(Bytes).Replace("-", "").ToLower()}";
|
||||||
return $"{BitConverter.ToString(KeyID).Replace("-", "").ToLower()}:{BitConverter.ToString(Bytes).Replace("-", "").ToLower()}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
namespace OF_DL.Widevine
|
namespace OF_DL.Widevine;
|
||||||
|
|
||||||
|
public class DerivedKeys
|
||||||
{
|
{
|
||||||
public class DerivedKeys
|
|
||||||
{
|
|
||||||
public byte[] Auth1 { get; set; }
|
public byte[] Auth1 { get; set; }
|
||||||
public byte[] Auth2 { get; set; }
|
public byte[] Auth2 { get; set; }
|
||||||
public byte[] Enc { get; set; }
|
public byte[] Enc { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,38 +1,43 @@
|
|||||||
namespace OF_DL.Widevine
|
namespace OF_DL.Widevine;
|
||||||
|
|
||||||
|
internal class PSSHBox
|
||||||
{
|
{
|
||||||
class PSSHBox
|
private static readonly byte[] PSSH_HEADER = new byte[] { 0x70, 0x73, 0x73, 0x68 };
|
||||||
{
|
|
||||||
static readonly byte[] PSSH_HEADER = new byte[] { 0x70, 0x73, 0x73, 0x68 };
|
|
||||||
|
|
||||||
public List<byte[]> KIDs { get; set; } = new List<byte[]>();
|
private PSSHBox(List<byte[]> kids, byte[] data)
|
||||||
public byte[] Data { get; set; }
|
|
||||||
|
|
||||||
PSSHBox(List<byte[]> kids, byte[] data)
|
|
||||||
{
|
{
|
||||||
KIDs = kids;
|
KIDs = kids;
|
||||||
Data = data;
|
Data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<byte[]> KIDs { get; set; } = new();
|
||||||
|
public byte[] Data { get; set; }
|
||||||
|
|
||||||
public static PSSHBox FromByteArray(byte[] psshbox)
|
public static PSSHBox FromByteArray(byte[] psshbox)
|
||||||
{
|
{
|
||||||
using var stream = new System.IO.MemoryStream(psshbox);
|
using MemoryStream stream = new(psshbox);
|
||||||
|
|
||||||
stream.Seek(4, System.IO.SeekOrigin.Current);
|
stream.Seek(4, SeekOrigin.Current);
|
||||||
byte[] header = new byte[4];
|
byte[] header = new byte[4];
|
||||||
stream.Read(header, 0, 4);
|
stream.Read(header, 0, 4);
|
||||||
|
|
||||||
if (!header.SequenceEqual(PSSH_HEADER))
|
if (!header.SequenceEqual(PSSH_HEADER))
|
||||||
|
{
|
||||||
throw new Exception("Not a pssh box");
|
throw new Exception("Not a pssh box");
|
||||||
|
}
|
||||||
|
|
||||||
stream.Seek(20, System.IO.SeekOrigin.Current);
|
stream.Seek(20, SeekOrigin.Current);
|
||||||
byte[] kidCountBytes = new byte[4];
|
byte[] kidCountBytes = new byte[4];
|
||||||
stream.Read(kidCountBytes, 0, 4);
|
stream.Read(kidCountBytes, 0, 4);
|
||||||
|
|
||||||
if (BitConverter.IsLittleEndian)
|
if (BitConverter.IsLittleEndian)
|
||||||
|
{
|
||||||
Array.Reverse(kidCountBytes);
|
Array.Reverse(kidCountBytes);
|
||||||
|
}
|
||||||
|
|
||||||
uint kidCount = BitConverter.ToUInt32(kidCountBytes);
|
uint kidCount = BitConverter.ToUInt32(kidCountBytes);
|
||||||
|
|
||||||
List<byte[]> kids = new List<byte[]>();
|
List<byte[]> kids = new();
|
||||||
for (int i = 0; i < kidCount; i++)
|
for (int i = 0; i < kidCount; i++)
|
||||||
{
|
{
|
||||||
byte[] kid = new byte[16];
|
byte[] kid = new byte[16];
|
||||||
@ -44,16 +49,20 @@
|
|||||||
stream.Read(dataLengthBytes);
|
stream.Read(dataLengthBytes);
|
||||||
|
|
||||||
if (BitConverter.IsLittleEndian)
|
if (BitConverter.IsLittleEndian)
|
||||||
|
{
|
||||||
Array.Reverse(dataLengthBytes);
|
Array.Reverse(dataLengthBytes);
|
||||||
|
}
|
||||||
|
|
||||||
uint dataLength = BitConverter.ToUInt32(dataLengthBytes);
|
uint dataLength = BitConverter.ToUInt32(dataLengthBytes);
|
||||||
|
|
||||||
if (dataLength == 0)
|
if (dataLength == 0)
|
||||||
|
{
|
||||||
return new PSSHBox(kids, null);
|
return new PSSHBox(kids, null);
|
||||||
|
}
|
||||||
|
|
||||||
byte[] data = new byte[dataLength];
|
byte[] data = new byte[dataLength];
|
||||||
stream.Read(data);
|
stream.Read(data);
|
||||||
|
|
||||||
return new PSSHBox(kids, data);
|
return new PSSHBox(kids, data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,15 @@
|
|||||||
namespace OF_DL.Widevine
|
namespace OF_DL.Widevine;
|
||||||
|
|
||||||
|
internal class Session
|
||||||
{
|
{
|
||||||
class Session
|
public Session(byte[] sessionId, dynamic initData, CDMDevice device, bool offline)
|
||||||
{
|
{
|
||||||
|
SessionId = sessionId;
|
||||||
|
InitData = initData;
|
||||||
|
Offline = offline;
|
||||||
|
Device = device;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] SessionId { get; set; }
|
public byte[] SessionId { get; set; }
|
||||||
public dynamic InitData { get; set; }
|
public dynamic InitData { get; set; }
|
||||||
public bool Offline { get; set; }
|
public bool Offline { get; set; }
|
||||||
@ -12,14 +20,5 @@
|
|||||||
public SignedLicense License { get; set; }
|
public SignedLicense License { get; set; }
|
||||||
public SignedDeviceCertificate ServiceCertificate { get; set; }
|
public SignedDeviceCertificate ServiceCertificate { get; set; }
|
||||||
public bool PrivacyMode { get; set; }
|
public bool PrivacyMode { get; set; }
|
||||||
public List<ContentKey> ContentKeys { get; set; } = new List<ContentKey>();
|
public List<ContentKey> ContentKeys { get; set; } = new();
|
||||||
|
|
||||||
public Session(byte[] sessionId, dynamic initData, CDMDevice device, bool offline)
|
|
||||||
{
|
|
||||||
SessionId = sessionId;
|
|
||||||
InitData = initData;
|
|
||||||
Offline = offline;
|
|
||||||
Device = device;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,5 +4,38 @@
|
|||||||
"prefix": "30586",
|
"prefix": "30586",
|
||||||
"suffix": "67000213",
|
"suffix": "67000213",
|
||||||
"checksum_constant": 521,
|
"checksum_constant": 521,
|
||||||
"checksum_indexes": [ 0, 2, 3, 7, 7, 8, 8, 10, 11, 13, 14, 16, 17, 17, 17, 19, 19, 20, 21, 21, 23, 23, 24, 24, 27, 27, 29, 30, 31, 34, 35, 39 ]
|
"checksum_indexes": [
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
7,
|
||||||
|
7,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
10,
|
||||||
|
11,
|
||||||
|
13,
|
||||||
|
14,
|
||||||
|
16,
|
||||||
|
17,
|
||||||
|
17,
|
||||||
|
17,
|
||||||
|
19,
|
||||||
|
19,
|
||||||
|
20,
|
||||||
|
21,
|
||||||
|
21,
|
||||||
|
23,
|
||||||
|
23,
|
||||||
|
24,
|
||||||
|
24,
|
||||||
|
27,
|
||||||
|
27,
|
||||||
|
29,
|
||||||
|
30,
|
||||||
|
31,
|
||||||
|
34,
|
||||||
|
35,
|
||||||
|
39
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user