]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/phoenix.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / phoenix.py
CommitLineData
ec5e77c5 1import re
8cc3eba7 2
ec5e77c5 3from .youtube import YoutubeIE
4from .zdf import ZDFBaseIE
ec5e77c5 5from ..utils import (
6 int_or_none,
7 merge_dicts,
b73612a2 8 try_get,
ec5e77c5 9 unified_timestamp,
b73612a2 10 urljoin,
ec5e77c5 11)
c15c8e25 12
ec5e77c5 13
14class PhoenixIE(ZDFBaseIE):
6c4d6609 15 IE_NAME = 'phoenix.de'
ec5e77c5 16 _VALID_URL = r'https?://(?:www\.)?phoenix\.de/(?:[^/]+/)*[^/?#&]*-a-(?P<id>\d+)\.html'
17 _TESTS = [{
18 # Same as https://www.zdf.de/politik/phoenix-sendungen/wohin-fuehrt-der-protest-in-der-pandemie-100.html
19 'url': 'https://www.phoenix.de/sendungen/ereignisse/corona-nachgehakt/wohin-fuehrt-der-protest-in-der-pandemie-a-2050630.html',
20 'md5': '34ec321e7eb34231fd88616c65c92db0',
21 'info_dict': {
22 'id': '210222_phx_nachgehakt_corona_protest',
23 'ext': 'mp4',
24 'title': 'Wohin führt der Protest in der Pandemie?',
25 'description': 'md5:7d643fe7f565e53a24aac036b2122fbd',
26 'duration': 1691,
b73612a2 27 'timestamp': 1613902500,
ec5e77c5 28 'upload_date': '20210221',
29 'uploader': 'Phoenix',
b73612a2 30 'series': 'corona nachgehakt',
31 'episode': 'Wohin führt der Protest in der Pandemie?',
edd73448 32 },
ec5e77c5 33 }, {
34 # Youtube embed
35 'url': 'https://www.phoenix.de/sendungen/gespraeche/phoenix-streitgut-brennglas-corona-a-1965505.html',
36 'info_dict': {
37 'id': 'hMQtqFYjomk',
38 'ext': 'mp4',
39 'title': 'phoenix streitgut: Brennglas Corona - Wie gerecht ist unsere Gesellschaft?',
40 'description': 'md5:ac7a02e2eb3cb17600bc372e4ab28fdd',
41 'duration': 3509,
42 'upload_date': '20201219',
43 'uploader': 'phoenix',
44 'uploader_id': 'phoenix',
edd73448 45 },
ec5e77c5 46 'params': {
47 'skip_download': True,
48 },
49 }, {
50 'url': 'https://www.phoenix.de/entwicklungen-in-russland-a-2044720.html',
51 'only_matching': True,
52 }, {
53 # no media
54 'url': 'https://www.phoenix.de/sendungen/dokumentationen/mit-dem-jumbo-durch-die-nacht-a-89625.html',
55 'only_matching': True,
56 }, {
57 # Same as https://www.zdf.de/politik/phoenix-sendungen/die-gesten-der-maechtigen-100.html
58 'url': 'https://www.phoenix.de/sendungen/dokumentationen/gesten-der-maechtigen-i-a-89468.html?ref=suche',
59 'only_matching': True,
60 }]
c15c8e25 61
8cc3eba7 62 def _real_extract(self, url):
ec5e77c5 63 article_id = self._match_id(url)
64
65 article = self._download_json(
add96eb9 66 f'https://www.phoenix.de/response/id/{article_id}', article_id,
ec5e77c5 67 'Downloading article JSON')
68
69 video = article['absaetze'][0]
70 title = video.get('titel') or article.get('subtitel')
71
72 if video.get('typ') == 'video-youtube':
73 video_id = video['id']
74 return self.url_result(
75 video_id, ie=YoutubeIE.ie_key(), video_id=video_id,
76 video_title=title)
77
add96eb9 78 video_id = str(video.get('basename') or video.get('content'))
ec5e77c5 79
b73612a2 80 details = self._download_json(
ec5e77c5 81 'https://www.phoenix.de/php/mediaplayer/data/beitrags_details.php',
b73612a2 82 video_id, 'Downloading details JSON', query={
ec5e77c5 83 'ak': 'web',
84 'ptmd': 'true',
85 'id': video_id,
86 'profile': 'player2',
87 })
88
b73612a2 89 title = title or details['title']
90 content_id = details['tracking']['nielsen']['content']['assetid']
ec5e77c5 91
92 info = self._extract_ptmd(
add96eb9 93 f'https://tmd.phoenix.de/tmd/2/ngplayer_2_3/vod/ptmd/phoenix/{content_id}',
ec5e77c5 94 content_id, None, url)
95
b73612a2 96 duration = int_or_none(try_get(
97 details, lambda x: x['tracking']['nielsen']['content']['length']))
98 timestamp = unified_timestamp(details.get('editorialDate'))
99 series = try_get(
100 details, lambda x: x['tracking']['nielsen']['content']['program'],
add96eb9 101 str)
b73612a2 102 episode = title if details.get('contentType') == 'episode' else None
ec5e77c5 103
104 thumbnails = []
b73612a2 105 teaser_images = try_get(details, lambda x: x['teaserImageRef']['layouts'], dict) or {}
106 for thumbnail_key, thumbnail_url in teaser_images.items():
107 thumbnail_url = urljoin(url, thumbnail_url)
ec5e77c5 108 if not thumbnail_url:
109 continue
110 thumbnail = {
111 'url': thumbnail_url,
112 }
b73612a2 113 m = re.match('^([0-9]+)x([0-9]+)$', thumbnail_key)
114 if m:
115 thumbnail['width'] = int(m.group(1))
116 thumbnail['height'] = int(m.group(2))
ec5e77c5 117 thumbnails.append(thumbnail)
118
119 return merge_dicts(info, {
120 'id': content_id,
121 'title': title,
b73612a2 122 'description': details.get('leadParagraph'),
123 'duration': duration,
ec5e77c5 124 'thumbnails': thumbnails,
125 'timestamp': timestamp,
b73612a2 126 'uploader': details.get('tvService'),
127 'series': series,
128 'episode': episode,
ec5e77c5 129 })