]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hotnewhiphop.py
Merge tag 'upstream/2013.08.17'
[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 results = [{
38 'id': video_id,
39 'url' : video_url,
40 'title' : video_title,
41 'thumbnail' : self._og_search_thumbnail(webpage_src),
42 'ext' : 'mp3',
43 }]
44 return results