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.

44 lines
1.4 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import str_or_none
  5. class ReverbNationIE(InfoExtractor):
  6. _VALID_URL = r'^https?://(?:www\.)?reverbnation\.com/.*?/song/(?P<id>\d+).*?$'
  7. _TESTS = [{
  8. 'url': 'http://www.reverbnation.com/alkilados/song/16965047-mona-lisa',
  9. 'md5': '3da12ebca28c67c111a7f8b262d3f7a7',
  10. 'info_dict': {
  11. 'id': '16965047',
  12. 'ext': 'mp3',
  13. 'title': 'MONA LISA',
  14. 'uploader': 'ALKILADOS',
  15. 'uploader_id': '216429',
  16. 'thumbnail': 're:^https://gp1\.wac\.edgecastcdn\.net/.*?\.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' % song_id,
  24. song_id,
  25. note='Downloading information of song %s' % song_id
  26. )
  27. return {
  28. 'id': song_id,
  29. 'title': api_res.get('name'),
  30. 'url': api_res.get('url'),
  31. 'uploader': api_res.get('artist', {}).get('name'),
  32. 'uploader_id': str_or_none(api_res.get('artist', {}).get('id')),
  33. 'thumbnail': self._proto_relative_url(
  34. api_res.get('image', api_res.get('thumbnail'))),
  35. 'ext': 'mp3',
  36. 'vcodec': 'none',
  37. }