]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hotnewhiphop.py
34163725f8c9562380a3ea30a17780e599f3b0a7
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
14 class HotNewHipHopIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?hotnewhiphop\.com/.*\.(?P<id>.*)\.html'
17 'url': 'http://www.hotnewhiphop.com/freddie-gibbs-lay-it-down-song.1435540.html',
18 'md5': '2c2cd2f76ef11a9b3b581e8b232f3d96',
22 'title': 'Freddie Gibbs - Lay It Down'
26 def _real_extract(self
, url
):
27 video_id
= self
._match
_id
(url
)
28 webpage
= self
._download
_webpage
(url
, video_id
)
30 video_url_base64
= self
._search
_regex
(
31 r
'data-path="(.*?)"', webpage
, 'video URL', default
=None)
33 if video_url_base64
is None:
34 video_url
= self
._search
_regex
(
35 r
'"contentUrl" content="(.*?)"', webpage
, 'content URL')
36 return self
.url_result(video_url
, ie
='Youtube')
38 reqdata
= urlencode_postdata([
40 ('mediaId', video_id
),
42 r
= sanitized_Request(
43 'http://www.hotnewhiphop.com/ajax/media/getActions/', data
=reqdata
)
44 r
.add_header('Content-Type', 'application/x-www-form-urlencoded')
45 mkd
= self
._download
_json
(
46 r
, video_id
, note
='Requesting media key',
47 errnote
='Could not download media key')
48 if 'mediaKey' not in mkd
:
49 raise ExtractorError('Did not get a media key')
51 redirect_url
= base64
.b64decode(video_url_base64
).decode('utf-8')
52 redirect_req
= HEADRequest(redirect_url
)
53 req
= self
._request
_webpage
(
54 redirect_req
, video_id
,
55 note
='Resolving final URL', errnote
='Could not resolve final URL')
56 video_url
= req
.geturl()
57 if video_url
.endswith('.html'):
58 raise ExtractorError('Redirect failed')
60 video_title
= self
._og
_search
_title
(webpage
).strip()
66 'thumbnail': self
._og
_search
_thumbnail
(webpage
),