diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index b3d04546..245c6d58 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -828,6 +828,17 @@ class DownloadQueue(metaclass=Singleton): ) return {"status": "ok"} + if condition.extras.get("set_preset") and (target_preset := condition.extras.get("set_preset")): + if Presets.get_instance().has(target_preset): + log_message: str = f"Switching preset from '{item.preset}' to '{target_preset}' for '{item_title}' as per condition '{condition.name}'." + LOG.info(log_message) + self._notify.emit(Events.LOG_INFO, data={}, title="Preset Switched", message=log_message) + item = item.new_with(preset=target_preset) + else: + LOG.warning( + f"Preset '{target_preset}' specified in condition '{condition.name}' does not exist. Ignoring set_preset." + ) + return await self.add(item=item.new_with(requeued=True, cli=condition.cli), already=already) _status, _msg = ytdlp_reject(entry=entry, yt_params=yt_conf) diff --git a/app/schema/conditions.json b/app/schema/conditions.json index 54b4c2a0..7ebcb3ac 100644 --- a/app/schema/conditions.json +++ b/app/schema/conditions.json @@ -38,18 +38,20 @@ }, "examples": [ { - "id": "c1e2d3f4-5678-1234-9abc-def012345678", - "name": "Audio Only", - "filter": "type=audio", - "cli": "--extract-audio", + "id": "a2b3c4d5-6789-2345-0bcd-ef1234567890", + "name": "Long Videos", + "filter": "duration>3600", "extras": { - "priority": "high" + "ignore_download": true } }, { - "id": "a2b3c4d5-6789-2345-0bcd-ef1234567890", - "name": "Long Videos", - "filter": "duration>3600" + "id": "b3c4d5e6-7890-3456-1cde-f23456789012", + "name": "Use Audio Preset for Music", + "filter": "categories~='Music'", + "extras": { + "set_preset": "audio-only" + } } ] } diff --git a/ui/app/components/ConditionForm.vue b/ui/app/components/ConditionForm.vue index c5e2e1af..15c9d5f8 100644 --- a/ui/app/components/ConditionForm.vue +++ b/ui/app/components/ConditionForm.vue @@ -164,6 +164,10 @@ YTPTube to ignore the download and directly mark the item as archived. this is useful to skip certain kind of downloads. +
  • The key set_preset with the name of an existing preset will instruct + YTPTube to switch the download to use the specified preset. This is useful + to apply different download settings based on content type or source. +