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"
};
}
//TODO change back from error
Console.Error.WriteLine("Request to DRM Authentication successful");
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>
{ { "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);
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)){
//TODO change back from error
Console.Error.WriteLine("Building command");
var keyId = BitConverter.ToString(encryptionKeys[0].KeyID).Replace("-", "").ToLower();
var key = BitConverter.ToString(encryptionKeys[0].Bytes).Replace("-", "").ToLower();
var commandBase = $"--show-progress --key {keyId}:{key}";
var commandVideo = commandBase + $" \"{tempTsFile}.video.enc.m4s\" \"{tempTsFile}.video.m4s\"";
var commandAudio = commandBase + $" \"{tempTsFile}.audio.enc.m4s\" \"{tempTsFile}.audio.m4s\"";
//TODO change back from error
Console.Error.WriteLine("Built command");
if (videoDownloaded){
//TODO change back from error
Console.Error.WriteLine("Started decrypting video");
@ -1145,10 +1155,14 @@ public class Crunchyroll{
IsPrimary = isPrimary
});
}
} else{
//TODO change back from error
Console.Error.WriteLine("No Video downloaded");
}
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);
if (!decryptAudio.IsOk){
@ -1192,9 +1206,12 @@ public class Crunchyroll{
IsPrimary = isPrimary
});
}
} else{
//TODO change back from error
Console.Error.WriteLine("No Audio downloaded");
}
} 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");
}
} else{
@ -1380,7 +1397,7 @@ public class Crunchyroll{
if (sBodySplit.Count > 2){
if (options.SubsAddScaledBorder == ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes){
sBodySplit.Insert(2, "ScaledBorderAndShadow: yes");
}else if (options.SubsAddScaledBorder == ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo){
} else if (options.SubsAddScaledBorder == ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo){
sBodySplit.Insert(2, "ScaledBorderAndShadow: no");
}
}

View File

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