]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/skysports.py
Fix the changelog.
[youtubedl] / youtube_dl / extractor / skysports.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 extract_attributes,
7 smuggle_url,
8 strip_or_none,
9 urljoin,
10 )
11
12
13 class SkySportsIE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?skysports\.com/watch/video/(?P<id>[0-9]+)'
15 _TEST = {
16 'url': 'http://www.skysports.com/watch/video/10328419/bale-its-our-time-to-shine',
17 'md5': '77d59166cddc8d3cb7b13e35eaf0f5ec',
18 'info_dict': {
19 'id': '10328419',
20 'ext': 'mp4',
21 'title': 'Bale: It\'s our time to shine',
22 'description': 'md5:e88bda94ae15f7720c5cb467e777bb6d',
23 },
24 'add_ie': ['Ooyala'],
25 }
26
27 def _real_extract(self, url):
28 video_id = self._match_id(url)
29 webpage = self._download_webpage(url, video_id)
30 video_data = extract_attributes(self._search_regex(
31 r'(<div.+?class="sdc-article-video__media-ooyala"[^>]+>)', webpage, 'video data'))
32
33 video_url = 'ooyala:%s' % video_data['data-video-id']
34 if video_data.get('data-token-required') == 'true':
35 token_fetch_options = self._parse_json(video_data.get('data-token-fetch-options', '{}'), video_id, fatal=False) or {}
36 token_fetch_url = token_fetch_options.get('url')
37 if token_fetch_url:
38 embed_token = self._download_webpage(urljoin(url, token_fetch_url), video_id, fatal=False)
39 if embed_token:
40 video_url = smuggle_url(video_url, {'embed_token': embed_token.strip('"')})
41
42 return {
43 '_type': 'url_transparent',
44 'id': video_id,
45 'url': video_url,
46 'title': self._og_search_title(webpage),
47 'description': strip_or_none(self._og_search_description(webpage)),
48 'ie_key': 'Ooyala',
49 }