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