aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/downloader/ytdl.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-03-29 07:20:04 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2025-03-29 07:20:04 -0400
commit5ea6cce4fb40d2cc4f1d7849e44e6825ac2f3a73 (patch)
tree2d7040d732323306b2227682068ed5c9e12d4bf0 /gallery_dl/downloader/ytdl.py
parent68863e88e0e0d8c08a8631831c05c302527627b1 (diff)
parent662e5ac868a5c1a3e7bc95b37054b3a0ca4db74f (diff)
Update upstream source from tag 'upstream/1.29.3'
Update to upstream version '1.29.3' with Debian dir 131b9b3bdbc67af5fe84f139a5b499a550f7c22b
Diffstat (limited to 'gallery_dl/downloader/ytdl.py')
-rw-r--r--gallery_dl/downloader/ytdl.py62
1 files changed, 41 insertions, 21 deletions
diff --git a/gallery_dl/downloader/ytdl.py b/gallery_dl/downloader/ytdl.py
index 1242098..9d653b3 100644
--- a/gallery_dl/downloader/ytdl.py
+++ b/gallery_dl/downloader/ytdl.py
@@ -10,6 +10,7 @@
from .common import DownloaderBase
from .. import ytdl, text
+from xml.etree import ElementTree
import os
@@ -76,7 +77,8 @@ class YoutubeDLDownloader(DownloaderBase):
manifest = kwdict.pop("_ytdl_manifest", None)
if manifest:
info_dict = self._extract_manifest(
- ytdl_instance, url, manifest)
+ ytdl_instance, url, manifest,
+ kwdict.pop("_ytdl_manifest_data", None))
else:
info_dict = self._extract_info(ytdl_instance, url)
except Exception as exc:
@@ -154,37 +156,55 @@ class YoutubeDLDownloader(DownloaderBase):
def _extract_info(self, ytdl, url):
return ytdl.extract_info(url, download=False)
- def _extract_manifest(self, ytdl, url, manifest):
+ def _extract_manifest(self, ytdl, url, manifest_type, manifest_data=None):
extr = ytdl.get_info_extractor("Generic")
video_id = extr._generic_id(url)
- if manifest == "hls":
- try:
- formats, subtitles = extr._extract_m3u8_formats_and_subtitles(
- url, video_id, "mp4")
- except AttributeError:
- formats = extr._extract_m3u8_formats(url, video_id, "mp4")
- subtitles = None
-
- elif manifest == "dash":
- try:
- formats, subtitles = extr._extract_mpd_formats_and_subtitles(
- url, video_id)
- except AttributeError:
- formats = extr._extract_mpd_formats(url, video_id)
- subtitles = None
+ if manifest_type == "hls":
+ if manifest_data is None:
+ try:
+ fmts, subs = extr._extract_m3u8_formats_and_subtitles(
+ url, video_id, "mp4")
+ except AttributeError:
+ fmts = extr._extract_m3u8_formats(url, video_id, "mp4")
+ subs = None
+ else:
+ try:
+ fmts, subs = extr._parse_m3u8_formats_and_subtitles(
+ url, video_id, "mp4")
+ except AttributeError:
+ fmts = extr._parse_m3u8_formats(url, video_id, "mp4")
+ subs = None
+
+ elif manifest_type == "dash":
+ if manifest_data is None:
+ try:
+ fmts, subs = extr._extract_mpd_formats_and_subtitles(
+ url, video_id)
+ except AttributeError:
+ fmts = extr._extract_mpd_formats(url, video_id)
+ subs = None
+ else:
+ if isinstance(manifest_data, str):
+ manifest_data = ElementTree.fromstring(manifest_data)
+ try:
+ fmts, subs = extr._parse_mpd_formats_and_subtitles(
+ manifest_data, mpd_id="dash")
+ except AttributeError:
+ fmts = extr._parse_mpd_formats(
+ manifest_data, mpd_id="dash")
+ subs = None
else:
- self.log.error("Unsupported manifest type '%s'", manifest)
+ self.log.error("Unsupported manifest type '%s'", manifest_type)
return None
info_dict = {
"id" : video_id,
"title" : video_id,
- "formats" : formats,
- "subtitles": subtitles,
+ "formats" : fmts,
+ "subtitles": subs,
}
- # extr._extra_manifest_info(info_dict, url)
return ytdl.process_ie_result(info_dict, download=False)
def _progress_hook(self, info):