Feat: set_preset key for condition to switch preset based on yt-dlp data
This commit is contained in:
parent
eaa433e264
commit
fa7292ac35
3 changed files with 25 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,6 +164,10 @@
|
|||
<b>YTPTube</b> to ignore the download and directly mark the item as archived. this is useful
|
||||
to skip certain kind of downloads.
|
||||
</li>
|
||||
<li>The key <code>set_preset</code> with the name of an existing preset will instruct
|
||||
<b>YTPTube</b> to switch the download to use the specified preset. This is useful
|
||||
to apply different download settings based on content type or source.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue