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