]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/worldstarhiphop.py
54a77b69699439a3409280cdab7cbbac5b743069
[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 'mp4' in video_url:
20 ext = 'mp4'
21 else:
22 ext = 'flv'
23
24 video_title = self._html_search_regex(r"<title>(.*)</title>",
25 webpage_src, u'title')
26
27 # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
28 thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
29 webpage_src, u'thumbnail', fatal=False)
30
31 if not thumbnail:
32 _title = r"""candytitles.*>(.*)</span>"""
33 mobj = re.search(_title, webpage_src)
34 if mobj is not None:
35 video_title = mobj.group(1)
36
37 results = [{
38 'id': video_id,
39 'url' : video_url,
40 'title' : video_title,
41 'thumbnail' : thumbnail,
42 'ext' : ext,
43 }]
44 return results