Skip to content

feat: first-class account re-registration lifecycle with automatic throttling recovery (#2126) - #2145

Merged
Mbucari merged 8 commits into
rmcrackan:masterfrom
wtanksleyjr:feat/automatic-device-registration-recovery
Nov 12, 2026
Merged

Mbucari merged 8 commits into
rmcrackan:masterfrom
wtanksleyjr:feat/automatic-device-registration-recovery

Conversation

@wtanksleyjr

@wtanksleyjr wtanksleyjr commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

feat: first-class account re-registration lifecycle with automatic throttling recovery (#2126)

Summary

This PR introduces a first-class account re-registration lifecycle (Account.RequiresReRegistration) that allows Libation to prompt for and negotiate a fresh device registration without destroying user libraries, account metadata, or database associations.

By establishing this non-destructive re-registration mechanism:

  1. Audible Device Throttling is resolved automatically: Accounts trapped in CustomerThrottled errors due to obsolete or legacy registrations are automatically thunked to CurrentAndroid + Widevine and prompted for a seamless re-login, resolving the longstanding throttling issues reported across the project.
  2. Audio Quality Upgrades "Stick" Naturally ("better quality" scan & download doesn't stick (was ""better quality" -- maybe just discussion and user education") #2126): As a direct benefit of this re-registration engine, the "Scan Audible for Higher Quality Audio" feature now automatically configures Widevine/xHE-AAC settings and marks accounts for the necessary Android re-registration, eliminating the counterintuitive trap where users repeatedly re-downloaded the same low-quality streams.

Closes #2021, #2041, #2070, #2093, #2110, #2121, #2140, #2139, #2133, #2128, #2096, #2077, #2083
Fixes #2126


The Central Problem: No Way to "Thunk" an Account's Registration

Previously, Libation had no intermediate state between "fully authenticated" and "account deleted". When an account's device registration became obsolete or incompatible with requested streams, the only remedy was scorched-earth:

  • Delete the account from Settings > Accounts (or manually edit AccountsSettings.json).
  • Deregister the device on Amazon's website.
  • Re-enter credentials from scratch and re-import.

This architectural limitation caused two major user pain points:

  1. Audible CustomerThrottled Denials:
    Audible increasingly denies content license requests (CustomerThrottled) to accounts registered under legacy device profiles (Windows, non-hex serials, 16-character serials) or downloading non-Widevine streams. Because Libation could not flag an existing account for re-registration, downloads in the queue would simply fail or direct users to static troubleshooting docs.

  2. The Higher-Quality Audio Upgrade Loop ("better quality" scan & download doesn't stick (was ""better quality" -- maybe just discussion and user education") #2126):
    Obtaining Widevine and xHE-AAC streams strictly requires an Android-based device registration. When users used the "Scan Audible for Higher Quality Audio" tool to find better-quality audio, Libation would mark books as "Download Pending" but couldn't safely thunk the user's accounts to an Android Widevine registration. Users were left with unchanged global settings, causing subsequent downloads to repeatedly fetch the existing low-quality AAC-LC stream over and over.


Architecture & Key Changes

1. The Re-Registration Lifecycle (Account.RequiresReRegistration)

  • Domain Flag: Added Account.RequiresReRegistration, persisted in AccountsSettings.json.
  • Obsolete Registration Detection: Added Account.HasObsoleteDeviceRegistration() to identify legacy device types and non-conformant serials (validating against modern 20-character ASCII hex Android device serials).
  • Graceful Lifecycle Management: When an account is marked for re-registration:
    • Account name, marketplace, and library records are 100% preserved.
    • Cached authentication tokens are invalidated so that the next API call prompts cleanly for interactive browser login.
    • Upon successful sign-in with the new registration profile, RequiresReRegistration is cleared automatically.

2. Automatic Throttling Policy (ThrottledDeviceRecovery)

  • Policy Engine: Centralizes decision-making when handling ContentLicenseDeniedException (CustomerThrottled):
    • ShouldRecover: Identifies whether a throttle is registration-related (legacy profile or missing Widevine).
    • ApplyRecovery: Automatically switches settings to UseWidevine = true and DeviceRegistrationKind.CurrentAndroid, and marks accounts for re-registration via the new flag.
  • Queue Interception: If a download hits CustomerThrottled, ProcessBookViewModel and _ProcessableOptionsBase invoke ApplyRecovery and transition the item to LicenseDeniedThrottledRecovered, cleanly pausing the queue with guidance rather than looping or failing permanently.

3. Seamless Quality Upgrades as a Natural Result (#2126)

With the re-registration capability in place, resolving #2126 became straightforward:

  • When FindBetterQualityBooksViewModel.MarkBooksAsync() queues books for higher-quality downloads:
    • If Widevine was off, it sets UseWidevine = true, sets Request_xHE_AAC = true (if xHE-AAC was found), and uses ThrottledDeviceRecovery to mark accounts for the required Android registration.
    • If Widevine was already on, it marks any accounts carrying obsolete registrations so they avoid throttling during the upgrade download.
  • MarkBooksResult.GetSummaryMessage() unifies user messaging across Avalonia and WinForms, letting the user know settings were upgraded and whether a re-login prompt will appear on the next run.
  • Clarified the dialog help text (InitialMessage), fixing a truncated sentence and noting rate-limiting options (Daily Download Limit) when queuing large libraries for quality upgrades.

4. GUI & CLI Integration

  • Avalonia & WinForms Settings: Enabling Widevine in settings checks for configured accounts and offers to flag them for re-registration via shared constants in ThrottledDeviceRecovery, eliminating duplicated prompt text across frontends.
  • CLI (list-accounts & login-external):
    • list-accounts indicates re-login needed under the valid column when RequiresReRegistration is set.
    • login-external detects when an account needs re-registration or has an obsolete profile, automatically proceeds with authentication, updates the device profile to Android, and clears the flag upon completion.

5. Documentation

  • Overhauled docs/advanced/device-registration.md, docs/features/audio-file-formats.md, docs/features/daily-download-limit.md, and troubleshooting guides to describe the automated recovery flow and distinguish registration-based throttling from daily download rate limits.
  • Removed obsolete documentation instructing users to delete accounts, clear local JSON files, or manually deregister devices on Amazon.

Verification & Testing

  • Automated Tests:
    • AudibleUtilities.Tests: Unit tests for RequiresReRegistration, HasObsoleteDeviceRegistration (testing modern 20-hex vs 16/32/non-hex formats), ApplyRecovery, and MarkObsoleteAccounts.
    • LibationUiBase.Tests: Added FindBetterQualityBooksViewModelTests verifying the automatic upgrade flow, config changes, and summary messaging.
    • LibationCli.Tests: Tests for CLI re-registration detection in LoginExternalOptionsTests.
    • All test suites pass: 166 passed in AudibleUtilities.Tests, 252 passed in LibationUiBase.Tests, 96 passed in LibationCli.Tests.
  • Build Quality: Clean build across all 34 projects on Linux (net10.0 / non-Windows SDK with EnableWindowsTargeting) with 0 warnings and 0 errors.

…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
…ad 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
- 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
…ance

- 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
… 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.
@wtanksleyjr

Copy link
Copy Markdown
Contributor Author

The newer commit adds a checkbox to each account on the Accounts page to allow the user to see, and optionally to clear, the registration on the account; documentation updated as well. This was done because I noticed I'd missed an error message that suggests logging out was a good idea, so I needed to give a way to do that in GUI (the CLI already could).

…ADRM fails (rmcrackan#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.
@wtanksleyjr

Copy link
Copy Markdown
Contributor Author

Added automatic recovery for titles requiring Widevine DRM (#2083):

  • Defense-in-depth detection: In addition to Sable 000307 (acr:null) on standard ADRM license requests, WidevineRecommendation now also recognizes secondary AAX fallback failures where no codecs are returned (Book has no codec specified), resolving Book download fails: no codec specified for Starsight (Audible ID 1409167399) #2083 directly within Libation without requiring external API changes.
  • Automated recovery & thunking: Instead of displaying a static warning directing users to manually toggle settings, Libation automatically invokes ThrottledDeviceRecovery.ApplyRecovery: it enables Widevine DRM, ensures the device profile is set to Android, and marks the account for re-registration (Account.RequiresReRegistration = true) so that Widevine credentials can be acquired on the next sign-in.
  • Modernized guidance: Updated the UI dialog, process queue row status (Widevine enabled (re-login needed)), and CLI output (libationcli login-external) to inform users that Widevine was automatically enabled and a fresh login is queued.

@Mbucari
Mbucari merged commit 3e40e0f into rmcrackan:master Nov 12, 2026
11 checks passed
@wtanksleyjr
wtanksleyjr deleted the feat/automatic-device-registration-recovery branch November 13, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants