]>
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): | |
fa6a1699 YCH |
9 | _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/(?:videos|android)/video\.php\?v=(?P<id>.*)' |
10 | _TESTS = [{ | |
6b47c7f2 | 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", | |
12548cd9 | 16 | "title": "KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!" |
6b47c7f2 | 17 | } |
fa6a1699 YCH |
18 | }, { |
19 | 'url': 'http://m.worldstarhiphop.com/android/video.php?v=wshh6a7q1ny0G34ZwuIO', | |
20 | 'md5': 'dc1c76c83ecc4190bb1eb143899b87d3', | |
21 | 'info_dict': { | |
22 | 'id': 'wshh6a7q1ny0G34ZwuIO', | |
23 | 'ext': 'mp4', | |
24 | "title": "KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!" | |
25 | } | |
26 | }] | |
6b47c7f2 | 27 | |
250f5578 | 28 | def _real_extract(self, url): |
12548cd9 PH |
29 | video_id = self._match_id(url) |
30 | webpage = self._download_webpage(url, video_id) | |
250f5578 | 31 | |
12548cd9 | 32 | m_vevo_id = re.search(r'videoId=(.*?)&?', webpage) |
2bc3de0f | 33 | if m_vevo_id is not None: |
2bc3de0f | 34 | return self.url_result('vevo:%s' % m_vevo_id.group(1), ie='Vevo') |
63f05de1 | 35 | |
c9aa111b | 36 | video_url = self._search_regex( |
fa6a1699 YCH |
37 | [r'so\.addVariable\("file","(.*?)"\)', |
38 | r'<div class="artlist">\s*<a[^>]+href="([^"]+)">'], | |
39 | webpage, 'video URL') | |
250f5578 | 40 | |
d18596ba | 41 | if 'youtube' in video_url: |
a545d1d2 | 42 | return self.url_result(video_url, ie='Youtube') |
d18596ba | 43 | |
c9aa111b | 44 | video_title = self._html_search_regex( |
fa6a1699 YCH |
45 | [r'(?s)<div class="content-heading">\s*<h1>(.*?)</h1>', |
46 | r'<span[^>]+class="tc-sp-pinned-title">(.*)</span>'], | |
12548cd9 | 47 | webpage, 'title') |
250f5578 PH |
48 | |
49 | # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video. | |
c9aa111b | 50 | thumbnail = self._html_search_regex( |
12548cd9 | 51 | r'rel="image_src" href="(.*)" />', webpage, 'thumbnail', |
fa6a1699 | 52 | default=None) |
250f5578 | 53 | if not thumbnail: |
12548cd9 PH |
54 | _title = r'candytitles.*>(.*)</span>' |
55 | mobj = re.search(_title, webpage) | |
250f5578 PH |
56 | if mobj is not None: |
57 | video_title = mobj.group(1) | |
58 | ||
c9aa111b PH |
59 | return { |
60 | 'id': video_id, | |
61 | 'url': video_url, | |
62 | 'title': video_title, | |
63 | 'thumbnail': thumbnail, | |
64 | } |