]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/nowness.py
[mooshare] Add support for mooshare.biz (Closes #2149)
[yt-dlp.git] / youtube_dl / extractor / nowness.py
CommitLineData
066f6a06
PH
1from __future__ import unicode_literals
2
3import re
4
5from .brightcove import BrightcoveIE
6from .common import InfoExtractor
7from ..utils import (
8 ExtractorError,
9)
10
11
12class 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 }