Merge branch 'Weiqitv' of https://github.com/FounderSG/youtube-dl into FounderSG...
[youtube-dl] / youtube_dl / extractor / fox.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import smuggle_url
6
7
8 class FOXIE(InfoExtractor):
9     _VALID_URL = r'https?://(?:www\.)?fox\.com/watch/(?P<id>[0-9]+)'
10     _TEST = {
11         'url': 'http://www.fox.com/watch/255180355939/7684182528',
12         'info_dict': {
13             'id': '255180355939',
14             'ext': 'mp4',
15             'title': 'Official Trailer: Gotham',
16             'description': 'Tracing the rise of the great DC Comics Super-Villains and vigilantes, Gotham reveals an entirely new chapter that has never been told.',
17             'duration': 129,
18         },
19         'add_ie': ['ThePlatform'],
20         'params': {
21             # m3u8 download
22             'skip_download': True,
23         },
24     }
25
26     def _real_extract(self, url):
27         video_id = self._match_id(url)
28         webpage = self._download_webpage(url, video_id)
29
30         release_url = self._parse_json(self._search_regex(
31             r'"fox_pdk_player"\s*:\s*({[^}]+?})', webpage, 'fox_pdk_player'),
32             video_id)['release_url'] + '&manifest=m3u'
33
34         return {
35             '_type': 'url_transparent',
36             'ie_key': 'ThePlatform',
37             'url': smuggle_url(release_url, {'force_smil_url': True}),
38             'id': video_id,
39         }