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.

51 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_str
  5. from ..utils import unified_strdate
  6. class StreetVoiceIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:.+?\.)?streetvoice\.com/[^/]+/songs/(?P<id>[0-9]+)'
  8. _TESTS = [{
  9. 'url': 'http://streetvoice.com/skippylu/songs/94440/',
  10. 'md5': '15974627fc01a29e492c98593c2fd472',
  11. 'info_dict': {
  12. 'id': '94440',
  13. 'ext': 'mp3',
  14. 'filesize': 4167053,
  15. 'title': '',
  16. 'description': 'Crispy脆樂團 - 輸',
  17. 'thumbnail': 're:^https?://.*\.jpg$',
  18. 'duration': 260,
  19. 'upload_date': '20091018',
  20. 'uploader': 'Crispy脆樂團',
  21. 'uploader_id': '627810',
  22. }
  23. }, {
  24. 'url': 'http://tw.streetvoice.com/skippylu/songs/94440/',
  25. 'only_matching': True,
  26. }]
  27. def _real_extract(self, url):
  28. song_id = self._match_id(url)
  29. song = self._download_json(
  30. 'http://streetvoice.com/music/api/song/%s' % song_id, song_id)
  31. title = song['name']
  32. author = song['musician']['name']
  33. return {
  34. 'id': song_id,
  35. 'url': song['file'],
  36. 'filesize': song.get('size'),
  37. 'title': title,
  38. 'description': '%s - %s' % (author, title),
  39. 'thumbnail': self._proto_relative_url(song.get('image'), 'http:'),
  40. 'duration': song.get('length'),
  41. 'upload_date': unified_strdate(song.get('created_at')),
  42. 'uploader': author,
  43. 'uploader_id': compat_str(song['musician']['id']),
  44. }