]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/streetvoice.py
Update changelog
[youtubedl] / youtube_dl / extractor / streetvoice.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_str
6 from ..utils import unified_strdate
7
8
9 class StreetVoiceIE(InfoExtractor):
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 'title': '輸',
18 'description': 'Crispy脆樂團 - 輸',
19 'thumbnail': r're:^https?://.*\.jpg$',
20 'duration': 260,
21 'upload_date': '20091018',
22 'uploader': 'Crispy脆樂團',
23 'uploader_id': '627810',
24 }
25 }, {
26 'url': 'http://tw.streetvoice.com/skippylu/songs/94440/',
27 'only_matching': True,
28 }]
29
30 def _real_extract(self, url):
31 song_id = self._match_id(url)
32
33 song = self._download_json(
34 'https://streetvoice.com/api/v1/public/song/%s/' % song_id, song_id, data=b'')
35
36 title = song['name']
37 author = song['user']['nickname']
38
39 return {
40 'id': song_id,
41 'url': song['file'],
42 'title': title,
43 'description': '%s - %s' % (author, title),
44 'thumbnail': self._proto_relative_url(song.get('image'), 'http:'),
45 'duration': song.get('length'),
46 'upload_date': unified_strdate(song.get('created_at')),
47 'uploader': author,
48 'uploader_id': compat_str(song['user']['id']),
49 }