]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hypem.py
Update upstream source from tag 'upstream/2020.06.16.1'
[youtubedl] / youtube_dl / extractor / hypem.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import int_or_none
5
6
7 class HypemIE(InfoExtractor):
8 _VALID_URL = r'https?://(?:www\.)?hypem\.com/track/(?P<id>[0-9a-z]{5})'
9 _TEST = {
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',
17 'timestamp': 1371810457,
18 'upload_date': '20130621',
19 }
20 }
21
22 def _real_extract(self, url):
23 track_id = self._match_id(url)
24
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
31 track_id = track['id']
32 title = track['song']
33
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']
39
40 return {
41 'id': track_id,
42 'url': final_url,
43 'ext': 'mp3',
44 'title': title,
45 'uploader': track.get('artist'),
46 'duration': int_or_none(track.get('time')),
47 'timestamp': int_or_none(track.get('ts')),
48 'track': title,
49 }