]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sky.py
Initiate new release.
[youtubedl] / youtube_dl / extractor / sky.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 SkyBaseIE(InfoExtractor):
14 def _real_extract(self, url):
15 video_id = self._match_id(url)
16 webpage = self._download_webpage(url, video_id)
17 video_data = extract_attributes(self._search_regex(
18 r'(<div.+?class="[^"]*sdc-article-video__media-ooyala[^"]*"[^>]+>)',
19 webpage, 'video data'))
20
21 video_url = 'ooyala:%s' % video_data['data-video-id']
22 if video_data.get('data-token-required') == 'true':
23 token_fetch_options = self._parse_json(video_data.get(
24 'data-token-fetch-options', '{}'), video_id, fatal=False) or {}
25 token_fetch_url = token_fetch_options.get('url')
26 if token_fetch_url:
27 embed_token = self._download_webpage(urljoin(
28 url, token_fetch_url), video_id, fatal=False)
29 if embed_token:
30 video_url = smuggle_url(
31 video_url, {'embed_token': embed_token.strip('"')})
32
33 return {
34 '_type': 'url_transparent',
35 'id': video_id,
36 'url': video_url,
37 'title': self._og_search_title(webpage),
38 'description': strip_or_none(self._og_search_description(webpage)),
39 'ie_key': 'Ooyala',
40 }
41
42
43 class SkySportsIE(SkyBaseIE):
44 _VALID_URL = r'https?://(?:www\.)?skysports\.com/watch/video/(?P<id>[0-9]+)'
45 _TEST = {
46 'url': 'http://www.skysports.com/watch/video/10328419/bale-its-our-time-to-shine',
47 'md5': '77d59166cddc8d3cb7b13e35eaf0f5ec',
48 'info_dict': {
49 'id': 'o3eWJnNDE6l7kfNO8BOoBlRxXRQ4ANNQ',
50 'ext': 'mp4',
51 'title': 'Bale: It\'s our time to shine',
52 'description': 'md5:e88bda94ae15f7720c5cb467e777bb6d',
53 },
54 'add_ie': ['Ooyala'],
55 }
56
57
58 class SkyNewsIE(SkyBaseIE):
59 _VALID_URL = r'https?://news\.sky\.com/video/[0-9a-z-]+-(?P<id>[0-9]+)'
60 _TEST = {
61 'url': 'https://news.sky.com/video/russian-plane-inspected-after-deadly-fire-11712962',
62 'md5': 'd6327e581473cea9976a3236ded370cd',
63 'info_dict': {
64 'id': '1ua21xaDE6lCtZDmbYfl8kwsKLooJbNM',
65 'ext': 'mp4',
66 'title': 'Russian plane inspected after deadly fire',
67 'description': 'The Russian Investigative Committee has released video of the wreckage of a passenger plane which caught fire near Moscow.',
68 },
69 'add_ie': ['Ooyala'],
70 }