]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nowness.py
Prepare for release.
[youtubedl] / youtube_dl / extractor / nowness.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .brightcove import BrightcoveIE
6 from .common import InfoExtractor
7 from ..utils import ExtractorError
8
9
10 class NownessIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?nowness\.com/[^?#]*?/(?P<id>[0-9]+)/(?P<slug>[^/]+?)(?:$|[?#])'
12
13 _TEST = {
14 'url': 'http://www.nowness.com/day/2013/6/27/3131/candor--the-art-of-gesticulation',
15 'md5': '068bc0202558c2e391924cb8cc470676',
16 'info_dict': {
17 'id': '2520295746001',
18 'ext': 'mp4',
19 'description': 'Candor: The Art of Gesticulation',
20 'uploader': 'Nowness',
21 'title': 'Candor: The Art of Gesticulation',
22 }
23 }
24
25 def _real_extract(self, url):
26 mobj = re.match(self._VALID_URL, url)
27 video_id = mobj.group('slug')
28
29 webpage = self._download_webpage(url, video_id)
30 player_url = self._search_regex(
31 r'"([^"]+/content/issue-[0-9.]+.js)"', webpage, 'player URL')
32 real_id = self._search_regex(
33 r'\sdata-videoId="([0-9]+)"', webpage, 'internal video ID')
34
35 player_code = self._download_webpage(
36 player_url, video_id,
37 note='Downloading player JavaScript',
38 errnote='Player download failed')
39 player_code = player_code.replace("'+d+'", real_id)
40
41 bc_url = BrightcoveIE._extract_brightcove_url(player_code)
42 if bc_url is None:
43 raise ExtractorError('Could not find player definition')
44 return {
45 '_type': 'url',
46 'url': bc_url,
47 'ie_key': 'Brightcove',
48 }