1 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_urllib_parse_urlencode
14 class HypemIE(InfoExtractor):
15 _VALID_URL = r'https?://(?: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 request = sanitized_Request(url + '?' + compat_urllib_parse_urlencode(data))
32 response, urlh = self._download_webpage_handle(
33 request, track_id, 'Downloading webpage with the url')
35 html_tracks = self._html_search_regex(
36 r'(?ms)<script type="application/json" id="displayList-data">(.+?)</script>',
39 track_list = json.loads(html_tracks)
40 track = track_list['tracks'][0]
42 raise ExtractorError('Hypemachine contained invalid JSON.')
45 track_id = track['id']
48 request = sanitized_Request(
49 'http://hypem.com/serve/source/%s/%s' % (track_id, key),
50 '', {'Content-Type': 'application/json'})
51 song_data = self._download_json(request, track_id, 'Downloading metadata')
52 final_url = song_data['url']
53 artist = track.get('artist')