]>
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
):
8 _VALID_URL
= r
'https?://(?:www\.)?hotnewhiphop\.com/.*\.(?P<id>.*)\.html'
10 'url': 'http://www.hotnewhiphop.com/freddie-gibbs-lay-it-down-song.1435540.html',
11 'md5': '2c2cd2f76ef11a9b3b581e8b232f3d96',
15 'title': 'Freddie Gibbs - Lay It Down'
19 def _real_extract(self
, url
):
20 video_id
= self
._match
_id
(url
)
21 webpage
= self
._download
_webpage
(url
, video_id
)
23 video_url_base64
= self
._search
_regex
(
24 r
'data-path="(.*?)"', webpage
, 'video URL', default
=None)
26 if video_url_base64
is None:
27 video_url
= self
._search
_regex
(
28 r
'"contentUrl" content="(.*?)"', webpage
, 'content URL')
29 return self
.url_result(video_url
, ie
='Youtube')
31 reqdata
= urlencode_postdata([
33 ('mediaId', video_id
),
36 'http://www.hotnewhiphop.com/ajax/media/getActions/', data
=reqdata
)
37 r
.headers
['Content-Type'] = 'application/x-www-form-urlencoded'
38 mkd
= self
._download
_json
(
39 r
, video_id
, note
='Requesting media key',
40 errnote
='Could not download media key')
41 if 'mediaKey' not in mkd
:
42 raise ExtractorError('Did not get a media key')
44 redirect_url
= compat_b64decode(video_url_base64
).decode('utf-8')
45 redirect_req
= HEADRequest(redirect_url
)
46 req
= self
._request
_webpage
(
47 redirect_req
, video_id
,
48 note
='Resolving final URL', errnote
='Could not resolve final URL')
50 if video_url
.endswith('.html'):
51 raise ExtractorError('Redirect failed')
53 video_title
= self
._og
_search
_title
(webpage
).strip()
59 'thumbnail': self
._og
_search
_thumbnail
(webpage
),