]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hypem.py
cca3dd4985dd9ce1587852b34e83e0d8f9e27249
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_urllib_parse
14 class HypemIE(InfoExtractor
):
15 _VALID_URL
= r
'http://(?:www\.)?hypem\.com/track/(?P<id>[^/]+)/'
17 'url': 'http://hypem.com/track/1v6ga/BODYWORK+-+TAME',
18 'md5': 'b9cc91b5af8995e9f0c1cee04c575828',
23 'uploader': 'BODYWORK',
27 def _real_extract(self
, url
):
28 track_id
= self
._match
_id
(url
)
30 data
= {'ax': 1, 'ts': time
.time()}
31 data_encoded
= compat_urllib_parse
.urlencode(data
)
32 complete_url
= url
+ "?" + data_encoded
33 request
= sanitized_Request(complete_url
)
34 response
, urlh
= self
._download
_webpage
_handle
(
35 request
, track_id
, 'Downloading webpage with the url')
36 cookie
= urlh
.headers
.get('Set-Cookie', '')
38 html_tracks
= self
._html
_search
_regex
(
39 r
'(?ms)<script type="application/json" id="displayList-data">\s*(.*?)\s*</script>',
42 track_list
= json
.loads(html_tracks
)
43 track
= track_list
['tracks'][0]
45 raise ExtractorError('Hypemachine contained invalid JSON.')
48 track_id
= track
['id']
49 artist
= track
['artist']
52 serve_url
= "http://hypem.com/serve/source/%s/%s" % (track_id
, key
)
53 request
= sanitized_Request(
54 serve_url
, '', {'Content-Type': 'application/json'})
55 request
.add_header('cookie', cookie
)
56 song_data
= self
._download
_json
(request
, track_id
, 'Downloading metadata')
57 final_url
= song_data
["url"]