]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/streetvoice.py
Fix "invalid escape sequences" error on Python 3.6
[yt-dlp.git] / youtube_dl / extractor / streetvoice.py
CommitLineData
c8dc41a6
YCH
1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
bb0aa4cb
S
5from ..compat import compat_str
6from ..utils import unified_strdate
c8dc41a6
YCH
7
8
9class 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',
bb0aa4cb
S
17 'title': '輸',
18 'description': 'Crispy脆樂團 - 輸',
ec85ded8 19 'thumbnail': r're:^https?://.*\.jpg$',
bb0aa4cb
S
20 'duration': 260,
21 'upload_date': '20091018',
22 'uploader': 'Crispy脆樂團',
23 'uploader_id': '627810',
c8dc41a6 24 }
bb0aa4cb
S
25 }, {
26 'url': 'http://tw.streetvoice.com/skippylu/songs/94440/',
27 'only_matching': True,
28 }]
c8dc41a6
YCH
29
30 def _real_extract(self, url):
31 song_id = self._match_id(url)
32
bb0aa4cb 33 song = self._download_json(
4dccea8a 34 'https://streetvoice.com/api/v1/public/song/%s/' % song_id, song_id, data=b'')
bb0aa4cb
S
35
36 title = song['name']
4dccea8a 37 author = song['user']['nickname']
c8dc41a6 38
c8dc41a6
YCH
39 return {
40 'id': song_id,
bb0aa4cb 41 'url': song['file'],
c8dc41a6 42 'title': title,
bb0aa4cb
S
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,
4dccea8a 48 'uploader_id': compat_str(song['user']['id']),
c8dc41a6 49 }