mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 00:16:48 +00:00
use mimetype2ext to determine manifest ext in multiple extractors
This commit is contained in:
parent
b4173f1551
commit
ab49d7a9fa
@ -5,6 +5,8 @@ from .common import InfoExtractor
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
|
mimetype2ext,
|
||||||
|
determine_ext,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -50,21 +52,25 @@ class AMPIE(InfoExtractor):
|
|||||||
if isinstance(media_content, dict):
|
if isinstance(media_content, dict):
|
||||||
media_content = [media_content]
|
media_content = [media_content]
|
||||||
for media_data in media_content:
|
for media_data in media_content:
|
||||||
media = media_data['@attributes']
|
media = media_data.get('@attributes', {})
|
||||||
media_type = media['type']
|
media_url = media.get('url')
|
||||||
if media_type in ('video/f4m', 'application/f4m+xml'):
|
if not media_url:
|
||||||
|
continue
|
||||||
|
ext = mimetype2ext(media.get('type')) or determne_ext(media_url)
|
||||||
|
if ext == 'f4m':
|
||||||
formats.extend(self._extract_f4m_formats(
|
formats.extend(self._extract_f4m_formats(
|
||||||
media['url'] + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124',
|
media_url + '?hdcore=3.4.0&plugin=aasp-3.4.0.132.124',
|
||||||
video_id, f4m_id='hds', fatal=False))
|
video_id, f4m_id='hds', fatal=False))
|
||||||
elif media_type == 'application/x-mpegURL':
|
elif ext == 'm3u8':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
media['url'], video_id, 'mp4', m3u8_id='hls', fatal=False))
|
media_url, video_id, 'mp4', m3u8_id='hls', fatal=False))
|
||||||
else:
|
else:
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': media_data.get('media-category', {}).get('@attributes', {}).get('label'),
|
'format_id': media_data.get('media-category', {}).get('@attributes', {}).get('label'),
|
||||||
'url': media['url'],
|
'url': media['url'],
|
||||||
'tbr': int_or_none(media.get('bitrate')),
|
'tbr': int_or_none(media.get('bitrate')),
|
||||||
'filesize': int_or_none(media.get('fileSize')),
|
'filesize': int_or_none(media.get('fileSize')),
|
||||||
|
'ext': ext,
|
||||||
})
|
})
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
@ -16,6 +16,7 @@ from ..utils import (
|
|||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
|
mimetype2ext,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -153,18 +154,19 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
|
|||||||
type_ = media.get('type')
|
type_ = media.get('type')
|
||||||
if type_ == 'application/vnd.lumberjack.manifest':
|
if type_ == 'application/vnd.lumberjack.manifest':
|
||||||
continue
|
continue
|
||||||
ext = determine_ext(media_url)
|
ext = mimetype2ext(type_) or determine_ext(media_url)
|
||||||
if type_ == 'application/x-mpegURL' or ext == 'm3u8':
|
if ext == 'm3u8':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
media_url, video_id, 'mp4', preference=-1,
|
media_url, video_id, 'mp4', preference=-1,
|
||||||
m3u8_id='hls', fatal=False))
|
m3u8_id='hls', fatal=False))
|
||||||
elif type_ == 'application/f4m' or ext == 'f4m':
|
elif ext == 'f4m':
|
||||||
formats.extend(self._extract_f4m_formats(
|
formats.extend(self._extract_f4m_formats(
|
||||||
media_url, video_id, preference=-1, f4m_id='hds', fatal=False))
|
media_url, video_id, preference=-1, f4m_id='hds', fatal=False))
|
||||||
else:
|
else:
|
||||||
f = {
|
f = {
|
||||||
'url': media_url,
|
'url': media_url,
|
||||||
'format_id': 'http-%s' % quality,
|
'format_id': 'http-%s' % quality,
|
||||||
|
'ext': ext,
|
||||||
}
|
}
|
||||||
m = re.search(r'H264-(?P<width>\d+)x(?P<height>\d+)', media_url)
|
m = re.search(r'H264-(?P<width>\d+)x(?P<height>\d+)', media_url)
|
||||||
if m:
|
if m:
|
||||||
|
@ -234,9 +234,8 @@ class MetacafeIE(InfoExtractor):
|
|||||||
source_url = source.get('src')
|
source_url = source.get('src')
|
||||||
if not source_url:
|
if not source_url:
|
||||||
continue
|
continue
|
||||||
mime_type = source.get('type')
|
ext = mimetype2ext(source.get('type')) or determine_ext(source_url)
|
||||||
ext = mimetype2ext(mime_type) or determine_ext(source_url)
|
if ext == 'm3u8':
|
||||||
if mime_type == 'application/x-mpegURL' or ext == 'm3u8':
|
|
||||||
video_url.extend(self._extract_m3u8_formats(
|
video_url.extend(self._extract_m3u8_formats(
|
||||||
source_url, video_id, 'mp4',
|
source_url, video_id, 'mp4',
|
||||||
'm3u8_native', m3u8_id='hls', fatal=False))
|
'm3u8_native', m3u8_id='hls', fatal=False))
|
||||||
|
@ -8,6 +8,7 @@ from ..utils import (
|
|||||||
determine_ext,
|
determine_ext,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
|
mimetype2ext,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -50,9 +51,8 @@ class OnionStudiosIE(InfoExtractor):
|
|||||||
source_url = source.get('url')
|
source_url = source.get('url')
|
||||||
if not source_url:
|
if not source_url:
|
||||||
continue
|
continue
|
||||||
content_type = source.get('content_type')
|
ext = mimetype2ext(source.get('content_type')) or determine_ext(source_url)
|
||||||
ext = determine_ext(source_url)
|
if ext == 'm3u8':
|
||||||
if content_type == 'application/x-mpegURL' or ext == 'm3u8':
|
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
source_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
|
source_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
|
||||||
else:
|
else:
|
||||||
|
@ -5,6 +5,8 @@ from .common import InfoExtractor
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
qualities,
|
qualities,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
mimetype2ext,
|
||||||
|
determine_ext,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -34,19 +36,21 @@ class SixPlayIE(InfoExtractor):
|
|||||||
source_type, source_url = source.get('type'), source.get('src')
|
source_type, source_url = source.get('type'), source.get('src')
|
||||||
if not source_url or source_type == 'hls/primetime':
|
if not source_url or source_type == 'hls/primetime':
|
||||||
continue
|
continue
|
||||||
if source_type == 'application/vnd.apple.mpegURL':
|
ext = mimetype2ext(source_type) or determine_ext(source_url)
|
||||||
|
if ext == 'm3u8':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
source_url, video_id, 'mp4', 'm3u8_native',
|
source_url, video_id, 'mp4', 'm3u8_native',
|
||||||
m3u8_id='hls', fatal=False))
|
m3u8_id='hls', fatal=False))
|
||||||
formats.extend(self._extract_f4m_formats(
|
formats.extend(self._extract_f4m_formats(
|
||||||
source_url.replace('.m3u8', '.f4m'),
|
source_url.replace('.m3u8', '.f4m'),
|
||||||
video_id, f4m_id='hds', fatal=False))
|
video_id, f4m_id='hds', fatal=False))
|
||||||
elif source_type == 'video/mp4':
|
elif ext == 'mp4':
|
||||||
quality = source.get('quality')
|
quality = source.get('quality')
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': source_url,
|
'url': source_url,
|
||||||
'format_id': quality,
|
'format_id': quality,
|
||||||
'quality': quality_key(quality),
|
'quality': quality_key(quality),
|
||||||
|
'ext': ext,
|
||||||
})
|
})
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
@ -92,12 +92,11 @@ class ThreeQSDNIE(InfoExtractor):
|
|||||||
if not item_url or item_url in urls:
|
if not item_url or item_url in urls:
|
||||||
return
|
return
|
||||||
urls.add(item_url)
|
urls.add(item_url)
|
||||||
type_ = item.get('type')
|
ext = mimetype2ext(item.get('type')) or determine_ext(item_url, default_ext=None)
|
||||||
ext = determine_ext(item_url, default_ext=None)
|
if ext == 'mpd':
|
||||||
if type_ == 'application/dash+xml' or ext == 'mpd':
|
|
||||||
formats.extend(self._extract_mpd_formats(
|
formats.extend(self._extract_mpd_formats(
|
||||||
item_url, video_id, mpd_id='mpd', fatal=False))
|
item_url, video_id, mpd_id='mpd', fatal=False))
|
||||||
elif type_ in ('application/vnd.apple.mpegURL', 'application/x-mpegurl') or ext == 'm3u8':
|
elif ext == 'm3u8':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
item_url, video_id, 'mp4',
|
item_url, video_id, 'mp4',
|
||||||
entry_protocol='m3u8' if live else 'm3u8_native',
|
entry_protocol='m3u8' if live else 'm3u8_native',
|
||||||
@ -111,7 +110,7 @@ class ThreeQSDNIE(InfoExtractor):
|
|||||||
formats.append({
|
formats.append({
|
||||||
'url': item_url,
|
'url': item_url,
|
||||||
'format_id': item.get('quality'),
|
'format_id': item.get('quality'),
|
||||||
'ext': 'mp4' if item_url.startswith('rtsp') else mimetype2ext(type_) or ext,
|
'ext': 'mp4' if item_url.startswith('rtsp') else ext,
|
||||||
'vcodec': 'none' if stream_type == 'audio' else None,
|
'vcodec': 'none' if stream_type == 'audio' else None,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user