]>
Commit | Line | Data |
---|---|---|
ebfe352b JMF |
1 | from __future__ import unicode_literals |
2 | ||
825e0984 | 3 | import re |
67ae7b47 | 4 | import json |
825e0984 PH |
5 | |
6 | from .common import InfoExtractor | |
7 | ||
8 | ||
9 | class BreakIE(InfoExtractor): | |
ebfe352b | 10 | _VALID_URL = r'http://(?:www\.)?break\.com/video/([^/]+)' |
6f5ac90c | 11 | _TEST = { |
ebfe352b JMF |
12 | 'url': 'http://www.break.com/video/when-girls-act-like-guys-2468056', |
13 | 'md5': 'a3513fb1547fba4fb6cfac1bffc6c46b', | |
14 | 'info_dict': { | |
15 | 'id': '2468056', | |
16 | 'ext': 'mp4', | |
17 | 'title': 'When Girls Act Like D-Bags', | |
6f5ac90c PH |
18 | } |
19 | } | |
825e0984 PH |
20 | |
21 | def _real_extract(self, url): | |
22 | mobj = re.match(self._VALID_URL, url) | |
23 | video_id = mobj.group(1).split("-")[-1] | |
67ae7b47 JMF |
24 | embed_url = 'http://www.break.com/embed/%s' % video_id |
25 | webpage = self._download_webpage(embed_url, video_id) | |
a25f2f99 | 26 | info_json = self._search_regex(r'var embedVars = ({.*})\s*?</script>', |
9b77f951 | 27 | webpage, 'info json', flags=re.DOTALL) |
67ae7b47 JMF |
28 | info = json.loads(info_json) |
29 | video_url = info['videoUri'] | |
659eb98a JMF |
30 | youtube_id = info.get('youtubeId') |
31 | if youtube_id: | |
32 | return self.url_result(youtube_id, 'Youtube') | |
33 | ||
67ae7b47 | 34 | final_url = video_url + '?' + info['AuthToken'] |
ebfe352b JMF |
35 | return { |
36 | 'id': video_id, | |
37 | 'url': final_url, | |
38 | 'title': info['contentName'], | |
67ae7b47 | 39 | 'thumbnail': info['thumbUri'], |
ebfe352b | 40 | } |