skynewsau.py 1.8 KB

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