]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/worldstarhiphop.py
Merge remote-tracking branch 'lenaten/8tracks'
[yt-dlp.git] / youtube_dl / extractor / worldstarhiphop.py
CommitLineData
c9aa111b
PH
1from __future__ import unicode_literals
2
250f5578
PH
3import re
4
5from .common import InfoExtractor
6
7
8class 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",
12548cd9 16 "title": "KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!"
6b47c7f2
PH
17 }
18 }
19
250f5578 20 def _real_extract(self, url):
12548cd9
PH
21 video_id = self._match_id(url)
22 webpage = self._download_webpage(url, video_id)
250f5578 23
12548cd9 24 m_vevo_id = re.search(r'videoId=(.*?)&amp?', webpage)
2bc3de0f 25 if m_vevo_id is not None:
2bc3de0f 26 return self.url_result('vevo:%s' % m_vevo_id.group(1), ie='Vevo')
63f05de1 27
c9aa111b 28 video_url = self._search_regex(
12548cd9 29 r'so\.addVariable\("file","(.*?)"\)', webpage, 'video URL')
250f5578 30
d18596ba 31 if 'youtube' in video_url:
a545d1d2 32 return self.url_result(video_url, ie='Youtube')
d18596ba 33
c9aa111b 34 video_title = self._html_search_regex(
12548cd9
PH
35 r'(?s)<div class="content-heading">\s*<h1>(.*?)</h1>',
36 webpage, 'title')
250f5578
PH
37
38 # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
c9aa111b 39 thumbnail = self._html_search_regex(
12548cd9 40 r'rel="image_src" href="(.*)" />', webpage, 'thumbnail',
c9aa111b 41 fatal=False)
250f5578 42 if not thumbnail:
12548cd9
PH
43 _title = r'candytitles.*>(.*)</span>'
44 mobj = re.search(_title, webpage)
250f5578
PH
45 if mobj is not None:
46 video_title = mobj.group(1)
47
c9aa111b
PH
48 return {
49 'id': video_id,
50 'url': video_url,
51 'title': video_title,
52 'thumbnail': thumbnail,
53 }