]>
Commit | Line | Data |
---|---|---|
c9aa111b PH |
1 | from __future__ import unicode_literals |
2 | ||
250f5578 PH |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
6 | ||
7 | ||
8 | class WorldStarHipHopIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/videos/video\.php\?v=(?P<id>.*)' | |
6b47c7f2 PH |
10 | _TEST = { |
11 | "url": "http://www.worldstarhiphop.com/videos/video.php?v=wshh6a7q1ny0G34ZwuIO", | |
6b47c7f2 PH |
12 | "md5": "9d04de741161603bf7071bbf4e883186", |
13 | "info_dict": { | |
c9aa111b PH |
14 | "id": "wshh6a7q1ny0G34ZwuIO", |
15 | "ext": "mp4", | |
6b47c7f2 PH |
16 | "title": "Video: KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!" |
17 | } | |
18 | } | |
19 | ||
250f5578 PH |
20 | def _real_extract(self, url): |
21 | m = re.match(self._VALID_URL, url) | |
22 | video_id = m.group('id') | |
23 | ||
24 | webpage_src = self._download_webpage(url, video_id) | |
25 | ||
2bc3de0f | 26 | m_vevo_id = re.search(r'videoId=(.*?)&?', |
9ddfd84e | 27 | webpage_src) |
2bc3de0f | 28 | if m_vevo_id is not None: |
2bc3de0f | 29 | return self.url_result('vevo:%s' % m_vevo_id.group(1), ie='Vevo') |
63f05de1 | 30 | |
c9aa111b PH |
31 | video_url = self._search_regex( |
32 | r'so\.addVariable\("file","(.*?)"\)', webpage_src, 'video URL') | |
250f5578 | 33 | |
d18596ba | 34 | if 'youtube' in video_url: |
a545d1d2 | 35 | return self.url_result(video_url, ie='Youtube') |
d18596ba | 36 | |
c9aa111b PH |
37 | video_title = self._html_search_regex( |
38 | r"<title>(.*)</title>", webpage_src, 'title') | |
250f5578 PH |
39 | |
40 | # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video. | |
c9aa111b PH |
41 | thumbnail = self._html_search_regex( |
42 | r'rel="image_src" href="(.*)" />', webpage_src, 'thumbnail', | |
43 | fatal=False) | |
250f5578 PH |
44 | if not thumbnail: |
45 | _title = r"""candytitles.*>(.*)</span>""" | |
46 | mobj = re.search(_title, webpage_src) | |
47 | if mobj is not None: | |
48 | video_title = mobj.group(1) | |
49 | ||
c9aa111b PH |
50 | return { |
51 | 'id': video_id, | |
52 | 'url': video_url, | |
53 | 'title': video_title, | |
54 | 'thumbnail': thumbnail, | |
55 | } | |
56 |