logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

hypem.py (1551B)


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