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.

45 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. 'file': '16965047.mp3',
  11. 'md5': '3da12ebca28c67c111a7f8b262d3f7a7',
  12. 'info_dict': {
  13. "title": "MONA LISA",
  14. "uploader": "ALKILADOS",
  15. "uploader_id": 216429,
  16. "thumbnail": "//gp1.wac.edgecastcdn.net/802892/production_public/Photo/13761700/image/1366002176_AVATAR_MONA_LISA.jpg"
  17. },
  18. }]
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. song_id = mobj.group('id')
  22. api_res = self._download_json(
  23. 'https://api.reverbnation.com/song/%s?callback=api_response_5&_=%d'
  24. % (song_id, int(time.time() * 1000)),
  25. song_id,
  26. transform_source=strip_jsonp,
  27. note='Downloading information of song %s' % song_id
  28. )
  29. return {
  30. 'id': song_id,
  31. 'title': api_res.get('name'),
  32. 'url': api_res.get('url'),
  33. 'uploader': api_res.get('artist', {}).get('name'),
  34. 'uploader_id': api_res.get('artist', {}).get('id'),
  35. 'thumbnail': api_res.get('image', api_res.get('thumbnail')),
  36. 'ext': 'mp3',
  37. 'vcodec': 'none',
  38. }