[ie/ZDF] Address review findings

This commit is contained in:
InvalidUsernameException
2025-03-31 22:31:21 +02:00
parent 2ad9fd8d8f
commit 01e3b208f2
4 changed files with 49 additions and 62 deletions
+8 -11
View File
@@ -34,6 +34,12 @@ class ZDFBaseIE(InfoExtractor):
url, video_id, note=f'Downloading {item}',
errnote=f'Failed to download {item}', headers=headers)
def _extract_chapters(self, data):
return traverse_obj(data, (lambda _, v: 'anchorOffset' in v, {
'start_time': ('anchorOffset', {float_or_none}),
'title': ('anchorLabel', {str}),
}), default=None)
@staticmethod
def _extract_subtitles(src):
seen_urls = set()
@@ -506,21 +512,12 @@ query VideoByCanonical($canonical: String!) {
'season_number': ('episodeInfo', 'seasonNumber', {int_or_none}),
'series': ('smartCollection', 'title', {str}),
'series_id': ('smartCollection', 'canonical', {str}),
'chapters': ('currentMedia', 'nodes', 0, {self._extract_chapters}),
'chapters': ('currentMedia', 'nodes', 0, 'streamAnchorTags', 'nodes', {self._extract_chapters}),
})),
}
def _extract_chapters(self, data):
chapter_marks = traverse_obj(data, ('streamAnchorTags', 'nodes'))
chapter_marks.append({'anchorOffset': float_or_none(data.get('duration'))})
return [{
'start_time': chap.get('anchorOffset'),
'end_time': next_chap.get('anchorOffset'),
'title': chap.get('anchorLabel'),
} for chap, next_chap in zip(chapter_marks, chapter_marks[1:])] or None
class ZDFCollectionIE(ZDFBaseIE):
class ZDFChannelIE(ZDFBaseIE):
_VALID_URL = r'https?://www\.zdf\.de/(?:[^/?#]+/)*(?P<id>[^/?#]+)'
_TESTS = [{
# Playlist, legacy URL before website redesign in 2025-03