mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-12-01 02:32:35 +01:00
feat: first-class account re-registration lifecycle with automatic throttling recovery (#2126) (#2145)
* feat(domain): add RequiresReRegistration and ThrottledDeviceRecovery policy - Add Account.RequiresReRegistration property and HasObsoleteDeviceRegistration predicate - Update AccountCredentialStatus to treat RequiresReRegistration as missing credentials - Introduce ThrottledDeviceRecovery service to detect throttling on obsolete profiles and mark accounts for re-registration - Add unit tests for Account, AccountCredentialStatus, and ThrottledDeviceRecovery * feat(core): enforce interactive re-registration across API and download queue - Intercept RequiresReRegistration in ApiExtended, invalidate tokens during login, and reset flag upon success - Add LicenseDeniedThrottledRecovered queue status and user message - Update ProcessBookViewModel, ProcessQueueViewModel, and _ProcessableOptionsBase to handle throttled recovery during liberation * feat(ui): add Widevine re-registration prompts and CLI status reporting - Prompt to mark accounts for re-registration when Widevine is enabled in Avalonia and WinForms - Guard settings toggle against passive navigation/loading events and revert cleanly on cancel - Show 're-login needed' in 'list-accounts' and automatically re-register in 'login-external' - Add CLI tests for re-registration detection and flow in LoginExternalOptionsTests * docs: document automatic registration recovery and rate limiting guidance - Clarify distinction between device-registration throttling and volume rate limits - Document automatic settings migration and re-registration flow across GUI and CLI - Advise using Daily Download Limit when bulk re-downloading after scanning for higher quality audio - Remove obsolete manual account deletion and JSON editing instructions * feat(ui): automatically enable Widevine and re-register accounts when upgrading book quality When upgrading audio quality via 'Scan Audible for Higher Quality Audio', marking books for re-download previously left Widevine disabled and accounts under legacy registrations, causing subsequent downloads to re-acquire the existing lower-quality AAC-LC stream. - Update FindBetterQualityBooksViewModel.MarkBooksAsync() to return a MarkBooksResult and automatically enable Widevine and Request xHE-AAC when higher-quality streams are selected. - Thunk accounts to CurrentAndroid and mark them for re-registration via ThrottledDeviceRecovery so that Widevine-protected and higher-quality codecs can be licensed without manual troubleshooting. - Alert user in Avalonia and WinForms dialogs when settings and registrations have been automatically upgraded. - Fix broken sentence and note daily download limits and rate limiting in FindBetterQualityBooksViewModel.InitialMessage. - Add unit tests in FindBetterQualityBooksViewModelTests covering clean and upgraded re-registration paths. * feat(accounts): add 'Signed in?' checkbox to mark accounts for re-registration on save * docs & fix(recovery): modernize license recovery guidance and document 'Signed in?' * feat(recovery): automatically enable Widevine and thunk account when ADRM fails (#2083) - Detects missing ADRM asset (Sable 000307 acr:null) and missing AAX fallback codecs in titles that only deliver via Widevine. - Instead of merely advising the user to change settings manually, automatically applies recovery via ThrottledDeviceRecovery.ApplyRecovery (sets UseWidevine = true, CurrentAndroid, and marks the account for re-registration). - Modernizes user-facing dialogs, process queue status, and CLI feedback to explain that Widevine DRM was enabled and a fresh login is required.
This commit is contained in:
committed by
GitHub
parent
503904e6f4
commit
3e40e0f268
@@ -1,6 +1,7 @@
|
||||
using ApplicationServices;
|
||||
using ApplicationServices;
|
||||
using AudibleApi;
|
||||
using AudibleApi.Common;
|
||||
using AudibleUtilities;
|
||||
using DataLayer;
|
||||
using Dinah.Core;
|
||||
using Dinah.Core.ErrorHandling;
|
||||
@@ -27,6 +28,8 @@ public enum ProcessBookResult
|
||||
LicenseDeniedPossibleOutage,
|
||||
/// <summary>Audible named CustomerThrottled on the license denial.</summary>
|
||||
LicenseDeniedThrottled,
|
||||
/// <summary>Audible throttled on legacy/non-Widevine registration; settings thunked to Android+Widevine and account marked for re-registration.</summary>
|
||||
LicenseDeniedThrottledRecovered,
|
||||
/// <summary>ADRM licenserequest failed with Sable acr:null; Widevine may work (see WidevineRecommendation).</summary>
|
||||
WidevineRecommended,
|
||||
/// <summary>Volume full on write; queue should stop (see ProcessQueueViewModel queue loop).</summary>
|
||||
@@ -89,6 +92,7 @@ public class ProcessBookViewModel : ReactiveObject
|
||||
(ProcessBookResult.LicenseDenied, false) => "License Denied",
|
||||
(ProcessBookResult.LicenseDeniedPossibleOutage, _) => "Possible Service Interruption",
|
||||
(ProcessBookResult.LicenseDeniedThrottled, _) => "License denied (throttled)",
|
||||
(ProcessBookResult.LicenseDeniedThrottledRecovered, _) => "License denied (re-login needed)",
|
||||
(ProcessBookResult.WidevineRecommended, _) => WidevineRecommendationUserMessage.QueueStatusText,
|
||||
(ProcessBookResult.DiskFull, _) => "Disk full, queue stopped",
|
||||
_ => Status.ToString(),
|
||||
@@ -231,10 +235,16 @@ public class ProcessBookViewModel : ReactiveObject
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ApiErrorException ex) when (WidevineRecommendation.ShouldRecommendWidevine(ex, Configuration))
|
||||
catch (Exception ex) when (WidevineRecommendation.ShouldRecommendWidevine(ex, Configuration))
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "ADRM license unavailable (Sable acr:null) for {Book}", LibraryBook.LogFriendly());
|
||||
LogInfo($"{procName}: {WidevineRecommendationUserMessage.BuildLogSummary(LibraryBook.Book.TitleWithSubtitle)}");
|
||||
Serilog.Log.Logger.Error(ex, "ADRM license unavailable (Sable acr:null or AAX fallback without codecs) for {Book}", LibraryBook.LogFriendly());
|
||||
if (System.IO.File.Exists(AudibleApiStorage.AccountsSettingsFile))
|
||||
{
|
||||
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
||||
var account = persister.AccountsSettings.GetAccount(LibraryBook.Account, LibraryBook.Book.Locale);
|
||||
ThrottledDeviceRecovery.ApplyRecovery(persister.AccountsSettings, Configuration, account);
|
||||
}
|
||||
LogInfo($"{procName}: {WidevineRecommendationUserMessage.BuildLogSummary(LibraryBook.Book.TitleWithSubtitle, LibraryBook.Account.ToMask())}");
|
||||
result = ProcessBookResult.WidevineRecommended;
|
||||
}
|
||||
catch (ContentLicenseDeniedException ldex)
|
||||
@@ -242,8 +252,25 @@ public class ProcessBookViewModel : ReactiveObject
|
||||
Serilog.Log.Logger.Error(ldex, "Content license was denied for {Book}", LibraryBook.LogFriendly());
|
||||
if (ldex.IsCustomerThrottled)
|
||||
{
|
||||
LogInfo($"{procName}: Audible reports throttling. Try deregistering Libation devices and recreating the account first. Recovery steps: {AppScaffolding.LicenseRecoveryGuidance.DocumentationUrl}. If it persists, wait 24 to 48 hours, sometimes a few days. - {LibraryBook.Book}");
|
||||
result = ProcessBookResult.LicenseDeniedThrottled;
|
||||
bool recovered = false;
|
||||
if (System.IO.File.Exists(AudibleApiStorage.AccountsSettingsFile))
|
||||
{
|
||||
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
||||
var account = persister.AccountsSettings.GetAccount(LibraryBook.Account, LibraryBook.Book.Locale);
|
||||
if (ThrottledDeviceRecovery.ShouldRecover(ldex, account, Configuration.Instance))
|
||||
{
|
||||
ThrottledDeviceRecovery.ApplyRecovery(persister.AccountsSettings, Configuration.Instance, account);
|
||||
LogInfo($"{procName}: Audible reports throttling on a legacy or non-Widevine registration. Libation updated settings to Android + Widevine and marked account '{LibraryBook.Account.ToMask()}' for re-registration. Sign in on next scan or liberate to complete setup. - {LibraryBook.Book}");
|
||||
result = ProcessBookResult.LicenseDeniedThrottledRecovered;
|
||||
recovered = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!recovered)
|
||||
{
|
||||
LogInfo($"{procName}: Audible reports throttling. Try deregistering Libation devices and recreating the account first. Recovery steps: {AppScaffolding.LicenseRecoveryGuidance.DocumentationUrl}. If it persists, wait 24 to 48 hours, sometimes a few days. - {LibraryBook.Book}");
|
||||
result = ProcessBookResult.LicenseDeniedThrottled;
|
||||
}
|
||||
}
|
||||
else if (ldex.AYCL?.RejectionReason is null or RejectionReason.GenericError)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user