]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hypem.py
aa0724a02353840e5f5533a1eedbc7005aa63008
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
16 class HypemIE(InfoExtractor
):
17 _VALID_URL
= r
'http://(?:www\.)?hypem\.com/track/(?P<id>[^/]+)/'
19 'url': 'http://hypem.com/track/1v6ga/BODYWORK+-+TAME',
20 'md5': 'b9cc91b5af8995e9f0c1cee04c575828',
25 'uploader': 'BODYWORK',
29 def _real_extract(self
, url
):
30 track_id
= self
._match
_id
(url
)
32 data
= {'ax': 1, 'ts': time
.time()}
33 data_encoded
= compat_urllib_parse
.urlencode(data
)
34 complete_url
= url
+ "?" + data_encoded
35 request
= compat_urllib_request
.Request(complete_url
)
36 response
, urlh
= self
._download
_webpage
_handle
(
37 request
, track_id
, 'Downloading webpage with the url')
38 cookie
= urlh
.headers
.get('Set-Cookie', '')
40 html_tracks
= self
._html
_search
_regex
(
41 r
'(?ms)<script type="application/json" id="displayList-data">\s*(.*?)\s*</script>',
44 track_list
= json
.loads(html_tracks
)
45 track
= track_list
['tracks'][0]
47 raise ExtractorError('Hypemachine contained invalid JSON.')
50 track_id
= track
['id']
51 artist
= track
['artist']
54 serve_url
= "http://hypem.com/serve/source/%s/%s" % (track_id
, key
)
55 request
= compat_urllib_request
.Request(
56 serve_url
, '', {'Content-Type': 'application/json'})
57 request
.add_header('cookie', cookie
)
58 song_data
= self
._download
_json
(request
, track_id
, 'Downloading metadata')
59 final_url
= song_data
["url"]