3 from .common
import InfoExtractor
4 from ..networking
import HEADRequest
, Request
5 from ..utils
import ExtractorError
, urlencode_postdata
8 class HotNewHipHopIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?hotnewhiphop\.com/.*\.(?P<id>.*)\.html'
12 'url': 'http://www.hotnewhiphop.com/freddie-gibbs-lay-it-down-song.1435540.html',
13 'md5': '2c2cd2f76ef11a9b3b581e8b232f3d96',
17 'title': 'Freddie Gibbs - Lay It Down',
21 def _real_extract(self
, url
):
22 video_id
= self
._match
_id
(url
)
23 webpage
= self
._download
_webpage
(url
, video_id
)
25 video_url_base64
= self
._search
_regex
(
26 r
'data-path="(.*?)"', webpage
, 'video URL', default
=None)
28 if video_url_base64
is None:
29 video_url
= self
._search
_regex
(
30 r
'"contentUrl" content="(.*?)"', webpage
, 'content URL')
31 return self
.url_result(video_url
, ie
='Youtube')
33 reqdata
= urlencode_postdata([
35 ('mediaId', video_id
),
38 'http://www.hotnewhiphop.com/ajax/media/getActions/', data
=reqdata
)
39 r
.headers
['Content-Type'] = 'application/x-www-form-urlencoded'
40 mkd
= self
._download
_json
(
41 r
, video_id
, note
='Requesting media key',
42 errnote
='Could not download media key')
43 if 'mediaKey' not in mkd
:
44 raise ExtractorError('Did not get a media key')
46 redirect_url
= base64
.b64decode(video_url_base64
).decode('utf-8')
47 redirect_req
= HEADRequest(redirect_url
)
48 req
= self
._request
_webpage
(
49 redirect_req
, video_id
,
50 note
='Resolving final URL', errnote
='Could not resolve final URL')
52 if video_url
.endswith('.html'):
53 raise ExtractorError('Redirect failed')
55 video_title
= self
._og
_search
_title
(webpage
).strip()
61 'thumbnail': self
._og
_search
_thumbnail
(webpage
),