add configurable stop_on_bot setting to halt downloads on YouTube bot detection

This commit is contained in:
Jordan May 2026-02-13 00:45:12 -05:00
parent c4ac6441bd
commit f786a9c62e
No known key found for this signature in database
6 changed files with 31 additions and 0 deletions

View File

@ -59,6 +59,7 @@ class AppConfigDownloadsSerializer(
extractor_lang = serializers.CharField(allow_null=True)
integrate_ryd = serializers.BooleanField()
integrate_sponsorblock = serializers.BooleanField()
stop_on_bot = serializers.BooleanField()
class AppConfigAppSerializer(

View File

@ -46,6 +46,7 @@ class DownloadsConfigType(TypedDict):
extractor_lang: str | None
integrate_ryd: bool
integrate_sponsorblock: bool
stop_on_bot: bool
class ApplicationConfigType(TypedDict):
@ -95,6 +96,7 @@ class AppConfig:
"extractor_lang": None,
"integrate_ryd": False,
"integrate_sponsorblock": False,
"stop_on_bot": True,
},
"application": {
"enable_snapshot": True,

View File

@ -94,6 +94,11 @@ class YtWrap:
print(f"{url}: failed to download with message {err}")
if "Temporary failure in name resolution" in str(err):
raise ConnectionError("lost the internet, abort!") from err
if self.config["downloads"].get("stop_on_bot"):
if "not a bot" in str(err):
raise ConnectionError(
"YouTube bot detection, abort!"
) from err
return False, str(err)
@ -122,6 +127,11 @@ class YtWrap:
print(f"{url}: failed to get info from youtube: {err}")
if "Temporary failure in name resolution" in str(err):
raise ConnectionError("lost the internet, abort!") from err
if self.config["downloads"].get("stop_on_bot"):
if "not a bot" in str(err):
raise ConnectionError(
"YouTube bot detection, abort!"
) from err
return None, str(err)

View File

@ -27,6 +27,7 @@ export type AppSettingsConfigType = {
extractor_lang: string | null;
integrate_ryd: boolean;
integrate_sponsorblock: boolean;
stop_on_bot: boolean;
};
application: {
enable_snapshot: boolean;

View File

@ -50,6 +50,7 @@ const SettingsApplication = () => {
const [currentThrottledRate, setCurrentThrottledRate] = useState<number | null>(null);
const [currentScrapingSleep, setCurrentScrapingSleep] = useState<number | null>(null);
const [currentAutodelete, setCurrentAutodelete] = useState<number | null>(null);
const [stopOnBot, setStopOnBot] = useState(true);
// Download Format
const [downloadsFormat, setDownloadsFormat] = useState<string | null>(null);
@ -106,6 +107,7 @@ const SettingsApplication = () => {
setCurrentThrottledRate(appSettingsConfigData?.downloads.throttledratelimit || null);
setCurrentScrapingSleep(appSettingsConfigData?.downloads.sleep_interval || null);
setCurrentAutodelete(appSettingsConfigData?.downloads.autodelete_days || null);
setStopOnBot(appSettingsConfigData?.downloads.stop_on_bot ?? true);
// Download Format
setDownloadsFormat(appSettingsConfigData?.downloads.format || null);
@ -308,6 +310,10 @@ const SettingsApplication = () => {
<li>Minimal recommended is 10.</li>
</ul>
</li>
<li>
Stop on bot detection will stop the download queue when YT returns a bot
detection error instead of continuing to fail every remaining video.
</li>
<li>
Auto delete deletes videos marked as watched after x days.
<ul>
@ -357,6 +363,16 @@ const SettingsApplication = () => {
updateCallback={handleUpdateConfig}
/>
</div>
<div className="settings-box-wrapper">
<div>
<p>Stop queue on bot detection</p>
</div>
<ToggleConfig
name="downloads.stop_on_bot"
value={stopOnBot}
updateCallback={handleUpdateConfig}
/>
</div>
<div className="settings-box-wrapper">
<div>
<p>

View File

@ -34,6 +34,7 @@ export const useAppSettingsStore = create<AppSettingsState>(set => ({
extractor_lang: null,
integrate_ryd: false,
integrate_sponsorblock: false,
stop_on_bot: true,
},
application: {
enable_snapshot: false,