1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-29 21:52:54 +00:00

[qqmusic] Extract additional formats (mp3-128, mp3-320)

This commit is contained in:
ping 2015-06-04 17:41:29 +08:00
parent 4c8fea92f3
commit 55e5841f14

View file

@ -19,10 +19,10 @@ class QQMusicIE(InfoExtractor):
_VALID_URL = r'http://y.qq.com/#type=song&mid=(?P<id>[0-9A-Za-z]+)' _VALID_URL = r'http://y.qq.com/#type=song&mid=(?P<id>[0-9A-Za-z]+)'
_TESTS = [{ _TESTS = [{
'url': 'http://y.qq.com/#type=song&mid=004295Et37taLD', 'url': 'http://y.qq.com/#type=song&mid=004295Et37taLD',
'md5': 'bed90b6db2a7a7a7e11bc585f471f63a', 'md5': '9ce1c1c8445f561506d2e3cfb0255705',
'info_dict': { 'info_dict': {
'id': '004295Et37taLD', 'id': '004295Et37taLD',
'ext': 'm4a', 'ext': 'mp3',
'title': '可惜没如果', 'title': '可惜没如果',
'upload_date': '20141227', 'upload_date': '20141227',
'creator': '林俊杰', 'creator': '林俊杰',
@ -30,6 +30,12 @@ class QQMusicIE(InfoExtractor):
} }
}] }]
_FORMATS = {
'mp3-320': {'prefix': 'M800', 'ext': 'mp3', 'preference': 40},
'mp3-128': {'prefix': 'M500', 'ext': 'mp3', 'preference': 30},
'm4a': {'prefix': 'C200', 'ext': 'm4a', 'preference': 10}
}
# Reference: m_r_GetRUin() in top_player.js # Reference: m_r_GetRUin() in top_player.js
# http://imgcache.gtimg.cn/music/portal_v3/y/top_player.js # http://imgcache.gtimg.cn/music/portal_v3/y/top_player.js
@staticmethod @staticmethod
@ -69,11 +75,19 @@ class QQMusicIE(InfoExtractor):
'http://base.music.qq.com/fcgi-bin/fcg_musicexpress.fcg?json=3&guid=%s' % guid, 'http://base.music.qq.com/fcgi-bin/fcg_musicexpress.fcg?json=3&guid=%s' % guid,
mid, note='Retrieve vkey', errnote='Unable to get vkey', mid, note='Retrieve vkey', errnote='Unable to get vkey',
transform_source=strip_jsonp)['key'] transform_source=strip_jsonp)['key']
song_url = 'http://cc.stream.qqmusic.qq.com/C200%s.m4a?vkey=%s&guid=%s&fromtag=0' % (mid, vkey, guid)
formats = []
for k, sf in self._FORMATS.items():
formats.append({
'url': 'http://cc.stream.qqmusic.qq.com/%s%s.%s?vkey=%s&guid=%s&fromtag=0'
% (sf['prefix'], mid, sf['ext'], vkey, guid),
'format': k, 'format_id': k, 'preference': sf['preference']
})
self._sort_formats(formats)
return { return {
'id': mid, 'id': mid,
'url': song_url, 'formats': formats,
'title': song_name, 'title': song_name,
'upload_date': publish_time, 'upload_date': publish_time,
'creator': singer, 'creator': singer,