]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/hotnewhiphop.py
1 from .common
import InfoExtractor
2 from ..compat
import compat_b64decode
3 from ..networking
import HEADRequest
, Request
4 from ..utils
import ExtractorError
, urlencode_postdata
7 class HotNewHipHopIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?hotnewhiphop\.com/.*\.(?P<id>.*)\.html'
11 'url': 'http://www.hotnewhiphop.com/freddie-gibbs-lay-it-down-song.1435540.html',
12 'md5': '2c2cd2f76ef11a9b3b581e8b232f3d96',
16 'title': 'Freddie Gibbs - Lay It Down'
20 def _real_extract(self
, url
):
21 video_id
= self
._match
_id
(url
)
22 webpage
= self
._download
_webpage
(url
, video_id
)
24 video_url_base64
= self
._search
_regex
(
25 r
'data-path="(.*?)"', webpage
, 'video URL', default
=None)
27 if video_url_base64
is None:
28 video_url
= self
._search
_regex
(
29 r
'"contentUrl" content="(.*?)"', webpage
, 'content URL')
30 return self
.url_result(video_url
, ie
='Youtube')
32 reqdata
= urlencode_postdata([
34 ('mediaId', video_id
),
37 'http://www.hotnewhiphop.com/ajax/media/getActions/', data
=reqdata
)
38 r
.headers
['Content-Type'] = 'application/x-www-form-urlencoded'
39 mkd
= self
._download
_json
(
40 r
, video_id
, note
='Requesting media key',
41 errnote
='Could not download media key')
42 if 'mediaKey' not in mkd
:
43 raise ExtractorError('Did not get a media key')
45 redirect_url
= compat_b64decode(video_url_base64
).decode('utf-8')
46 redirect_req
= HEADRequest(redirect_url
)
47 req
= self
._request
_webpage
(
48 redirect_req
, video_id
,
49 note
='Resolving final URL', errnote
='Could not resolve final URL')
51 if video_url
.endswith('.html'):
52 raise ExtractorError('Redirect failed')
54 video_title
= self
._og
_search
_title
(webpage
).strip()
60 'thumbnail': self
._og
_search
_thumbnail
(webpage
),