]>
Commit | Line | Data |
---|---|---|
2656f4eb PH |
1 | from __future__ import unicode_literals |
2 | ||
27110b05 | 3 | from .common import InfoExtractor |
f517c0c0 | 4 | from ..utils import int_or_none |
27110b05 PH |
5 | |
6 | ||
7 | class HypemIE(InfoExtractor): | |
f517c0c0 | 8 | _VALID_URL = r'https?://(?:www\.)?hypem\.com/track/(?P<id>[0-9a-z]{5})' |
6f5ac90c | 9 | _TEST = { |
2656f4eb PH |
10 | 'url': 'http://hypem.com/track/1v6ga/BODYWORK+-+TAME', |
11 | 'md5': 'b9cc91b5af8995e9f0c1cee04c575828', | |
12 | 'info_dict': { | |
13 | 'id': '1v6ga', | |
14 | 'ext': 'mp3', | |
15 | 'title': 'Tame', | |
16 | 'uploader': 'BODYWORK', | |
f517c0c0 RA |
17 | 'timestamp': 1371810457, |
18 | 'upload_date': '20130621', | |
6f5ac90c PH |
19 | } |
20 | } | |
27110b05 PH |
21 | |
22 | def _real_extract(self, url): | |
1cc79574 | 23 | track_id = self._match_id(url) |
27110b05 | 24 | |
f517c0c0 RA |
25 | response = self._download_webpage(url, track_id) |
26 | ||
27 | track = self._parse_json(self._html_search_regex( | |
28 | r'(?s)<script\s+type="application/json"\s+id="displayList-data">(.+?)</script>', | |
29 | response, 'tracks'), track_id)['tracks'][0] | |
30 | ||
2656f4eb | 31 | track_id = track['id'] |
2656f4eb | 32 | title = track['song'] |
27110b05 | 33 | |
f517c0c0 RA |
34 | final_url = self._download_json( |
35 | 'http://hypem.com/serve/source/%s/%s' % (track_id, track['key']), | |
36 | track_id, 'Downloading metadata', headers={ | |
37 | 'Content-Type': 'application/json' | |
38 | })['url'] | |
27110b05 | 39 | |
2656f4eb PH |
40 | return { |
41 | 'id': track_id, | |
42 | 'url': final_url, | |
43 | 'ext': 'mp3', | |
44 | 'title': title, | |
f517c0c0 RA |
45 | 'uploader': track.get('artist'), |
46 | 'duration': int_or_none(track.get('time')), | |
47 | 'timestamp': int_or_none(track.get('ts')), | |
48 | 'track': title, | |
2656f4eb | 49 | } |