yt-dlp/youtube_dlc/extractor/phoenix.py

53 lines
2 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
from .common import InfoExtractor
2019-09-16 20:53:49 +00:00
from ..utils import ExtractorError
class PhoenixIE(InfoExtractor):
2015-12-29 11:00:52 +00:00
IE_NAME = 'phoenix.de'
2019-09-16 20:53:49 +00:00
_VALID_URL = r'''https?://(?:www\.)?phoenix.de/\D+(?P<id>\d+)\.html'''
2015-03-30 15:15:08 +00:00
_TESTS = [
{
2019-09-16 20:53:49 +00:00
'url': 'https://www.phoenix.de/sendungen/dokumentationen/unsere-welt-in-zukunft---stadt-a-1283620.html',
'md5': '5e765e838aa3531c745a4f5b249ee3e3',
2015-03-30 15:15:08 +00:00
'info_dict': {
2019-09-16 20:53:49 +00:00
'id': '0OB4HFc43Ns',
2015-03-30 15:15:08 +00:00
'ext': 'mp4',
2019-09-16 20:53:49 +00:00
'title': 'Unsere Welt in Zukunft - Stadt',
'description': 'md5:9bfb6fd498814538f953b2dcad7ce044',
'upload_date': '20190912',
'uploader': 'phoenix',
'uploader_id': 'phoenix',
2015-03-30 15:15:08 +00:00
}
},
{
2019-09-16 20:53:49 +00:00
'url': 'https://www.phoenix.de/drohnenangriffe-in-saudi-arabien-a-1286995.html?ref=aktuelles',
2015-03-30 15:15:08 +00:00
'only_matching': True,
},
2019-09-16 20:53:49 +00:00
# an older page: https://www.phoenix.de/sendungen/gespraeche/phoenix-persoenlich/im-dialog-a-177727.html
# seems to not have an embedded video, even though it's uploaded on youtube: https://www.youtube.com/watch?v=4GxnoUHvOkM
2015-03-30 15:15:08 +00:00
]
2019-09-16 20:53:49 +00:00
def extract_from_json_api(self, video_id, api_url):
doc = self._download_json(
api_url, video_id,
note="Downloading webpage metadata",
errnote="Failed to load webpage metadata")
for a in doc["absaetze"]:
if a["typ"] == "video-youtube":
return {
'_type': 'url_transparent',
'id': a["id"],
'title': doc["titel"],
'url': "https://www.youtube.com/watch?v=%s" % a["id"],
'ie_key': 'Youtube',
}
raise ExtractorError("No downloadable video found", expected=True)
def _real_extract(self, url):
2019-09-16 20:53:49 +00:00
page_id = self._match_id(url)
api_url = 'https://www.phoenix.de/response/id/%s' % page_id
return self.extract_from_json_api(page_id, api_url)