@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
from .common import DownloaderBase
|
from .common import DownloaderBase
|
||||||
from .. import ytdl, text
|
from .. import ytdl, text
|
||||||
|
from xml.etree import ElementTree
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
@@ -76,7 +77,8 @@ class YoutubeDLDownloader(DownloaderBase):
|
|||||||
manifest = kwdict.pop("_ytdl_manifest", None)
|
manifest = kwdict.pop("_ytdl_manifest", None)
|
||||||
if manifest:
|
if manifest:
|
||||||
info_dict = self._extract_manifest(
|
info_dict = self._extract_manifest(
|
||||||
ytdl_instance, url, manifest)
|
ytdl_instance, url, manifest,
|
||||||
|
kwdict.pop("_ytdl_manifest_data", None))
|
||||||
else:
|
else:
|
||||||
info_dict = self._extract_info(ytdl_instance, url)
|
info_dict = self._extract_info(ytdl_instance, url)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
@@ -154,37 +156,55 @@ class YoutubeDLDownloader(DownloaderBase):
|
|||||||
def _extract_info(self, ytdl, url):
|
def _extract_info(self, ytdl, url):
|
||||||
return ytdl.extract_info(url, download=False)
|
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")
|
extr = ytdl.get_info_extractor("Generic")
|
||||||
video_id = extr._generic_id(url)
|
video_id = extr._generic_id(url)
|
||||||
|
|
||||||
if manifest == "hls":
|
if manifest_type == "hls":
|
||||||
try:
|
if manifest_data is None:
|
||||||
formats, subtitles = extr._extract_m3u8_formats_and_subtitles(
|
try:
|
||||||
url, video_id, "mp4")
|
fmts, subs = extr._extract_m3u8_formats_and_subtitles(
|
||||||
except AttributeError:
|
url, video_id, "mp4")
|
||||||
formats = extr._extract_m3u8_formats(url, video_id, "mp4")
|
except AttributeError:
|
||||||
subtitles = None
|
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 == "dash":
|
elif manifest_type == "dash":
|
||||||
try:
|
if manifest_data is None:
|
||||||
formats, subtitles = extr._extract_mpd_formats_and_subtitles(
|
try:
|
||||||
url, video_id)
|
fmts, subs = extr._extract_mpd_formats_and_subtitles(
|
||||||
except AttributeError:
|
url, video_id)
|
||||||
formats = extr._extract_mpd_formats(url, video_id)
|
except AttributeError:
|
||||||
subtitles = None
|
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:
|
else:
|
||||||
self.log.error("Unsupported manifest type '%s'", manifest)
|
self.log.error("Unsupported manifest type '%s'", manifest_type)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
info_dict = {
|
info_dict = {
|
||||||
"id" : video_id,
|
"id" : video_id,
|
||||||
"title" : video_id,
|
"title" : video_id,
|
||||||
"formats" : formats,
|
"formats" : fmts,
|
||||||
"subtitles": subtitles,
|
"subtitles": subs,
|
||||||
}
|
}
|
||||||
# extr._extra_manifest_info(info_dict, url)
|
|
||||||
return ytdl.process_ie_result(info_dict, download=False)
|
return ytdl.process_ie_result(info_dict, download=False)
|
||||||
|
|
||||||
def _progress_hook(self, info):
|
def _progress_hook(self, info):
|
||||||
|
|||||||
Reference in New Issue
Block a user