diff --git a/CRD/Downloader/CRAuth.cs b/CRD/Downloader/CRAuth.cs index dd798dd..ecbee79 100644 --- a/CRD/Downloader/CRAuth.cs +++ b/CRD/Downloader/CRAuth.cs @@ -113,12 +113,18 @@ public class CrAuth{ if (responseSubs.IsOk){ var subsc = Helpers.Deserialize(responseSubs.ResponseContent, crunInstance.SettingsJsonSerializerSettings); crunInstance.Profile.Subscription = subsc; - if ( subsc.SubscriptionProducts is{ Count: 0 } && subsc.ThirdPartySubscriptionProducts is{ Count: > 0 }){ + if ( subsc is{ SubscriptionProducts:{ Count: 0 }, ThirdPartySubscriptionProducts.Count: > 0 }){ var thirdPartySub = subsc.ThirdPartySubscriptionProducts.First(); var remaining = thirdPartySub.ExpirationDate - DateTime.UtcNow; crunInstance.Profile.HasPremium = remaining > TimeSpan.Zero; crunInstance.Profile.Subscription.IsActive = remaining > TimeSpan.Zero; crunInstance.Profile.Subscription.NextRenewalDate = thirdPartySub.ExpirationDate; + } else if(subsc is{ SubscriptionProducts:{ Count: 0 }, NonrecurringSubscriptionProducts.Count: > 0 }){ + var nonRecurringSub = subsc.NonrecurringSubscriptionProducts.First(); + var remaining = nonRecurringSub.EndDate - DateTime.UtcNow; + crunInstance.Profile.HasPremium = remaining > TimeSpan.Zero; + crunInstance.Profile.Subscription.IsActive = remaining > TimeSpan.Zero; + crunInstance.Profile.Subscription.NextRenewalDate = nonRecurringSub.EndDate; } else{ crunInstance.Profile.HasPremium = subsc.IsActive; } diff --git a/CRD/Utils/Structs/CrProfile.cs b/CRD/Utils/Structs/CrProfile.cs index e0a4e87..16d7e0a 100644 --- a/CRD/Utils/Structs/CrProfile.cs +++ b/CRD/Utils/Structs/CrProfile.cs @@ -45,9 +45,19 @@ public class Subscription{ public List? ThirdPartySubscriptionProducts{ get; set; } [JsonProperty("nonrecurring_subscription_products")] - public List? NonrecurringSubscriptionProducts{ get; set; } + public List? NonrecurringSubscriptionProducts{ get; set; } } +public class NonRecurringSubscriptionProduct{ + [JsonProperty("start_date")] + public DateTime StartDate{ get; set; } + [JsonProperty("end_date")] + public DateTime EndDate{ get; set; } + public string? Sku{ get; set; } + public string? Tier{ get; set; } +} + + public class SubscriptionProduct{ [JsonProperty("currency_code")] public string? CurrencyCode{ get; set; } diff --git a/CRD/ViewModels/AccountPageViewModel.cs b/CRD/ViewModels/AccountPageViewModel.cs index 0ab7b86..752564a 100644 --- a/CRD/ViewModels/AccountPageViewModel.cs +++ b/CRD/ViewModels/AccountPageViewModel.cs @@ -61,6 +61,8 @@ public partial class AccountPageViewModel : ViewModelBase{ if (sub != null){ IsCancelled = !sub.AutoRenew; } + }else if(Crunchyroll.Instance.Profile.Subscription?.NonrecurringSubscriptionProducts.Count >= 1){ + IsCancelled = true; } if (Crunchyroll.Instance.Profile.Subscription?.NextRenewalDate != null){