]>
Commit | Line | Data |
---|---|---|
5b66de88 JMS |
1 | import re |
2 | import base64 | |
3 | ||
4 | from .common import InfoExtractor | |
5 | ||
6 | ||
7 | class HotNewHipHopIE(InfoExtractor): | |
ed4a915e | 8 | _VALID_URL = r'http://www\.hotnewhiphop.com/.*\.(?P<id>.*)\.html' |
6f5ac90c PH |
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 | } | |
5b66de88 JMS |
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 | ||
5b66de88 | 24 | video_url_base64 = self._search_regex(r'data-path="(.*?)"', |
ed54491c JMS |
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') | |
5b66de88 | 31 | |
ed4a915e | 32 | video_url = base64.b64decode(video_url_base64).decode('utf-8') |
5b66de88 JMS |
33 | |
34 | video_title = self._html_search_regex(r"<title>(.*)</title>", | |
35 | webpage_src, u'title') | |
36 | ||
5b66de88 JMS |
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 |