]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/worldstarhiphop.py
Fix description of the modularization.
[youtubedl] / youtube_dl / extractor / worldstarhiphop.py
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>.*)'
8 IE_NAME = u'WorldStarHipHop'
9
10 def _real_extract(self, url):
11 m = re.match(self._VALID_URL, url)
12 video_id = m.group('id')
13
14 webpage_src = self._download_webpage(url, video_id)
15
16 video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)',
17 webpage_src, u'video URL')
18
19 if 'youtube' in video_url:
20 self.to_screen(u'Youtube video detected:')
21 return self.url_result(video_url, ie='Youtube')
22
23 if 'mp4' in video_url:
24 ext = 'mp4'
25 else:
26 ext = 'flv'
27
28 video_title = self._html_search_regex(r"<title>(.*)</title>",
29 webpage_src, u'title')
30
31 # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
32 thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
33 webpage_src, u'thumbnail', fatal=False)
34
35 if not thumbnail:
36 _title = r"""candytitles.*>(.*)</span>"""
37 mobj = re.search(_title, webpage_src)
38 if mobj is not None:
39 video_title = mobj.group(1)
40
41 results = [{
42 'id': video_id,
43 'url' : video_url,
44 'title' : video_title,
45 'thumbnail' : thumbnail,
46 'ext' : ext,
47 }]
48 return results