]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/skynewsau.py
[cleanup] Misc fixes
[yt-dlp.git] / yt_dlp / extractor / skynewsau.py
CommitLineData
72ab7687
AG
1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5from ..utils import (
6 try_get,
7 unified_strdate,
8)
9
10
11class SkyNewsAUIE(InfoExtractor):
73f035e1 12 _VALID_URL = r'https?://(?:www\.)?skynews\.com\.au/[^/]+/[^/]+/[^/]+/video/(?P<id>[a-z0-9]+)'
72ab7687
AG
13
14 _TESTS = [{
15 'url': 'https://www.skynews.com.au/world-news/united-states/incredible-vision-shows-lava-overflowing-from-spains-la-palma-volcano/video/0f4c6243d6903502c01251f228b91a71',
16 'info_dict': {
17 'id': '6277184925001',
18 'ext': 'mp4',
19 'title': 'md5:60594f1ea6d5ae93e292900f4d34e9ae',
20 'description': 'md5:60594f1ea6d5ae93e292900f4d34e9ae',
21 'thumbnail': r're:^https?://.*\.jpg',
22 'duration': 76.394,
23 'timestamp': 1634271300,
24 'uploader_id': '5348771529001',
25 'tags': ['fblink', 'msn', 'usa', 'world', 'yt'],
26 'upload_date': '20211015',
27 },
28 'params': {'skip_download': True, 'format': 'bv'}
29 }]
30
31 _API_KEY = '6krsj3w249nk779d8fukqx9f'
32
33 def _real_extract(self, url):
34 id = self._match_id(url)
35 webpage = self._download_webpage(url, id)
36 embedcode = self._search_regex(r'embedcode\s?=\s?\"([^\"]+)\"', webpage, 'embedcode')
37 data_json = self._download_json(
38 f'https://content.api.news/v3/videos/brightcove/{embedcode}?api_key={self._API_KEY}', id)['content']
39 return {
40 'id': id,
41 '_type': 'url_transparent',
42 'url': 'https://players.brightcove.net/%s/default_default/index.html?videoId=%s' % tuple(embedcode.split('-')),
43 'ie_key': 'BrightcoveNew',
44 'title': data_json.get('caption'),
45 'upload_date': unified_strdate(try_get(data_json, lambda x: x['date']['created'])),
46 }