diff --git a/OF DL/Crypto/Padding.cs b/OF DL/Crypto/Padding.cs index 1225e1e..5f4641b 100644 --- a/OF DL/Crypto/Padding.cs +++ b/OF DL/Crypto/Padding.cs @@ -37,7 +37,7 @@ public class Padding return result; } - public static byte[] AddPSSPadding(byte[] hash) + public static byte[]? AddPSSPadding(byte[] hash) { int modBits = 2048; int hLen = 20; diff --git a/OF DL/Helpers/IFileNameHelper.cs b/OF DL/Helpers/IFileNameHelper.cs index 6454742..0ea39f1 100644 --- a/OF DL/Helpers/IFileNameHelper.cs +++ b/OF DL/Helpers/IFileNameHelper.cs @@ -5,5 +5,5 @@ public interface IFileNameHelper Task BuildFilename(string fileFormat, Dictionary values); Task> GetFilename(object obj1, object obj2, object obj3, List selectedProperties, - string username, Dictionary users = null); + string username, Dictionary? users); } diff --git a/OF DL/Services/APIService.cs b/OF DL/Services/APIService.cs index 80edeb4..9c64c1d 100644 --- a/OF DL/Services/APIService.cs +++ b/OF DL/Services/APIService.cs @@ -125,7 +125,7 @@ public class APIService(IAuthService authService, IConfigService configService, try { - UserEntities.User? user = new(); + UserEntities.User user = new(); int post_limit = 50; Dictionary getParams = new() { @@ -166,7 +166,7 @@ public class APIService(IAuthService authService, IConfigService configService, return null; } - public async Task GetUserInfoById(string endpoint) + public async Task GetUserInfoById(string endpoint) { try { @@ -231,7 +231,7 @@ public class APIService(IAuthService authService, IConfigService configService, } - public async Task> GetLists(string endpoint) + public async Task?> GetLists(string endpoint) { Log.Debug("Calling GetLists"); @@ -358,7 +358,7 @@ public class APIService(IAuthService authService, IConfigService configService, } - public async Task> GetMedia(MediaType mediatype, + public async Task?> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, diff --git a/OF DL/Services/DownloadService.cs b/OF DL/Services/DownloadService.cs index da1b941..eb2c698 100644 --- a/OF DL/Services/DownloadService.cs +++ b/OF DL/Services/DownloadService.cs @@ -576,7 +576,10 @@ public class DownloadService( using HttpResponseMessage response = await client.GetAsync(mpdURL, HttpCompletionOption.ResponseHeadersRead); if (response.IsSuccessStatusCode) { - return response.Content.Headers.LastModified.Value.DateTime; + if (response.Content.Headers.LastModified != null) + { + return response.Content.Headers.LastModified.Value.DateTime; + } } return DateTime.Now; diff --git a/OF DL/Services/IAPIService.cs b/OF DL/Services/IAPIService.cs index a14c024..fe55d1f 100644 --- a/OF DL/Services/IAPIService.cs +++ b/OF DL/Services/IAPIService.cs @@ -16,10 +16,10 @@ public interface IAPIService Task GetDecryptionKeyCDM(Dictionary drmHeaders, string licenceURL, string pssh); Task GetDRMMPDLastModified(string mpdUrl, string policy, string signature, string kvp); Task GetDRMMPDPSSH(string mpdUrl, string policy, string signature, string kvp); - Task> GetLists(string endpoint); - Task> GetListUsers(string endpoint); + Task?> GetLists(string endpoint); + Task?> GetListUsers(string endpoint); - Task> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, + Task?> GetMedia(MediaType mediatype, string endpoint, string? username, string folder, List paid_post_ids); Task GetPaidPosts(string endpoint, string folder, string username, @@ -46,10 +46,10 @@ public interface IAPIService Task> GetPurchasedTab(string endpoint, string folder, Dictionary users); - Task GetUserInfo(string endpoint); - Task GetUserInfoById(string endpoint); + Task GetUserInfo(string endpoint); + Task GetUserInfoById(string endpoint); Dictionary GetDynamicHeaders(string path, string queryParam); - Task> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions); - Task> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions); + Task?> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions); + Task?> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions); Task GetDecryptionKeyOFDL(Dictionary drmHeaders, string licenceURL, string pssh); } diff --git a/OF DL/Utils/HttpUtil.cs b/OF DL/Utils/HttpUtil.cs index eaa7ebb..bd0203a 100644 --- a/OF DL/Utils/HttpUtil.cs +++ b/OF DL/Utils/HttpUtil.cs @@ -54,7 +54,7 @@ internal class HttpUtil return bytes; } - public static async Task GetWebSource(string URL, Dictionary headers = null) + public static async Task GetWebSource(string URL, Dictionary? headers = null) { HttpResponseMessage response = await PerformOperation(async () => { return await Get(URL, headers); }); @@ -62,7 +62,7 @@ internal class HttpUtil return Encoding.UTF8.GetString(bytes); } - public static async Task GetBinary(string URL, Dictionary headers = null) + public static async Task GetBinary(string URL, Dictionary? headers = null) { HttpResponseMessage response = await PerformOperation(async () => { return await Get(URL, headers); }); @@ -72,7 +72,7 @@ internal class HttpUtil public static string GetString(byte[] bytes) => Encoding.UTF8.GetString(bytes); - private static async Task Get(string URL, Dictionary headers = null) + private static async Task Get(string URL, Dictionary? headers = null) { HttpRequestMessage request = new() { RequestUri = new Uri(URL), Method = HttpMethod.Get }; @@ -87,8 +87,8 @@ internal class HttpUtil return await Send(request); } - private static async Task Post(string URL, Dictionary headers, - HttpContent content) + private static async Task Post(string URL, Dictionary? headers = null, + HttpContent? content = null) { HttpRequestMessage request = new() { RequestUri = new Uri(URL), Method = HttpMethod.Post, Content = content }; diff --git a/OF DL/Widevine/CDM.cs b/OF DL/Widevine/CDM.cs index d005cd5..64e352c 100644 --- a/OF DL/Widevine/CDM.cs +++ b/OF DL/Widevine/CDM.cs @@ -48,7 +48,7 @@ public class CDM 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); @@ -98,7 +98,7 @@ public class CDM return BytesToHex(sessionId); } - private static WidevineCencHeader ParseInitData(byte[] initData) + private static WidevineCencHeader? ParseInitData(byte[] initData) { WidevineCencHeader cencHeader; @@ -190,7 +190,7 @@ public class CDM return true; } - public static byte[] GetLicenseRequest(string sessionId) + public static byte[]? GetLicenseRequest(string sessionId) { //Logger.Debug($"GetLicenseRequest(sessionId={BytesToHex(sessionId)})"); //Logger.Verbose($"Getting license request"); diff --git a/OF DL/Widevine/CDMDevice.cs b/OF DL/Widevine/CDMDevice.cs index 887a91f..61ba112 100644 --- a/OF DL/Widevine/CDMDevice.cs +++ b/OF DL/Widevine/CDMDevice.cs @@ -11,8 +11,8 @@ namespace OF_DL.Widevine; public class CDMDevice { - public CDMDevice(string deviceName, byte[] clientIdBlobBytes = null, byte[] privateKeyBytes = null, - byte[] vmpBytes = null) + public CDMDevice(string deviceName, byte[]? clientIdBlobBytes = null, byte[]? privateKeyBytes = null, + byte[]? vmpBytes = null) { DeviceName = deviceName; diff --git a/OF DL/Widevine/ContentKey.cs b/OF DL/Widevine/ContentKey.cs index 3a25f9d..2487f56 100644 --- a/OF DL/Widevine/ContentKey.cs +++ b/OF DL/Widevine/ContentKey.cs @@ -6,11 +6,11 @@ namespace OF_DL.Widevine; [Serializable] public class ContentKey { - [JsonPropertyName("key_id")] public byte[] KeyID { get; set; } + [JsonPropertyName("key_id")] public byte[] KeyID { get; set; } = []; - [JsonPropertyName("type")] public string Type { get; set; } + [JsonPropertyName("type")] public string Type { get; set; } = ""; - [JsonPropertyName("bytes")] public byte[] Bytes { get; set; } + [JsonPropertyName("bytes")] public byte[] Bytes { get; set; } = []; [NotMapped] [JsonPropertyName("permissions")] @@ -20,7 +20,7 @@ public class ContentKey set => PermissionsString = string.Join(",", value); } - [JsonIgnore] public string PermissionsString { get; set; } + [JsonIgnore] public string PermissionsString { get; set; } = ""; public override string ToString() => $"{BitConverter.ToString(KeyID).Replace("-", "").ToLower()}:{BitConverter.ToString(Bytes).Replace("-", "").ToLower()}"; diff --git a/OF DL/Widevine/DerivedKeys.cs b/OF DL/Widevine/DerivedKeys.cs index 9aca670..2ca9d1d 100644 --- a/OF DL/Widevine/DerivedKeys.cs +++ b/OF DL/Widevine/DerivedKeys.cs @@ -2,7 +2,7 @@ namespace OF_DL.Widevine; public class DerivedKeys { - public byte[] Auth1 { get; set; } - public byte[] Auth2 { get; set; } - public byte[] Enc { get; set; } + public byte[] Auth1 { get; set; } = []; + public byte[] Auth2 { get; set; } = []; + public byte[] Enc { get; set; } = []; } diff --git a/OF DL/Widevine/PSSHBox.cs b/OF DL/Widevine/PSSHBox.cs index 64363d6..0e59099 100644 --- a/OF DL/Widevine/PSSHBox.cs +++ b/OF DL/Widevine/PSSHBox.cs @@ -57,7 +57,7 @@ internal class PSSHBox if (dataLength == 0) { - return new PSSHBox(kids, null); + return new PSSHBox(kids, []); } byte[] data = new byte[dataLength]; diff --git a/OF DL/Widevine/Session.cs b/OF DL/Widevine/Session.cs index e9177ef..d879aa5 100644 --- a/OF DL/Widevine/Session.cs +++ b/OF DL/Widevine/Session.cs @@ -1,24 +1,16 @@ namespace OF_DL.Widevine; -internal class Session +internal class Session(byte[] sessionId, dynamic initData, CDMDevice device, bool offline) { - public Session(byte[] sessionId, dynamic initData, CDMDevice device, bool offline) - { - SessionId = sessionId; - InitData = initData; - Offline = offline; - Device = device; - } - - public byte[] SessionId { get; set; } - public dynamic InitData { get; set; } - public bool Offline { get; set; } - public CDMDevice Device { get; set; } - public byte[] SessionKey { get; set; } - public DerivedKeys DerivedKeys { get; set; } - public byte[] LicenseRequest { get; set; } - public SignedLicense License { get; set; } - public SignedDeviceCertificate ServiceCertificate { get; set; } + public byte[] SessionId { get; set; } = sessionId; + public dynamic InitData { get; set; } = initData; + public bool Offline { get; set; } = offline; + public CDMDevice Device { get; set; } = device; + public byte[] SessionKey { get; set; } = []; + public DerivedKeys DerivedKeys { get; set; } = new(); + public byte[] LicenseRequest { get; set; } = []; + public SignedLicense License { get; set; } = new(); + public SignedDeviceCertificate ServiceCertificate { get; set; } = new(); public bool PrivacyMode { get; set; } - public List ContentKeys { get; set; } = new(); + public List ContentKeys { get; set; } = []; }