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.

49 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. 'title': '',
  15. 'description': 'Crispy脆樂團 - 輸',
  16. 'thumbnail': 're:^https?://.*\.jpg$',
  17. 'duration': 260,
  18. 'upload_date': '20091018',
  19. 'uploader': 'Crispy脆樂團',
  20. 'uploader_id': '627810',
  21. }
  22. }, {
  23. 'url': 'http://tw.streetvoice.com/skippylu/songs/94440/',
  24. 'only_matching': True,
  25. }]
  26. def _real_extract(self, url):
  27. song_id = self._match_id(url)
  28. song = self._download_json(
  29. 'https://streetvoice.com/api/v1/public/song/%s/' % song_id, song_id, data=b'')
  30. title = song['name']
  31. author = song['user']['nickname']
  32. return {
  33. 'id': song_id,
  34. 'url': song['file'],
  35. 'title': title,
  36. 'description': '%s - %s' % (author, title),
  37. 'thumbnail': self._proto_relative_url(song.get('image'), 'http:'),
  38. 'duration': song.get('length'),
  39. 'upload_date': unified_strdate(song.get('created_at')),
  40. 'uploader': author,
  41. 'uploader_id': compat_str(song['user']['id']),
  42. }