]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/phoenix.py
[skip travis] adding automerge support
[yt-dlp.git] / youtube_dl / extractor / phoenix.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import ExtractorError
5
6
7 class PhoenixIE(InfoExtractor):
8 IE_NAME = 'phoenix.de'
9 _VALID_URL = r'''https?://(?:www\.)?phoenix.de/\D+(?P<id>\d+)\.html'''
10 _TESTS = [
11 {
12 'url': 'https://www.phoenix.de/sendungen/dokumentationen/unsere-welt-in-zukunft---stadt-a-1283620.html',
13 'md5': '5e765e838aa3531c745a4f5b249ee3e3',
14 'info_dict': {
15 'id': '0OB4HFc43Ns',
16 'ext': 'mp4',
17 'title': 'Unsere Welt in Zukunft - Stadt',
18 'description': 'md5:9bfb6fd498814538f953b2dcad7ce044',
19 'upload_date': '20190912',
20 'uploader': 'phoenix',
21 'uploader_id': 'phoenix',
22 }
23 },
24 {
25 'url': 'https://www.phoenix.de/drohnenangriffe-in-saudi-arabien-a-1286995.html?ref=aktuelles',
26 'only_matching': True,
27 },
28 # an older page: https://www.phoenix.de/sendungen/gespraeche/phoenix-persoenlich/im-dialog-a-177727.html
29 # seems to not have an embedded video, even though it's uploaded on youtube: https://www.youtube.com/watch?v=4GxnoUHvOkM
30 ]
31
32 def extract_from_json_api(self, video_id, api_url):
33 doc = self._download_json(
34 api_url, video_id,
35 note="Downloading webpage metadata",
36 errnote="Failed to load webpage metadata")
37
38 for a in doc["absaetze"]:
39 if a["typ"] == "video-youtube":
40 return {
41 '_type': 'url_transparent',
42 'id': a["id"],
43 'title': doc["titel"],
44 'url': "https://www.youtube.com/watch?v=%s" % a["id"],
45 'ie_key': 'Youtube',
46 }
47 raise ExtractorError("No downloadable video found", expected=True)
48
49 def _real_extract(self, url):
50 page_id = self._match_id(url)
51 api_url = 'https://www.phoenix.de/response/id/%s' % page_id
52 return self.extract_from_json_api(page_id, api_url)