]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hotnewhiphop.py
ca3abb7d7fdaaf5c84869e1b4eda125d5076573a
[youtubedl] / youtube_dl / extractor / hotnewhiphop.py
1 import re
2 import base64
3
4 from .common import InfoExtractor
5
6
7 class HotNewHipHopIE(InfoExtractor):
8 _VALID_URL = r'http://www\.hotnewhiphop.com/.*\.(?P<id>.*)\.html'
9 _TEST = {
10 u'url': u"http://www.hotnewhiphop.com/freddie-gibbs-lay-it-down-song.1435540.html'",
11 u'file': u'1435540.mp3',
12 u'md5': u'2c2cd2f76ef11a9b3b581e8b232f3d96',
13 u'info_dict': {
14 u"title": u"Freddie Gibbs Songs - Lay It Down"
15 }
16 }
17
18 def _real_extract(self, url):
19 m = re.match(self._VALID_URL, url)
20 video_id = m.group('id')
21
22 webpage_src = self._download_webpage(url, video_id)
23
24 video_url_base64 = self._search_regex(r'data-path="(.*?)"',
25 webpage_src, u'video URL', fatal=False)
26
27 if video_url_base64 == None:
28 video_url = self._search_regex(r'"contentUrl" content="(.*?)"', webpage_src,
29 u'video URL')
30 return self.url_result(video_url, ie='Youtube')
31
32 video_url = base64.b64decode(video_url_base64).decode('utf-8')
33
34 video_title = self._html_search_regex(r"<title>(.*)</title>",
35 webpage_src, u'title')
36
37 # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
38 thumbnail = self._html_search_regex(r'"og:image" content="(.*)"',
39 webpage_src, u'thumbnail', fatal=False)
40
41 results = [{
42 'id': video_id,
43 'url' : video_url,
44 'title' : video_title,
45 'thumbnail' : thumbnail,
46 'ext' : 'mp3',
47 }]
48 return results