mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-04-23 09:06:06 +00:00
Split expanding PTMD template from extracting PTMD data
This commit is contained in:
parent
3bb3aa4672
commit
692a396be8
@ -97,7 +97,8 @@ class DreiSatIE(ZDFBaseIE):
|
|||||||
(('streams', 'default'), None),
|
(('streams', 'default'), None),
|
||||||
('http://zdf.de/rels/streams/ptmd', 'http://zdf.de/rels/streams/ptmd-template'),
|
('http://zdf.de/rels/streams/ptmd', 'http://zdf.de/rels/streams/ptmd-template'),
|
||||||
{str}, any, {require('ptmd path')}))
|
{str}, any, {require('ptmd path')}))
|
||||||
info = self._extract_ptmd(player_url, ptmd_path, video_id, api_token)
|
ptmd_url = self._expand_ptmd_template(player_url, ptmd_path)
|
||||||
|
info = self._extract_ptmd(ptmd_url, video_id, api_token)
|
||||||
|
|
||||||
return merge_dicts(info, {
|
return merge_dicts(info, {
|
||||||
**traverse_obj(content, {
|
**traverse_obj(content, {
|
||||||
|
|||||||
@ -71,8 +71,7 @@ class PhoenixIE(ZDFBaseIE):
|
|||||||
content_id = details['tracking']['nielsen']['content']['assetid']
|
content_id = details['tracking']['nielsen']['content']['assetid']
|
||||||
|
|
||||||
info = self._extract_ptmd(
|
info = self._extract_ptmd(
|
||||||
'https://tmd.phoenix.de',
|
f'https://tmd.phoenix.de/tmd/2/android_native_6/vod/ptmd/phoenix/{content_id}',
|
||||||
f'tmd/2/{{playerId}}/vod/ptmd/phoenix/{content_id}',
|
|
||||||
content_id)
|
content_id)
|
||||||
|
|
||||||
duration = int_or_none(try_get(
|
duration = int_or_none(try_get(
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import functools
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
@ -87,7 +88,10 @@ class ZDFBaseIE(InfoExtractor):
|
|||||||
'quality': qualities(self._QUALITIES)(meta.get('quality')),
|
'quality': qualities(self._QUALITIES)(meta.get('quality')),
|
||||||
}) for f in fmts)
|
}) for f in fmts)
|
||||||
|
|
||||||
def _extract_ptmd(self, api_base_url, templates, video_id, api_token=None):
|
def _expand_ptmd_template(self, api_base_url, template):
|
||||||
|
return urljoin(api_base_url, template.replace('{playerId}', 'android_native_6'))
|
||||||
|
|
||||||
|
def _extract_ptmd(self, ptmd_urls, video_id, api_token=None):
|
||||||
# TODO: If there are multiple PTMD templates,
|
# TODO: If there are multiple PTMD templates,
|
||||||
# usually one of them is a sign-language variant of the video.
|
# usually one of them is a sign-language variant of the video.
|
||||||
# The format order works out fine as is and prefers the "regular" video,
|
# The format order works out fine as is and prefers the "regular" video,
|
||||||
@ -96,16 +100,14 @@ class ZDFBaseIE(InfoExtractor):
|
|||||||
# TODO: HTTPS formats are extracted without resolution information
|
# TODO: HTTPS formats are extracted without resolution information
|
||||||
# However, we know vertical resolution and the caller often knows apsect ratio.
|
# However, we know vertical resolution and the caller often knows apsect ratio.
|
||||||
# So we could calculate the correct resulution from those two data points.
|
# So we could calculate the correct resulution from those two data points.
|
||||||
templates = variadic(templates)
|
ptmd_urls = variadic(ptmd_urls)
|
||||||
src_captions = []
|
src_captions = []
|
||||||
|
|
||||||
content_id = None
|
content_id = None
|
||||||
duration = None
|
duration = None
|
||||||
formats = []
|
formats = []
|
||||||
track_uris = set()
|
track_uris = set()
|
||||||
for template in templates:
|
for ptmd_url in ptmd_urls:
|
||||||
ptmd_url = urljoin(api_base_url, template.replace(
|
|
||||||
'{playerId}', 'android_native_6'))
|
|
||||||
ptmd = self._call_api(ptmd_url, video_id, 'PTMD data', api_token)
|
ptmd = self._call_api(ptmd_url, video_id, 'PTMD data', api_token)
|
||||||
# As per above TODO on sign language videos variants,
|
# As per above TODO on sign language videos variants,
|
||||||
# prefer content_id from the last entry to get the "regular" ID.
|
# prefer content_id from the last entry to get the "regular" ID.
|
||||||
@ -537,11 +539,10 @@ query VideoByCanonical($canonical: String!) {
|
|||||||
if not video_data:
|
if not video_data:
|
||||||
return self._extract_fallback(video_id)
|
return self._extract_fallback(video_id)
|
||||||
|
|
||||||
ptmd_templates = traverse_obj(
|
ptmd_urls = traverse_obj(video_data, (
|
||||||
video_data, ('currentMedia', 'nodes', ..., 'ptmdTemplate'))
|
'currentMedia', 'nodes', ..., 'ptmdTemplate',
|
||||||
ptmd_data = self._extract_ptmd(
|
{functools.partial(self._expand_ptmd_template, 'https://api.zdf.de')}))
|
||||||
'https://api.zdf.de', ptmd_templates, video_id,
|
ptmd_data = self._extract_ptmd(ptmd_urls, video_id, self._get_api_token(video_id))
|
||||||
self._get_api_token(video_id))
|
|
||||||
# We can't use the ID from PTMD extraction as the video ID
|
# We can't use the ID from PTMD extraction as the video ID
|
||||||
# because it is not available during playlist extraction.
|
# because it is not available during playlist extraction.
|
||||||
# We fix it here manually instead of inside the method
|
# We fix it here manually instead of inside the method
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user