You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. import time
  4. from .common import InfoExtractor
  5. from ..utils import strip_jsonp
  6. class ReverbNationIE(InfoExtractor):
  7. _VALID_URL = r'^https?://(?:www\.)?reverbnation\.com/.*?/song/(?P<id>\d+).*?$'
  8. _TESTS = [{
  9. 'url': 'http://www.reverbnation.com/alkilados/song/16965047-mona-lisa',
  10. 'md5': '3da12ebca28c67c111a7f8b262d3f7a7',
  11. 'info_dict': {
  12. "id": "16965047",
  13. "ext": "mp3",
  14. "title": "MONA LISA",
  15. "uploader": "ALKILADOS",
  16. "uploader_id": 216429,
  17. "thumbnail": "re:^https://gp1\.wac\.edgecastcdn\.net/.*?\.jpg$"
  18. },
  19. }]
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. song_id = mobj.group('id')
  23. api_res = self._download_json(
  24. 'https://api.reverbnation.com/song/%s?callback=api_response_5&_=%d'
  25. % (song_id, int(time.time() * 1000)),
  26. song_id,
  27. transform_source=strip_jsonp,
  28. note='Downloading information of song %s' % song_id
  29. )
  30. return {
  31. 'id': song_id,
  32. 'title': api_res.get('name'),
  33. 'url': api_res.get('url'),
  34. 'uploader': api_res.get('artist', {}).get('name'),
  35. 'uploader_id': api_res.get('artist', {}).get('id'),
  36. 'thumbnail': self._proto_relative_url(
  37. api_res.get('image', api_res.get('thumbnail'))),
  38. 'ext': 'mp3',
  39. 'vcodec': 'none',
  40. }