Add - Added forced display option to default subs

Fix - Grace period of third party subscription not detected
This commit is contained in:
Elwador 2024-07-26 06:05:05 +02:00
parent c1bb11c9fd
commit 5fc2d207e9
6 changed files with 26 additions and 7 deletions

View File

@ -114,10 +114,11 @@ public class CrAuth{
crunInstance.Profile.Subscription = subsc;
if ( subsc is{ SubscriptionProducts:{ Count: 0 }, ThirdPartySubscriptionProducts.Count: > 0 }){
var thirdPartySub = subsc.ThirdPartySubscriptionProducts.First();
var remaining = thirdPartySub.ExpirationDate - DateTime.UtcNow;
var expiration = thirdPartySub.InGrace ? thirdPartySub.InGraceExpirationDate : thirdPartySub.ExpirationDate;
var remaining = expiration - DateTime.UtcNow;
crunInstance.Profile.HasPremium = remaining > TimeSpan.Zero;
crunInstance.Profile.Subscription.IsActive = remaining > TimeSpan.Zero;
crunInstance.Profile.Subscription.NextRenewalDate = thirdPartySub.ExpirationDate;
crunInstance.Profile.Subscription.NextRenewalDate = expiration;
} else if(subsc is{ SubscriptionProducts:{ Count: 0 }, NonrecurringSubscriptionProducts.Count: > 0 }){
var nonRecurringSub = subsc.NonrecurringSubscriptionProducts.First();
var remaining = nonRecurringSub.EndDate - DateTime.UtcNow;

View File

@ -194,6 +194,9 @@ public class Merger{
if (options.Defaults.Sub.Code == subObj.Language.Code && CrunchyrollManager.Instance.CrunOptions.DefaultSubSigns == subObj.Signs && subObj.ClosedCaption == false){
args.Add("--default-track 0");
if (CrunchyrollManager.Instance.CrunOptions.DefaultSubForcedDisplay){
args.Add("--forced-track 0:yes");
}
} else{
args.Add("--default-track 0:0");
}

View File

@ -99,6 +99,9 @@ public class CrDownloadOptions{
[YamlMember(Alias = "mux_default_sub_signs", ApplyNamingConventions = false)]
public bool DefaultSubSigns{ get; set; }
[YamlMember(Alias = "mux_default_sub_forced_display", ApplyNamingConventions = false)]
public bool DefaultSubForcedDisplay{ get; set; }
[YamlMember(Alias = "mux_default_dub", ApplyNamingConventions = false)]
public string DefaultAudio{ get; set; }

View File

@ -91,4 +91,7 @@ public class ThirdPartySubscriptionProduct{
[JsonProperty("expiration_date")]
public DateTime ExpirationDate{ get; set; }
[JsonProperty("in_grace_expiration_date")]
public DateTime InGraceExpirationDate{ get; set; }
}

View File

@ -60,6 +60,9 @@ public partial class SettingsPageViewModel : ViewModelBase{
[ObservableProperty]
private bool _defaultSubSigns;
[ObservableProperty]
private bool _defaultSubForcedDisplay;
[ObservableProperty]
private bool _includeEpisodeDescription;
@ -382,6 +385,7 @@ public partial class SettingsPageViewModel : ViewModelBase{
AddScaledBorderAndShadow = options.SubsAddScaledBorder is ScaledBorderAndShadowSelection.ScaledBorderAndShadowNo or ScaledBorderAndShadowSelection.ScaledBorderAndShadowYes;
SelectedScaledBorderAndShadow = GetScaledBorderAndShadowFromOptions(options);
DefaultSubForcedDisplay = options.DefaultSubForcedDisplay;
DefaultSubSigns = options.DefaultSubSigns;
HistoryAddSpecials = options.HistoryAddSpecials;
DownloadSpeed = options.DownloadSpeedLimit;
@ -450,6 +454,7 @@ public partial class SettingsPageViewModel : ViewModelBase{
}
CrunchyrollManager.Instance.CrunOptions.DefaultSubSigns = DefaultSubSigns;
CrunchyrollManager.Instance.CrunOptions.DefaultSubForcedDisplay = DefaultSubForcedDisplay;
CrunchyrollManager.Instance.CrunOptions.IncludeVideoDescription = IncludeEpisodeDescription;
CrunchyrollManager.Instance.CrunOptions.HistoryAddSpecials = HistoryAddSpecials;
CrunchyrollManager.Instance.CrunOptions.VideoTitle = FileTitle;

View File

@ -309,10 +309,14 @@
<controls:SettingsExpanderItem Content="Default Subtitle ">
<controls:SettingsExpanderItem.Footer>
<ComboBox HorizontalContentAlignment="Center" MinWidth="210" MaxDropDownHeight="400"
ItemsSource="{Binding DefaultSubLangList}"
SelectedItem="{Binding SelectedDefaultSubLang}">
</ComboBox>
<StackPanel Orientation="Vertical">
<ComboBox HorizontalContentAlignment="Center" MinWidth="210" MaxDropDownHeight="400"
ItemsSource="{Binding DefaultSubLangList}"
SelectedItem="{Binding SelectedDefaultSubLang}">
</ComboBox>
<CheckBox Content="Forced Display" IsChecked="{Binding DefaultSubForcedDisplay}"> </CheckBox>
</StackPanel>
</controls:SettingsExpanderItem.Footer>
</controls:SettingsExpanderItem>