Adding toggle to prevent downloads from starting when cookies are locked.

This commit is contained in:
Roland 2026-03-14 12:08:23 -06:00
parent 9b3a03012e
commit ae7ab1981f
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
8 changed files with 36 additions and 3 deletions

View file

@ -316,6 +316,7 @@ export async function getSettings() {
map_destination: content.map_destination,
nav_color: content.nav_color,
media_directory: content.media_directory,
require_cookies_unlocked: content.require_cookies_unlocked,
save_ffprobe_json: content.save_ffprobe_json,
tags_directory: content.tags_directory,
throttle_on_startup: content.throttle_on_startup,

View file

@ -452,6 +452,7 @@ export function SettingsPage() {
// Only these settings can be changed on the SettingsPage.
archive_destination: settings.archive_destination,
download_on_startup: settings.download_on_startup,
require_cookies_unlocked: settings.require_cookies_unlocked,
download_timeout: settings.download_timeout,
download_wait: settings.download_wait,
download_window_start: settings.download_window_start || '',
@ -672,6 +673,19 @@ export function SettingsPage() {
/>
</div>
<div style={{margin: '0.5em'}}>
<Toggle
label={<>
Do not download while cookies are locked
<InfoPopup
content='When enabled, downloads will wait until cookies are unlocked. If no cookies are configured, downloads proceed normally.'/>
</>}
disabled={disabled || state.require_cookies_unlocked === null}
checked={state.require_cookies_unlocked === true}
onChange={checked => handleInputChange(null, 'require_cookies_unlocked', checked)}
/>
</div>
<Form.Group inline>
<Form.Input
label={<>

View file

@ -76,7 +76,7 @@ class ArchiveDownloader(Downloader, ABC):
need_commit = False
if tag_names := download.tag_names:
for name in tag_names:
archive.add_tag(name, session)
archive.add_tag(session, name)
need_commit = True
if need_commit:

View file

@ -393,8 +393,8 @@ class Archive(Base, ModelHelper):
archive = model_archive(session, file_group)
return archive
def add_tag(self, tag_id_or_name: int | str, session: Session = None) -> TagFile:
return self.file_group.add_tag(tag_id_or_name, session)
def add_tag(self, session: Session, tag_id_or_name: int | str) -> TagFile:
return self.file_group.add_tag(session, tag_id_or_name)
@property
def location(self):

View file

@ -803,6 +803,7 @@ class WROLPiConfigValidator:
log_level: str = None
map_destination: str = None
nav_color: str = None
require_cookies_unlocked: bool = None
save_ffprobe_json: bool = None
tags_directory: bool = None
throttle_on_startup: bool = None
@ -948,6 +949,7 @@ class WROLPiConfig(ConfigFile):
log_level='info',
map_destination='map',
nav_color='violet',
require_cookies_unlocked=True,
save_ffprobe_json=True,
tags_directory=True,
throttle_on_startup=False,
@ -1009,6 +1011,14 @@ class WROLPiConfig(ConfigFile):
def download_on_startup(self, value: bool):
self.update({'download_on_startup': value})
@property
def require_cookies_unlocked(self) -> bool:
return self._config.get('require_cookies_unlocked', True)
@require_cookies_unlocked.setter
def require_cookies_unlocked(self, value: bool):
self.update({'require_cookies_unlocked': value})
@property
def download_timeout(self) -> int:
return self._config['download_timeout']

View file

@ -645,6 +645,11 @@ class DownloadManager:
if wrol_mode_enabled():
# Do not download with WROL Mode enabled.
return False
if get_wrolpi_config().require_cookies_unlocked \
and flags.cookies_exist.is_set() \
and not flags.cookies_unlocked.is_set():
# Do not download when cookies exist but are not unlocked.
return False
if not self.is_within_download_window():
# Do not download outside the configured time window.
return False

View file

@ -178,6 +178,7 @@ def get_settings(_: Request):
'videos_destination': wrolpi_config.videos_destination,
'wrol_mode': wrolpi_config.wrol_mode,
'zims_destination': wrolpi_config.zims_destination,
'require_cookies_unlocked': wrolpi_config.require_cookies_unlocked,
'save_ffprobe_json': wrolpi_config.save_ffprobe_json,
'timezone': wrolpi_config.timezone,
}

View file

@ -31,6 +31,7 @@ class SettingsResponse:
log_level: str
nav_color: str
media_directory: str
require_cookies_unlocked: bool
tags_directory: bool
throttle_on_startup: bool
throttle_status: str
@ -82,6 +83,7 @@ class SettingsRequest:
videos_destination: Optional[str] = None
wrol_mode: Optional[bool] = None
zims_destination: Optional[str] = None
require_cookies_unlocked: Optional[bool] = None
save_ffprobe_json: Optional[bool] = None
timezone: Optional[str] = None