streetvoice.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class StreetVoiceIE(InfoExtractor):
  5. _VALID_URL = r'http://tw.streetvoice.com/[^/]+/songs/(?P<id>[0-9]+)/'
  6. _TESTS = [
  7. {
  8. 'url': 'http://tw.streetvoice.com/skippylu/songs/94440/',
  9. 'md5': '15974627fc01a29e492c98593c2fd472',
  10. 'info_dict': {
  11. 'id': '94440',
  12. 'ext': 'mp3',
  13. 'title': '輸',
  14. 'description': '輸 - Crispy脆樂團'
  15. }
  16. }
  17. ]
  18. def _real_extract(self, url):
  19. song_id = self._match_id(url)
  20. api_url = 'http://tw.streetvoice.com/music/api/song/%s/' % song_id
  21. info_dict = self._download_json(api_url, song_id)
  22. author = info_dict['musician']['name']
  23. title = info_dict['name']
  24. return {
  25. 'id': song_id,
  26. 'ext': 'mp3',
  27. 'title': title,
  28. 'url': info_dict['file'],
  29. 'description': '%s - %s' % (title, author)
  30. }