diff --git a/app/src/api.js b/app/src/api.js
index 1f7bea44..458c8763 100644
--- a/app/src/api.js
+++ b/app/src/api.js
@@ -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,
diff --git a/app/src/components/admin/Settings.js b/app/src/components/admin/Settings.js
index 054c0ec1..2337556c 100644
--- a/app/src/components/admin/Settings.js
+++ b/app/src/components/admin/Settings.js
@@ -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() {
/>
+
+
+ Do not download while cookies are locked
+
+ >}
+ disabled={disabled || state.require_cookies_unlocked === null}
+ checked={state.require_cookies_unlocked === true}
+ onChange={checked => handleInputChange(null, 'require_cookies_unlocked', checked)}
+ />
+
+
diff --git a/modules/archive/__init__.py b/modules/archive/__init__.py
index 6e4e0f6c..3145e3ed 100644
--- a/modules/archive/__init__.py
+++ b/modules/archive/__init__.py
@@ -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:
diff --git a/modules/archive/models.py b/modules/archive/models.py
index 87e16335..01dcea98 100644
--- a/modules/archive/models.py
+++ b/modules/archive/models.py
@@ -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):
diff --git a/wrolpi/common.py b/wrolpi/common.py
index 5a5628a5..59e9eb46 100644
--- a/wrolpi/common.py
+++ b/wrolpi/common.py
@@ -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']
diff --git a/wrolpi/downloader.py b/wrolpi/downloader.py
index 42bab7f1..3a5d30fa 100644
--- a/wrolpi/downloader.py
+++ b/wrolpi/downloader.py
@@ -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
diff --git a/wrolpi/root_api.py b/wrolpi/root_api.py
index 3722aea6..e021bbbc 100644
--- a/wrolpi/root_api.py
+++ b/wrolpi/root_api.py
@@ -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,
}
diff --git a/wrolpi/schema.py b/wrolpi/schema.py
index 0b485a3c..0e257dcd 100644
--- a/wrolpi/schema.py
+++ b/wrolpi/schema.py
@@ -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