You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. extract_attributes,
  6. smuggle_url,
  7. strip_or_none,
  8. urljoin,
  9. )
  10. class SkyBaseIE(InfoExtractor):
  11. def _real_extract(self, url):
  12. video_id = self._match_id(url)
  13. webpage = self._download_webpage(url, video_id)
  14. video_data = extract_attributes(self._search_regex(
  15. r'(<div.+?class="[^"]*sdc-article-video__media-ooyala[^"]*"[^>]+>)',
  16. webpage, 'video data'))
  17. video_url = 'ooyala:%s' % video_data['data-video-id']
  18. if video_data.get('data-token-required') == 'true':
  19. token_fetch_options = self._parse_json(video_data.get(
  20. 'data-token-fetch-options', '{}'), video_id, fatal=False) or {}
  21. token_fetch_url = token_fetch_options.get('url')
  22. if token_fetch_url:
  23. embed_token = self._download_webpage(urljoin(
  24. url, token_fetch_url), video_id, fatal=False)
  25. if embed_token:
  26. video_url = smuggle_url(
  27. video_url, {'embed_token': embed_token.strip('"')})
  28. return {
  29. '_type': 'url_transparent',
  30. 'id': video_id,
  31. 'url': video_url,
  32. 'title': self._og_search_title(webpage),
  33. 'description': strip_or_none(self._og_search_description(webpage)),
  34. 'ie_key': 'Ooyala',
  35. }
  36. class SkySportsIE(SkyBaseIE):
  37. _VALID_URL = r'https?://(?:www\.)?skysports\.com/watch/video/(?P<id>[0-9]+)'
  38. _TEST = {
  39. 'url': 'http://www.skysports.com/watch/video/10328419/bale-its-our-time-to-shine',
  40. 'md5': '77d59166cddc8d3cb7b13e35eaf0f5ec',
  41. 'info_dict': {
  42. 'id': 'o3eWJnNDE6l7kfNO8BOoBlRxXRQ4ANNQ',
  43. 'ext': 'mp4',
  44. 'title': 'Bale: It\'s our time to shine',
  45. 'description': 'md5:e88bda94ae15f7720c5cb467e777bb6d',
  46. },
  47. 'add_ie': ['Ooyala'],
  48. }
  49. class SkyNewsIE(SkyBaseIE):
  50. _VALID_URL = r'https?://news\.sky\.com/video/[0-9a-z-]+-(?P<id>[0-9]+)'
  51. _TEST = {
  52. 'url': 'https://news.sky.com/video/russian-plane-inspected-after-deadly-fire-11712962',
  53. 'md5': 'd6327e581473cea9976a3236ded370cd',
  54. 'info_dict': {
  55. 'id': '1ua21xaDE6lCtZDmbYfl8kwsKLooJbNM',
  56. 'ext': 'mp4',
  57. 'title': 'Russian plane inspected after deadly fire',
  58. 'description': 'The Russian Investigative Committee has released video of the wreckage of a passenger plane which caught fire near Moscow.',
  59. },
  60. 'add_ie': ['Ooyala'],
  61. }