mirror of
https://github.com/tropicoo/yt-dlp-bot.git
synced 2024-09-20 06:46:08 +08:00
Merge 783967571e
into 11f04eddf4
This commit is contained in:
commit
1c2020c02d
|
@ -175,7 +175,13 @@ documentations lives at `http://127.0.0.1:1984/docs`.
|
|||
"download_media_type": "AUDIO_VIDEO",
|
||||
"save_to_storage": false,
|
||||
"custom_filename": "cool.mp4",
|
||||
"automatic_extension": false
|
||||
"automatic_extension": false,
|
||||
"custom_options": {
|
||||
"http_headers": {
|
||||
"User-Agent": "MyApp/1.0.0",
|
||||
"Authorization": "Bearer <token>"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Response
|
||||
|
|
|
@ -59,7 +59,7 @@ class CreateTaskIn(StrictRealBaseModel):
|
|||
save_to_storage: bool = ...
|
||||
custom_filename: str = ...
|
||||
automatic_extension: bool = ...
|
||||
|
||||
custom_options: dict | None = Field(None, strict=False)
|
||||
|
||||
class CreateTaskOut(StrictRealBaseModel):
|
||||
id: uuid.UUID
|
||||
|
|
|
@ -81,6 +81,7 @@ class TaskService:
|
|||
ack_message_id=None,
|
||||
custom_filename=task.custom_filename,
|
||||
automatic_extension=task.automatic_extension,
|
||||
custom_options=task.custom_options,
|
||||
)
|
||||
if not await publisher.send_for_download(payload):
|
||||
raise TaskServiceError('Failed to create task')
|
||||
|
|
|
@ -37,6 +37,7 @@ class UrlService:
|
|||
download_media_type=url.download_media_type,
|
||||
custom_filename=None,
|
||||
automatic_extension=False,
|
||||
custom_options=None,
|
||||
)
|
||||
is_sent = await self._rmq_publisher.send_for_download(payload)
|
||||
if not is_sent:
|
||||
|
|
|
@ -60,6 +60,13 @@ class MediaDownloader:
|
|||
media_type=media_type, curr_tmp_dir=curr_tmp_dir
|
||||
)
|
||||
|
||||
if media_payload.custom_options:
|
||||
for key, value in media_payload.custom_options.items():
|
||||
try:
|
||||
ytdl_opts_model.ytdl_opts[key].update(value)
|
||||
except KeyError:
|
||||
ytdl_opts_model.ytdl_opts[key] = value
|
||||
|
||||
with yt_dlp.YoutubeDL(ytdl_opts_model.ytdl_opts) as ytdl:
|
||||
self._log.info('Downloading "%s" to "%s"', url, curr_tmp_dir)
|
||||
self._log.info(
|
||||
|
|
|
@ -37,6 +37,7 @@ class InbMediaPayload(StrictRealBaseModel):
|
|||
download_media_type: DownMediaType
|
||||
custom_filename: str | None
|
||||
automatic_extension: bool
|
||||
custom_options: dict[str, dict] | None
|
||||
added_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue