Merge pull request #4758 from yan12125/IE_streetvoice
[youtube-dl] / youtube_dl / extractor / streetvoice.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class StreetVoiceIE(InfoExtractor):
8     _VALID_URL = r'http://tw.streetvoice.com/[^/]+/songs/(?P<id>[0-9]+)/'
9     _TESTS = [
10         {
11             'url': 'http://tw.streetvoice.com/skippylu/songs/94440/',
12             'md5': '15974627fc01a29e492c98593c2fd472',
13             'info_dict': {
14                 'id': '94440',
15                 'ext': 'mp3',
16                 'title': '輸',
17                 'description': '輸 - Crispy脆樂團'
18             }
19         }
20     ]
21
22     def _real_extract(self, url):
23         song_id = self._match_id(url)
24
25         api_url = 'http://tw.streetvoice.com/music/api/song/%s/' % song_id
26         info_dict = self._download_json(api_url, song_id)
27
28         author = info_dict['musician']['name']
29         title = info_dict['name']
30         return {
31             'id': song_id,
32             'ext': 'mp3',
33             'title': title,
34             'url': info_dict['file'],
35             'description': '%s - %s' % (title, author)
36         }