mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-09-12 21:57:19 -04:00
Records every successful audiobook download in the library database (a new DownloadHistory table) and, when the user opts in, stops downloading once the rolling 24 hour window is full. The history lives in the database rather than a file under LibationFiles because in Docker only the database is on a volume; a file there is discarded on every container restart. The limit is checked immediately before each book downloads, never at queueing time, so a full queue stays full and the user can raise or disable the limit mid-run. When nothing in the queue can proceed the queue pauses and re-checks every 15 seconds, recomputing settings, history and clock from scratch, so a queue left running for days drip-feeds itself as downloads age out. The CLI never waits: it skips covered titles and reports a count. Co-authored-by: rmcrackan <rmcrackan@gmail.com>
68 lines
3.1 KiB
C#
68 lines
3.1 KiB
C#
using ApplicationServices;
|
|
using LibationFileManager;
|
|
using System;
|
|
|
|
namespace LibationUiBase;
|
|
|
|
/// <summary>
|
|
/// User-facing copy when Audible denies a content license (download/decrypt). Covers temporary
|
|
/// service issues and Audible Plus throttling — often mistaken for a Libation bug.
|
|
/// Shared by WinForms and Avalonia via the process queue.
|
|
/// </summary>
|
|
public static class ContentLicenseDeniedUserMessage
|
|
{
|
|
public const string DialogCaption = "Content license denied";
|
|
|
|
/// <summary>Generic outage / GenericError-style denial: not specific to Plus titles.</summary>
|
|
public static string BuildDialogBodyForPossibleOutage(string bookTitleWithSubtitle)
|
|
=> $"""
|
|
You were denied a content license for {bookTitleWithSubtitle}
|
|
|
|
This error often reflects a temporary interruption of service on Audible's side. It usually resolves within about 1 to 2 days, and in the meantime you should still be able to access your books through Audible's website or app.
|
|
|
|
Heavy use of the Audible Plus catalog in a short time can also produce "license denied" responses; community reports often involve on the order of dozens of titles — Audible does not publish a fixed limit. Waiting 24 to 48 hours before trying again is usually enough.
|
|
|
|
If the problem continues after several days, open an issue on Libation's GitHub and include your logs.
|
|
""" + AppendSuggestion();
|
|
|
|
/// <summary>License denied on an Audible Plus title — often rate limiting, not a Libation defect.</summary>
|
|
public static string BuildDialogBodyForPlusCatalog(string bookTitleWithSubtitle)
|
|
=> $"""
|
|
You were denied a content license for {bookTitleWithSubtitle}
|
|
|
|
This title is from the Audible Plus catalog. Audible sometimes temporarily denies content licenses after heavy Plus use in a short period; community reports often mention on the order of dozens of downloads — Audible does not publish a fixed limit. This is usually not a Libation bug.
|
|
|
|
Try waiting 24 to 48 hours and liberate again. If it still fails after several days, open an issue on Libation's GitHub with logs.
|
|
|
|
If you should not have access to this title (for example it left Plus before you downloaded), confirm in the Audible app or website.
|
|
""" + AppendSuggestion();
|
|
|
|
/// <summary>
|
|
/// Audible reports no distinct "throttled" reason, so this suggestion is what turns a guess into evidence:
|
|
/// it only appears when Libation's own record shows enough recent downloads for throttling to be plausible,
|
|
/// and when the user has no daily limit configured yet. Logged as well as shown.
|
|
/// </summary>
|
|
private static string AppendSuggestion()
|
|
{
|
|
try
|
|
{
|
|
var now = DateTimeOffset.Now;
|
|
var suggestion = DailyDownloadLimitUserMessage.BuildSuggestionParagraph(
|
|
Configuration.Instance,
|
|
DownloadHistoryStore.GetCurrentWindow(now),
|
|
now);
|
|
|
|
if (suggestion is null)
|
|
return string.Empty;
|
|
|
|
Serilog.Log.Logger.Information("Suggesting a daily download limit after a license denial. {Suggestion}", suggestion);
|
|
return Environment.NewLine + Environment.NewLine + suggestion;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Serilog.Log.Logger.Error(ex, "Failed to build the daily download limit suggestion");
|
|
return string.Empty;
|
|
}
|
|
}
|
|
}
|