source: titan/mediathek/localhoster/lib/youtube_dl/extractor/streetvoice.py @ 40094

Last change on this file since 40094 was 40094, checked in by obi, 7 years ago

tithek add yoztube-dl support

File size: 1.6 KB
Line 
1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
5from ..compat import compat_str
6from ..utils import unified_strdate
7
8
9class 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        }
Note: See TracBrowser for help on using the repository browser.