mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 12:26:19 -05:00
Add per-domain and global daily download limits
Adds two optional DownloadManager settings: - download_daily_limit_per_domain: max non-recurring downloads per domain per day - download_daily_limit_global: max non-recurring downloads across all domains per day Recurring Channel/RSS catalog updates are never gated and never counted; only the videos/archives they spawn and one-off downloads count. Both successful and failed attempts consume a slot (counted once per download per day). Limits reset at local midnight (configured timezone). Over-limit downloads stay "new" and resume the next day. Implementation: - New Download.last_download_attempt column (+ index, migration) set at dispatch time so the count survives restarts and is correct across workers. - dispatch_downloads gates non-recurring downloads: per-domain skips that domain, global stops dispatching counted downloads for the cycle. daily_download_counts derives the day's totals from the DB. - Domain grouping uses normalized URLs via a new Downloader.normalize_domain method (base strips www/m/mobile + port); VideoDownloader/ChannelDownloader override it to collapse youtu.be, /shorts/, and tracking params to youtube.com. ArchiveDownloader is the seam for future archive URL normalization. - Settings wired through WROLPiConfig, the /settings API (GET/PATCH, non-negative validation, 0 = unlimited), and the React Settings page. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d6862ecd2d
commit
d95249218b
9 changed files with 478 additions and 11 deletions
|
|
@ -367,6 +367,11 @@ export function SettingsPage() {
|
|||
setPendingSave(true);
|
||||
newSettings.download_timeout = parseInt(newSettings.download_timeout);
|
||||
newSettings.download_wait = parseInt(newSettings.download_wait);
|
||||
// Empty daily-limit fields become null (no change / unlimited); a number is sent as-is.
|
||||
newSettings.download_daily_limit_per_domain = newSettings.download_daily_limit_per_domain === ''
|
||||
? null : parseInt(newSettings.download_daily_limit_per_domain);
|
||||
newSettings.download_daily_limit_global = newSettings.download_daily_limit_global === ''
|
||||
? null : parseInt(newSettings.download_daily_limit_global);
|
||||
newSettings.log_level = toApiLogLevel(newSettings.log_level);
|
||||
try {
|
||||
await saveSettings(newSettings);
|
||||
|
|
@ -456,6 +461,8 @@ export function SettingsPage() {
|
|||
require_media_mounted: settings.require_media_mounted,
|
||||
download_timeout: settings.download_timeout,
|
||||
download_wait: settings.download_wait,
|
||||
download_daily_limit_per_domain: settings.download_daily_limit_per_domain ?? '',
|
||||
download_daily_limit_global: settings.download_daily_limit_global ?? '',
|
||||
download_window_start: settings.download_window_start || '',
|
||||
download_window_end: settings.download_window_end || '',
|
||||
timezone: settings.timezone || '',
|
||||
|
|
@ -726,6 +733,34 @@ export function SettingsPage() {
|
|||
/>
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Daily Download Limit (per domain)</b>
|
||||
<InfoPopup
|
||||
content='Maximum number of downloads from any single domain per day. Recurring
|
||||
Channel/RSS catalog updates do not count; only the videos/archives they create
|
||||
and one-off downloads count. Leave empty or set to 0 for no limit.'/>
|
||||
</>}
|
||||
value={state.download_daily_limit_per_domain}
|
||||
disabled={disabled}
|
||||
onChange={(e, i) => handleTimeoutChange(e, 'download_daily_limit_per_domain', i.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
<b>Daily Download Limit (total)</b>
|
||||
<InfoPopup
|
||||
content='Maximum number of downloads across all domains per day. Recurring
|
||||
Channel/RSS catalog updates do not count. Leave empty or set to 0 for no limit.'/>
|
||||
</>}
|
||||
value={state.download_daily_limit_global}
|
||||
disabled={disabled}
|
||||
onChange={(e, i) => handleTimeoutChange(e, 'download_daily_limit_global', i.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group inline>
|
||||
<Form.Input
|
||||
label={<>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue