Address compiler warnings

This commit is contained in:
whimsical-c4lic0 2026-02-09 04:48:21 -06:00
parent 44a9fb1fcd
commit 17af1e8dfe
12 changed files with 46 additions and 51 deletions

View File

@ -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;

View File

@ -5,5 +5,5 @@ public interface IFileNameHelper
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);
string username, Dictionary<string, long>? users);
}

View File

@ -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<string, string> getParams = new()
{
@ -166,7 +166,7 @@ public class APIService(IAuthService authService, IConfigService configService,
return null;
}
public async Task<JObject> GetUserInfoById(string endpoint)
public async Task<JObject?> GetUserInfoById(string endpoint)
{
try
{
@ -231,7 +231,7 @@ public class APIService(IAuthService authService, IConfigService configService,
}
public async Task<Dictionary<string, long>> GetLists(string endpoint)
public async Task<Dictionary<string, long>?> GetLists(string endpoint)
{
Log.Debug("Calling GetLists");
@ -358,7 +358,7 @@ public class APIService(IAuthService authService, IConfigService configService,
}
public async Task<Dictionary<long, string>> GetMedia(MediaType mediatype,
public async Task<Dictionary<long, string>?> GetMedia(MediaType mediatype,
string endpoint,
string? username,
string folder,

View File

@ -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;

View File

@ -16,10 +16,10 @@ public interface IAPIService
Task<string> GetDecryptionKeyCDM(Dictionary<string, string> drmHeaders, string licenceURL, string pssh);
Task<DateTime> GetDRMMPDLastModified(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<List<string>> GetListUsers(string endpoint);
Task<Dictionary<string, long>?> GetLists(string endpoint);
Task<List<string>?> GetListUsers(string endpoint);
Task<Dictionary<long, string>> GetMedia(MediaType mediatype, string endpoint, string? username, string folder,
Task<Dictionary<long, string>?> GetMedia(MediaType mediatype, string endpoint, string? username, string folder,
List<long> paid_post_ids);
Task<PurchasedEntities.PaidPostCollection> GetPaidPosts(string endpoint, string folder, string username,
@ -46,10 +46,10 @@ public interface IAPIService
Task<List<PurchasedEntities.PurchasedTabCollection>> GetPurchasedTab(string endpoint, string folder,
Dictionary<string, long> users);
Task<UserEntities.User> GetUserInfo(string endpoint);
Task<JObject> GetUserInfoById(string endpoint);
Task<UserEntities.User?> GetUserInfo(string endpoint);
Task<JObject?> GetUserInfoById(string endpoint);
Dictionary<string, string> GetDynamicHeaders(string path, string queryParam);
Task<Dictionary<string, long>> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions);
Task<Dictionary<string, long>> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions);
Task<Dictionary<string, long>?> GetActiveSubscriptions(string endpoint, bool includeRestrictedSubscriptions);
Task<Dictionary<string, long>?> GetExpiredSubscriptions(string endpoint, bool includeRestrictedSubscriptions);
Task<string> GetDecryptionKeyOFDL(Dictionary<string, string> drmHeaders, string licenceURL, string pssh);
}

View File

@ -54,7 +54,7 @@ internal class HttpUtil
return bytes;
}
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)
{
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<byte[]> GetBinary(string URL, Dictionary<string, string> headers = null)
public static async Task<byte[]> GetBinary(string URL, Dictionary<string, string>? 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<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() { RequestUri = new Uri(URL), Method = HttpMethod.Get };
@ -87,8 +87,8 @@ internal class HttpUtil
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 = null,
HttpContent? content = null)
{
HttpRequestMessage request = new() { RequestUri = new Uri(URL), Method = HttpMethod.Post, Content = content };

View File

@ -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");

View File

@ -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;

View File

@ -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()}";

View File

@ -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; } = [];
}

View File

@ -57,7 +57,7 @@ internal class PSSHBox
if (dataLength == 0)
{
return new PSSHBox(kids, null);
return new PSSHBox(kids, []);
}
byte[] data = new byte[dataLength];

View File

@ -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<ContentKey> ContentKeys { get; set; } = new();
public List<ContentKey> ContentKeys { get; set; } = [];
}