]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/syfy.py
Prepare to upload.
[youtubedl] / youtube_dl / extractor / syfy.py
1 from __future__ import unicode_literals
2
3 from .adobepass import AdobePassIE
4 from ..utils import (
5 update_url_query,
6 smuggle_url,
7 )
8
9
10 class SyfyIE(AdobePassIE):
11 _VALID_URL = r'https?://(?:www\.)?syfy\.com/(?:[^/]+/)?videos/(?P<id>[^/?#]+)'
12 _TESTS = [{
13 'url': 'http://www.syfy.com/theinternetruinedmylife/videos/the-internet-ruined-my-life-season-1-trailer',
14 'info_dict': {
15 'id': '2968097',
16 'ext': 'mp4',
17 'title': 'The Internet Ruined My Life: Season 1 Trailer',
18 'description': 'One tweet, one post, one click, can destroy everything.',
19 'uploader': 'NBCU-MPAT',
20 'upload_date': '20170113',
21 'timestamp': 1484345640,
22 },
23 'params': {
24 # m3u8 download
25 'skip_download': True,
26 },
27 'add_ie': ['ThePlatform'],
28 }]
29
30 def _real_extract(self, url):
31 display_id = self._match_id(url)
32 webpage = self._download_webpage(url, display_id)
33 syfy_mpx = list(self._parse_json(self._search_regex(
34 r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', webpage, 'drupal settings'),
35 display_id)['syfy']['syfy_mpx'].values())[0]
36 video_id = syfy_mpx['mpxGUID']
37 title = syfy_mpx['episodeTitle']
38 query = {
39 'mbr': 'true',
40 'manifest': 'm3u',
41 }
42 if syfy_mpx.get('entitlement') == 'auth':
43 resource = self._get_mvpd_resource(
44 'syfy', title, video_id,
45 syfy_mpx.get('mpxRating', 'TV-14'))
46 query['auth'] = self._extract_mvpd_auth(
47 url, video_id, 'syfy', resource)
48
49 return {
50 '_type': 'url_transparent',
51 'ie_key': 'ThePlatform',
52 'url': smuggle_url(update_url_query(
53 self._proto_relative_url(syfy_mpx['releaseURL']), query),
54 {'force_smil_url': True}),
55 'title': title,
56 'id': video_id,
57 'display_id': display_id,
58 }