Support more deeply nested ptmd_path with test, update tests

pull/30613/head
dirkf 2022-01-14 20:14:14 +00:00
parent 01824d275b
commit 5197336de6
1 changed files with 24 additions and 4 deletions

View File

@ -7,6 +7,7 @@ from .common import InfoExtractor
from ..compat import compat_str from ..compat import compat_str
from ..utils import ( from ..utils import (
determine_ext, determine_ext,
ExtractorError,
float_or_none, float_or_none,
int_or_none, int_or_none,
merge_dicts, merge_dicts,
@ -145,6 +146,7 @@ class ZDFIE(ZDFBaseIE):
'timestamp': 1613948400, 'timestamp': 1613948400,
'upload_date': '20210221', 'upload_date': '20210221',
}, },
'skip': 'No longer available: "Diese Seite wurde leider nicht gefunden"',
}, { }, {
# Same as https://www.3sat.de/film/ab-18/10-wochen-sommer-108.html # Same as https://www.3sat.de/film/ab-18/10-wochen-sommer-108.html
'url': 'https://www.zdf.de/dokumentation/ab-18/10-wochen-sommer-102.html', 'url': 'https://www.zdf.de/dokumentation/ab-18/10-wochen-sommer-102.html',
@ -158,6 +160,7 @@ class ZDFIE(ZDFBaseIE):
'timestamp': 1608604200, 'timestamp': 1608604200,
'upload_date': '20201222', 'upload_date': '20201222',
}, },
'skip': 'No longer available: "Diese Seite wurde leider nicht gefunden"',
}, { }, {
'url': 'https://www.zdf.de/dokumentation/terra-x/die-magie-der-farben-von-koenigspurpur-und-jeansblau-100.html', 'url': 'https://www.zdf.de/dokumentation/terra-x/die-magie-der-farben-von-koenigspurpur-und-jeansblau-100.html',
'info_dict': { 'info_dict': {
@ -190,6 +193,17 @@ class ZDFIE(ZDFBaseIE):
}, { }, {
'url': 'https://www.zdf.de/dokumentation/planet-e/planet-e-uebersichtsseite-weitere-dokumentationen-von-planet-e-100.html', 'url': 'https://www.zdf.de/dokumentation/planet-e/planet-e-uebersichtsseite-weitere-dokumentationen-von-planet-e-100.html',
'only_matching': True, 'only_matching': True,
}, {
'url': 'https://www.zdf.de/arte/todliche-flucht/page-video-artede-toedliche-flucht-16-100.html',
'info_dict': {
'id': 'video_artede_083871-001-A',
'ext': 'mp4',
'title': 'Tödliche Flucht (1/6)',
'description': 'md5:e34f96a9a5f8abd839ccfcebad3d5315',
'duration': 3193.0,
'timestamp': 1641355200,
'upload_date': '20220105',
},
}] }]
def _extract_entry(self, url, player, content, video_id): def _extract_entry(self, url, player, content, video_id):
@ -197,12 +211,18 @@ class ZDFIE(ZDFBaseIE):
t = content['mainVideoContent']['http://zdf.de/rels/target'] t = content['mainVideoContent']['http://zdf.de/rels/target']
ptmd_path = t.get('http://zdf.de/rels/streams/ptmd') def get_ptmd_path(d):
return (
d.get('http://zdf.de/rels/streams/ptmd')
or d.get('http://zdf.de/rels/streams/ptmd-template',
'').replace('{playerId}', 'ngplayer_2_4'))
ptmd_path = get_ptmd_path(try_get(t, lambda x: x['streams']['default'], dict) or {})
if not ptmd_path:
ptmd_path = get_ptmd_path(t)
if not ptmd_path: if not ptmd_path:
ptmd_path = t[ raise ExtractorError('Could not extract ptmd_path')
'http://zdf.de/rels/streams/ptmd-template'].replace(
'{playerId}', 'ngplayer_2_4')
info = self._extract_ptmd( info = self._extract_ptmd(
urljoin(url, ptmd_path), video_id, player['apiToken'], url) urljoin(url, ptmd_path), video_id, player['apiToken'], url)