X-Git-Url: https://git.rapsys.eu/youtubedl/blobdiff_plain/7df4343e553a9942a290e5e1dffe931261ab844e..67afe88251ff8b1fcb43246c9a4bb1a0ea0185a2:/youtube_dl/extractor/qqmusic.py
diff --git a/youtube_dl/extractor/qqmusic.py b/youtube_dl/extractor/qqmusic.py
index 1311382..f773332 100644
--- a/youtube_dl/extractor/qqmusic.py
+++ b/youtube_dl/extractor/qqmusic.py
@@ -9,7 +9,6 @@ from .common import InfoExtractor
from ..utils import (
strip_jsonp,
unescapeHTML,
- js_to_json,
)
from ..compat import compat_urllib_request
@@ -26,7 +25,7 @@ class QQMusicIE(InfoExtractor):
'title': 'å¯æ没å¦æ',
'upload_date': '20141227',
'creator': 'æä¿æ°',
- 'description': 'md5:4348ff1dd24036906baa7b6f973f8d30',
+ 'description': 'md5:d327722d0361576fde558f1ac68a7065',
}
}]
@@ -60,6 +59,8 @@ class QQMusicIE(InfoExtractor):
lrc_content = self._html_search_regex(
r'
]*>([^<>]+)
',
detail_info_page, 'LRC lyrics', default=None)
+ if lrc_content:
+ lrc_content = lrc_content.replace('\\n', '\n')
guid = self.m_r_get_ruin()
@@ -179,60 +180,49 @@ class QQMusicToplistIE(QQPlaylistBaseIE):
_VALID_URL = r'http://y\.qq\.com/#type=toplist&p=(?P(top|global)_[0-9]+)'
_TESTS = [{
- 'url': 'http://y.qq.com/#type=toplist&p=global_12',
+ 'url': 'http://y.qq.com/#type=toplist&p=global_123',
'info_dict': {
- 'id': 'global_12',
- 'title': 'itunesæ¦',
+ 'id': 'global_123',
+ 'title': 'ç¾å½iTunesæ¦',
},
'playlist_count': 10,
}, {
- 'url': 'http://y.qq.com/#type=toplist&p=top_6',
+ 'url': 'http://y.qq.com/#type=toplist&p=top_3',
'info_dict': {
- 'id': 'top_6',
+ 'id': 'top_3',
'title': 'QQé³ä¹å·
å³°æ¦Â·æ¬§ç¾',
+ 'description': 'QQé³ä¹å·
å³°æ¦Â·æ¬§ç¾æ ¹æ®ç¨æ·æ¶å¬è¡ä¸ºèªå¨çæï¼éç»å½ä¸ææµè¡ç欧ç¾æ°æï¼:æ´æ°æ¶é´ï¼æ¯å¨å22ç¹|ç»'
+ '计å¨æï¼ä¸å¨ï¼ä¸å¨åè³æ¬å¨ä¸ï¼|ç»è®¡å¯¹è±¡ï¼ä¸ä¸ªæå
åè¡ç欧ç¾ææ²|ç»è®¡æ°éï¼100é¦|ç»è®¡ç®æ³ï¼æ ¹æ®'
+ 'ææ²å¨ä¸å¨å
çææææ¾æ¬¡æ°ï¼ç±é«å°ä½åå100åï¼åä¸æææå¤å
许5é¦ææ²åæ¶ä¸æ¦ï¼|ææææ¾æ¬¡æ°ï¼'
+ 'ç»å½ç¨æ·å®æ´ææ¾ä¸é¦ææ²ï¼è®°ä¸ºä¸æ¬¡ææææ¾ï¼åä¸ç¨æ·æ¶å¬åä¸é¦ææ²ï¼æ¯å¤©è®°å½ä¸º1次ææææ¾'
},
'playlist_count': 100,
}, {
- 'url': 'http://y.qq.com/#type=toplist&p=global_5',
+ 'url': 'http://y.qq.com/#type=toplist&p=global_106',
'info_dict': {
- 'id': 'global_5',
- 'title': 'é©å½mnetæè¡æ¦',
+ 'id': 'global_106',
+ 'title': 'é©å½Mnetæ¦',
},
'playlist_count': 50,
}]
- @staticmethod
- def strip_qq_jsonp(code):
- return js_to_json(re.sub(r'^MusicJsonCallback\((.*?)\)/\*.+?\*/$', r'\1', code))
-
def _real_extract(self, url):
list_id = self._match_id(url)
list_type, num_id = list_id.split("_")
- list_page = self._download_webpage(
- "http://y.qq.com/y/static/toplist/index/%s.html" % list_id,
- list_id, 'Download toplist page')
-
- entries = []
- if list_type == 'top':
- jsonp_url = "http://y.qq.com/y/static/toplist/json/top/%s/1.js" % num_id
- else:
- jsonp_url = "http://y.qq.com/y/static/toplist/json/global/%s/1_1.js" % num_id
-
toplist_json = self._download_json(
- jsonp_url, list_id, note='Retrieve toplist json',
- errnote='Unable to get toplist json', transform_source=self.strip_qq_jsonp)
-
- for song in toplist_json['l']:
- s = song['s']
- song_mid = s.split("|")[20]
- entries.append(self.url_result(
- 'http://y.qq.com/#type=song&mid=' + song_mid, 'QQMusic',
- song_mid))
+ 'http://i.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg?type=%s&topid=%s&format=json'
+ % (list_type, num_id),
+ list_id, 'Download toplist page')
- list_name = self._html_search_regex(
- r'([^\']+)
', list_page, 'top list name',
- default=None)
+ entries = [
+ self.url_result(
+ 'http://y.qq.com/#type=song&mid=' + song['data']['songmid'], 'QQMusic', song['data']['songmid']
+ ) for song in toplist_json['songlist']
+ ]
- return self.playlist_result(entries, list_id, list_name)
+ topinfo = toplist_json.get('topinfo', {})
+ list_name = topinfo.get('ListName')
+ list_description = topinfo.get('info')
+ return self.playlist_result(entries, list_id, list_name, list_description)