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