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.

49 lines
1.8 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 SkySportsIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?skysports\.com/watch/video/(?P<id>[0-9]+)'
  12. _TEST = {
  13. 'url': 'http://www.skysports.com/watch/video/10328419/bale-its-our-time-to-shine',
  14. 'md5': '77d59166cddc8d3cb7b13e35eaf0f5ec',
  15. 'info_dict': {
  16. 'id': '10328419',
  17. 'ext': 'mp4',
  18. 'title': 'Bale: It\'s our time to shine',
  19. 'description': 'md5:e88bda94ae15f7720c5cb467e777bb6d',
  20. },
  21. 'add_ie': ['Ooyala'],
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. video_data = extract_attributes(self._search_regex(
  27. r'(<div.+?class="sdc-article-video__media-ooyala"[^>]+>)', webpage, 'video data'))
  28. video_url = 'ooyala:%s' % video_data['data-video-id']
  29. if video_data.get('data-token-required') == 'true':
  30. token_fetch_options = self._parse_json(video_data.get('data-token-fetch-options', '{}'), video_id, fatal=False) or {}
  31. token_fetch_url = token_fetch_options.get('url')
  32. if token_fetch_url:
  33. embed_token = self._download_webpage(urljoin(url, token_fetch_url), video_id, fatal=False)
  34. if embed_token:
  35. video_url = smuggle_url(video_url, {'embed_token': embed_token.strip('"')})
  36. return {
  37. '_type': 'url_transparent',
  38. 'id': video_id,
  39. 'url': video_url,
  40. 'title': self._og_search_title(webpage),
  41. 'description': strip_or_none(self._og_search_description(webpage)),
  42. 'ie_key': 'Ooyala',
  43. }