Fix - Crash on login screen

This commit is contained in:
Elwador 2024-06-19 17:00:08 +02:00
parent d220a7d0db
commit f53a5e9fe6
2 changed files with 51 additions and 26 deletions

View File

@ -1070,14 +1070,18 @@ public class Crunchyroll{
ErrorText = "DRM Authentication failed" ErrorText = "DRM Authentication failed"
}; };
} }
//TODO change back from error //TODO change back from error
Console.Error.WriteLine("Request to DRM Authentication successful"); Console.Error.WriteLine("Request to DRM Authentication successful");
DrmAuthData authData = Helpers.Deserialize<DrmAuthData>(decRequestResponse.ResponseContent, SettingsJsonSerializerSettings) ?? new DrmAuthData(); DrmAuthData authData = Helpers.Deserialize<DrmAuthData>(decRequestResponse.ResponseContent, SettingsJsonSerializerSettings) ?? new DrmAuthData();
//TODO change back from error
Console.Error.WriteLine("Deserialized Authentication successful");
Dictionary<string, string> authDataDict = new Dictionary<string, string> Dictionary<string, string> authDataDict = new Dictionary<string, string>
{ { "dt-custom-data", authData.CustomData ?? string.Empty },{ "x-dt-auth-token", authData.Token ?? string.Empty } }; { { "dt-custom-data", authData.CustomData ?? string.Empty },{ "x-dt-auth-token", authData.Token ?? string.Empty } };
//TODO change back from error
Console.Error.WriteLine("Requesting encryption keys");
var encryptionKeys = await _widevine.getKeys(chosenVideoSegments.pssh, "https://lic.drmtoday.com/license-proxy-widevine/cenc/", authDataDict); var encryptionKeys = await _widevine.getKeys(chosenVideoSegments.pssh, "https://lic.drmtoday.com/license-proxy-widevine/cenc/", authDataDict);
if (encryptionKeys.Count == 0){ if (encryptionKeys.Count == 0){
@ -1091,13 +1095,19 @@ public class Crunchyroll{
}; };
} }
//TODO change back from error
Console.Error.WriteLine("Requested encryption keys successful");
if (Path.Exists(CfgManager.PathMP4Decrypt)){ if (Path.Exists(CfgManager.PathMP4Decrypt)){
//TODO change back from error
Console.Error.WriteLine("Building command");
var keyId = BitConverter.ToString(encryptionKeys[0].KeyID).Replace("-", "").ToLower(); var keyId = BitConverter.ToString(encryptionKeys[0].KeyID).Replace("-", "").ToLower();
var key = BitConverter.ToString(encryptionKeys[0].Bytes).Replace("-", "").ToLower(); var key = BitConverter.ToString(encryptionKeys[0].Bytes).Replace("-", "").ToLower();
var commandBase = $"--show-progress --key {keyId}:{key}"; var commandBase = $"--show-progress --key {keyId}:{key}";
var commandVideo = commandBase + $" \"{tempTsFile}.video.enc.m4s\" \"{tempTsFile}.video.m4s\""; var commandVideo = commandBase + $" \"{tempTsFile}.video.enc.m4s\" \"{tempTsFile}.video.m4s\"";
var commandAudio = commandBase + $" \"{tempTsFile}.audio.enc.m4s\" \"{tempTsFile}.audio.m4s\""; var commandAudio = commandBase + $" \"{tempTsFile}.audio.enc.m4s\" \"{tempTsFile}.audio.m4s\"";
//TODO change back from error
Console.Error.WriteLine("Built command");
if (videoDownloaded){ if (videoDownloaded){
//TODO change back from error //TODO change back from error
Console.Error.WriteLine("Started decrypting video"); Console.Error.WriteLine("Started decrypting video");
@ -1145,10 +1155,14 @@ public class Crunchyroll{
IsPrimary = isPrimary IsPrimary = isPrimary
}); });
} }
} else{
//TODO change back from error
Console.Error.WriteLine("No Video downloaded");
} }
if (audioDownloaded){ if (audioDownloaded){
Console.WriteLine("Started decrypting audio"); //TODO change back from error
Console.Error.WriteLine("Started decrypting audio");
var decryptAudio = await Helpers.ExecuteCommandAsync("mp4decrypt", CfgManager.PathMP4Decrypt, commandAudio); var decryptAudio = await Helpers.ExecuteCommandAsync("mp4decrypt", CfgManager.PathMP4Decrypt, commandAudio);
if (!decryptAudio.IsOk){ if (!decryptAudio.IsOk){
@ -1192,9 +1206,12 @@ public class Crunchyroll{
IsPrimary = isPrimary IsPrimary = isPrimary
}); });
} }
} else{
//TODO change back from error
Console.Error.WriteLine("No Audio downloaded");
} }
} else{ } else{
Console.WriteLine("mp4decrypt not found, files need decryption. Decryption Keys: "); Console.Error.WriteLine("mp4decrypt not found, files need decryption. Decryption Keys: ");
MainWindow.Instance.ShowError($"mp4decrypt not found, files need decryption"); MainWindow.Instance.ShowError($"mp4decrypt not found, files need decryption");
} }
} else{ } else{

View File

@ -32,9 +32,6 @@ public partial class AccountPageViewModel : ViewModelBase{
public AccountPageViewModel(){ public AccountPageViewModel(){
UpdatetProfile(); UpdatetProfile();
} }
private void Timer_Tick(object sender, EventArgs e){ private void Timer_Tick(object sender, EventArgs e){
@ -52,22 +49,33 @@ public partial class AccountPageViewModel : ViewModelBase{
LoginLogoutText = Crunchyroll.Instance.Profile.Username == "???" ? "Login" : "Logout"; // Default state LoginLogoutText = Crunchyroll.Instance.Profile.Username == "???" ? "Login" : "Logout"; // Default state
LoadProfileImage("https://static.crunchyroll.com/assets/avatar/170x170/" + Crunchyroll.Instance.Profile.Avatar); LoadProfileImage("https://static.crunchyroll.com/assets/avatar/170x170/" + Crunchyroll.Instance.Profile.Avatar);
if (Crunchyroll.Instance.Profile.Subscription != null && Crunchyroll.Instance.Profile.Subscription?.SubscriptionProducts != null){ if (Crunchyroll.Instance.Profile.Subscription != null && Crunchyroll.Instance.Profile.Subscription?.SubscriptionProducts != null){
if (Crunchyroll.Instance.Profile.Subscription?.SubscriptionProducts.Count >= 1){
var sub = Crunchyroll.Instance.Profile.Subscription?.SubscriptionProducts.First(); var sub = Crunchyroll.Instance.Profile.Subscription?.SubscriptionProducts.First();
_targetTime = Crunchyroll.Instance.Profile.Subscription.NextRenewalDate;
if (sub != null){ if (sub != null){
IsCancelled = sub.IsCancelled; IsCancelled = sub.IsCancelled;
} }
}
if (Crunchyroll.Instance.Profile.Subscription?.NextRenewalDate != null){
_targetTime = Crunchyroll.Instance.Profile.Subscription.NextRenewalDate;
_timer = new DispatcherTimer{ _timer = new DispatcherTimer{
Interval = TimeSpan.FromSeconds(1) Interval = TimeSpan.FromSeconds(1)
}; };
_timer.Tick += Timer_Tick; _timer.Tick += Timer_Tick;
_timer.Start(); _timer.Start();
} else{
RemainingTime = "No active Subscription";
} }
} else{
RemainingTime = "No active Subscription";
if (_timer != null){
_timer.Stop();
_timer.Tick -= Timer_Tick;
}
RaisePropertyChanged(nameof(RemainingTime));
}
} }
[RelayCommand] [RelayCommand]