[webtoons] extend 'bgm' option (#8733)

allow remuxing bgm audio into a different format/container
This commit is contained in:
Mike Fährmann
2026-01-06 21:39:38 +01:00
parent 3c0509e80c
commit 6cc7153b6c
2 changed files with 17 additions and 3 deletions

View File

@@ -6833,13 +6833,20 @@ Note
extractor.webtoons.bgm extractor.webtoons.bgm
---------------------- ----------------------
Type Type
``bool`` * ``bool``
* ``string``
Default Default
``true`` ``true``
Example
``"aac"``
Description Description
Download an episode's `background music` if available. Download an episode's `background music` if available.
If this is a ``string``, remux the downloaded `background music` file
into the given format.
Note Note
Requires |ytdl| Requires |ytdl| for downloads
and |ffmpeg| for remuxing
extractor.webtoons.quality extractor.webtoons.quality

View File

@@ -172,6 +172,12 @@ class WebtoonsEpisodeExtractor(WebtoonsBase, GalleryExtractor):
} }
paths = self.paths paths = self.paths
if isinstance(self.bgm, str):
remux = ext = self.bgm.lower()
else:
ext = "mp4"
remux = False
for bgm in bgm_list: for bgm in bgm_list:
url = (f"https://apis.naver.com/audiocweb/audiocplayogwweb/play" url = (f"https://apis.naver.com/audiocweb/audiocplayogwweb/play"
f"/audio/{bgm['audioId']}/hls/token") f"/audio/{bgm['audioId']}/hls/token")
@@ -190,10 +196,11 @@ class WebtoonsEpisodeExtractor(WebtoonsBase, GalleryExtractor):
"num_stop": paths.get(stop) or 0, "num_stop": paths.get(stop) or 0,
"filename_play": play[play.rfind("/")+1:play.rfind(".")], "filename_play": play[play.rfind("/")+1:play.rfind(".")],
"filename_stop": stop[stop.rfind("/")+1:stop.rfind(".")], "filename_stop": stop[stop.rfind("/")+1:stop.rfind(".")],
"extension": ext,
"type": "bgm", "type": "bgm",
"url" : "ytdl:" + audio["url"], "url" : "ytdl:" + audio["url"],
"_ytdl_manifest": audio["type"].lower(), "_ytdl_manifest": audio["type"].lower(),
"extension": "mp3", "_ytdl_manifest_remux": remux,
}) })