mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-12-16 06:05:41 +07:00
Compare commits
3 Commits
3ef867451c
...
7eff676183
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eff676183 | ||
|
|
1ac7e6005c | ||
|
|
f3597cfafc |
@@ -6,15 +6,15 @@
|
||||
OnDemandPagedList,
|
||||
clean_html,
|
||||
determine_ext,
|
||||
float_or_none,
|
||||
format_field,
|
||||
int_or_none,
|
||||
join_nonempty,
|
||||
parse_codecs,
|
||||
parse_iso8601,
|
||||
url_or_none,
|
||||
urljoin,
|
||||
)
|
||||
from ..utils.traversal import traverse_obj
|
||||
from ..utils.traversal import require, traverse_obj
|
||||
|
||||
|
||||
class FloatplaneBaseIE(InfoExtractor):
|
||||
@@ -50,37 +50,31 @@ def _real_extract(self, url):
|
||||
media_id = media['id']
|
||||
media_typ = media.get('type') or 'video'
|
||||
|
||||
metadata = self._download_json(
|
||||
f'{self._BASE_URL}/api/v3/content/{media_typ}', media_id, query={'id': media_id},
|
||||
note=f'Downloading {media_typ} metadata', impersonate=self._IMPERSONATE_TARGET)
|
||||
|
||||
stream = self._download_json(
|
||||
f'{self._BASE_URL}/api/v2/cdn/delivery', media_id, query={
|
||||
'type': 'vod' if media_typ == 'video' else 'aod',
|
||||
'guid': metadata['guid'],
|
||||
}, note=f'Downloading {media_typ} stream data',
|
||||
f'{self._BASE_URL}/api/v3/delivery/info', media_id,
|
||||
query={'scenario': 'onDemand', 'entityId': media_id},
|
||||
note=f'Downloading {media_typ} stream data',
|
||||
impersonate=self._IMPERSONATE_TARGET)
|
||||
|
||||
path_template = traverse_obj(stream, ('resource', 'uri', {str}))
|
||||
metadata = self._download_json(
|
||||
f'{self._BASE_URL}/api/v3/content/{media_typ}', media_id,
|
||||
f'Downloading {media_typ} metadata', query={'id': media_id},
|
||||
fatal=False, impersonate=self._IMPERSONATE_TARGET)
|
||||
|
||||
def format_path(params):
|
||||
path = path_template
|
||||
for i, val in (params or {}).items():
|
||||
path = path.replace(f'{{qualityLevelParams.{i}}}', val)
|
||||
return path
|
||||
cdn_base_url = traverse_obj(stream, (
|
||||
'groups', 0, 'origins', ..., 'url', {url_or_none}, any, {require('cdn base url')}))
|
||||
|
||||
formats = []
|
||||
for quality in traverse_obj(stream, ('resource', 'data', 'qualityLevels', ...)):
|
||||
url = urljoin(stream['cdn'], format_path(traverse_obj(
|
||||
stream, ('resource', 'data', 'qualityLevelParams', quality['name'], {dict}))))
|
||||
format_id = traverse_obj(quality, ('name', {str}))
|
||||
for variant in traverse_obj(stream, ('groups', 0, 'variants', lambda _, v: v['url'])):
|
||||
format_url = urljoin(cdn_base_url, variant['url'])
|
||||
format_id = traverse_obj(variant, ('name', {str}))
|
||||
hls_aes = {}
|
||||
m3u8_data = None
|
||||
|
||||
# If we need impersonation for the API, then we need it for HLS keys too: extract in advance
|
||||
if self._IMPERSONATE_TARGET is not None:
|
||||
m3u8_data = self._download_webpage(
|
||||
url, media_id, fatal=False, impersonate=self._IMPERSONATE_TARGET, headers=self._HEADERS,
|
||||
format_url, media_id, fatal=False, impersonate=self._IMPERSONATE_TARGET, headers=self._HEADERS,
|
||||
note=join_nonempty('Downloading', format_id, 'm3u8 information', delim=' '),
|
||||
errnote=join_nonempty('Failed to download', format_id, 'm3u8 information', delim=' '))
|
||||
if not m3u8_data:
|
||||
@@ -98,14 +92,19 @@ def format_path(params):
|
||||
hls_aes['key'] = urlh.read().hex()
|
||||
|
||||
formats.append({
|
||||
**traverse_obj(quality, {
|
||||
**traverse_obj(variant, {
|
||||
'format_note': ('label', {str}),
|
||||
'width': ('width', {int}),
|
||||
'height': ('height', {int}),
|
||||
'width': ('meta', 'video', 'width', {int_or_none}),
|
||||
'height': ('meta', 'video', 'height', {int_or_none}),
|
||||
'vcodec': ('meta', 'video', 'codec', {str}),
|
||||
'acodec': ('meta', 'audio', 'codec', {str}),
|
||||
'vbr': ('meta', 'video', 'bitrate', 'average', {int_or_none(scale=1000)}),
|
||||
'abr': ('meta', 'audio', 'bitrate', 'average', {int_or_none(scale=1000)}),
|
||||
'audio_channels': ('meta', 'audio', 'channelCount', {int_or_none}),
|
||||
'fps': ('meta', 'video', 'fps', {float_or_none}),
|
||||
}),
|
||||
**parse_codecs(quality.get('codecs')),
|
||||
'url': url,
|
||||
'ext': determine_ext(url.partition('/chunk.m3u8')[0], 'mp4'),
|
||||
'url': format_url,
|
||||
'ext': determine_ext(format_url.partition('/chunk.m3u8')[0], 'mp4'),
|
||||
'format_id': format_id,
|
||||
'hls_media_playlist_data': m3u8_data,
|
||||
'hls_aes': hls_aes or None,
|
||||
|
||||
@@ -136,8 +136,10 @@ class TubeTuGrazIE(TubeTuGrazBaseIE):
|
||||
IE_DESC = 'tube.tugraz.at'
|
||||
|
||||
_VALID_URL = r'''(?x)
|
||||
https?://tube\.tugraz\.at/paella/ui/watch.html\?id=
|
||||
(?P<id>[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})
|
||||
https?://tube\.tugraz\.at/(?:
|
||||
paella/ui/watch\.html\?(?:[^#]*&)?id=|
|
||||
portal/watch/
|
||||
)(?P<id>[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12})
|
||||
'''
|
||||
_TESTS = [
|
||||
{
|
||||
@@ -152,6 +154,7 @@ class TubeTuGrazIE(TubeTuGrazBaseIE):
|
||||
'creator': 'Safran C',
|
||||
'duration': 3295818,
|
||||
'series_id': 'b1192fff-2aa7-4bf0-a5cf-7b15c3bd3b34',
|
||||
'creators': ['Safran C'],
|
||||
},
|
||||
}, {
|
||||
'url': 'https://tube.tugraz.at/paella/ui/watch.html?id=2df6d787-e56a-428d-8ef4-d57f07eef238',
|
||||
@@ -162,6 +165,10 @@ class TubeTuGrazIE(TubeTuGrazBaseIE):
|
||||
'ext': 'mp4',
|
||||
},
|
||||
'expected_warnings': ['Extractor failed to obtain "title"'],
|
||||
}, {
|
||||
# Portal URL format
|
||||
'url': 'https://tube.tugraz.at/portal/watch/ab28ec60-8cbe-4f1a-9b96-a95add56c612',
|
||||
'only_matching': True,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class TwitchBaseIE(InfoExtractor):
|
||||
'ClipsCards__User': 'b73ad2bfaecfd30a9e6c28fada15bd97032c83ec77a0440766a56fe0bd632777',
|
||||
'ShareClipRenderStatus': 'e0a46b287d760c6890a39d1ccd736af5ec9479a267d02c710e9ac33326b651d2',
|
||||
'ChannelCollectionsContent': '447aec6a0cc1e8d0a8d7732d47eb0762c336a2294fdb009e9c9d854e49d484b9',
|
||||
'StreamMetadata': 'a647c2a13599e5991e175155f798ca7f1ecddde73f7f341f39009c14dbf59962',
|
||||
'StreamMetadata': 'b57f9b910f8cd1a4659d894fe7550ccc81ec9052c01e438b290fd66a040b9b93',
|
||||
'ComscoreStreamingQuery': 'e1edae8122517d013405f237ffcc124515dc6ded82480a88daef69c83b53ac01',
|
||||
'VideoPreviewOverlay': '3006e77e51b128d838fa4e835723ca4dc9a05c5efd4466c1085215c6e437e65c',
|
||||
'VideoMetadata': '49b5b8f268cdeb259d75b58dcb0c1a748e3b575003448a2333dc5cdafd49adad',
|
||||
@@ -1050,7 +1050,10 @@ def _real_extract(self, url):
|
||||
gql = self._download_gql(
|
||||
channel_name, [{
|
||||
'operationName': 'StreamMetadata',
|
||||
'variables': {'channelLogin': channel_name},
|
||||
'variables': {
|
||||
'channelLogin': channel_name,
|
||||
'includeIsDJ': True,
|
||||
},
|
||||
}, {
|
||||
'operationName': 'ComscoreStreamingQuery',
|
||||
'variables': {
|
||||
|
||||
Reference in New Issue
Block a user