1 from .common
import InfoExtractor
12 class StreetVoiceIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:.+?\.)?streetvoice\.com/[^/]+/songs/(?P<id>[0-9]+)'
15 'url': 'https://streetvoice.com/skippylu/songs/123688/',
16 'md5': '0eb535970629a5195685355f3ed60bfd',
21 'description': 'md5:8eb0bfcc9dcd8aa82bd6efca66e3fea6',
22 'thumbnail': r
're:^https?://.*\.jpg',
24 'upload_date': '20100923',
25 'uploader': 'Crispy脆樂團',
26 'uploader_id': '627810',
27 'uploader_url': 're:^https?://streetvoice.com/skippylu/',
28 'timestamp': 1285261661,
38 'url': 'http://tw.streetvoice.com/skippylu/songs/94440/',
39 'only_matching': True,
42 def _real_extract(self
, url
):
43 song_id
= self
._match
_id
(url
)
44 base_url
= 'https://streetvoice.com/api/v4/song/%s/' % song_id
45 song
= self
._download
_json
(base_url
, song_id
, query
={
46 'fields': 'album,comments_count,created_at,id,image,length,likes_count,name,nickname,plays_count,profile,share_count,synopsis,user,username',
51 for suffix
, format_id
in [('hls/file', 'hls'), ('file', 'http'), ('file/original', 'original')]:
52 f_url
= (self
._download
_json
(
53 base_url
+ suffix
+ '/', song_id
,
54 'Downloading %s format URL' % format_id
,
55 data
=b
'', fatal
=False) or {}).get('file')
60 'format_id': format_id
,
64 if format_id
== 'hls':
65 f
['protocol'] = 'm3u8_native'
66 abr
= self
._search
_regex
(r
'\.mp3\.(\d+)k', f_url
, 'bitrate', default
=None)
75 user
= song
.get('user') or {}
76 username
= user
.get('username')
77 get_count
= lambda x
: int_or_none(song
.get(x
+ '_count'))
83 'description': strip_or_none(song
.get('synopsis')),
84 'thumbnail': song
.get('image'),
85 'duration': int_or_none(song
.get('length')),
86 'timestamp': parse_iso8601(song
.get('created_at')),
87 'uploader': try_get(user
, lambda x
: x
['profile']['nickname']),
88 'uploader_id': str_or_none(user
.get('id')),
89 'uploader_url': urljoin(url
, '/%s/' % username
) if username
else None,
90 'view_count': get_count('plays'),
91 'like_count': get_count('likes'),
92 'comment_count': get_count('comments'),
93 'repost_count': get_count('share'),
96 'album': try_get(song
, lambda x
: x
['album']['name']),