]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/worldstarhiphop.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / worldstarhiphop.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class WorldStarHipHopIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/videos/video\.php\?v=(?P<id>.*)'
10 _TEST = {
11 "url": "http://www.worldstarhiphop.com/videos/video.php?v=wshh6a7q1ny0G34ZwuIO",
12 "md5": "9d04de741161603bf7071bbf4e883186",
13 "info_dict": {
14 "id": "wshh6a7q1ny0G34ZwuIO",
15 "ext": "mp4",
16 "title": "KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!"
17 }
18 }
19
20 def _real_extract(self, url):
21 video_id = self._match_id(url)
22 webpage = self._download_webpage(url, video_id)
23
24 m_vevo_id = re.search(r'videoId=(.*?)&amp?', webpage)
25 if m_vevo_id is not None:
26 return self.url_result('vevo:%s' % m_vevo_id.group(1), ie='Vevo')
27
28 video_url = self._search_regex(
29 r'so\.addVariable\("file","(.*?)"\)', webpage, 'video URL')
30
31 if 'youtube' in video_url:
32 return self.url_result(video_url, ie='Youtube')
33
34 video_title = self._html_search_regex(
35 r'(?s)<div class="content-heading">\s*<h1>(.*?)</h1>',
36 webpage, 'title')
37
38 # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
39 thumbnail = self._html_search_regex(
40 r'rel="image_src" href="(.*)" />', webpage, 'thumbnail',
41 fatal=False)
42 if not thumbnail:
43 _title = r'candytitles.*>(.*)</span>'
44 mobj = re.search(_title, webpage)
45 if mobj is not None:
46 video_title = mobj.group(1)
47
48 return {
49 'id': video_id,
50 'url': video_url,
51 'title': video_title,
52 'thumbnail': thumbnail,
53 }
54