From 1633491bff3e393d7d095b7303f954dacce4f4da Mon Sep 17 00:00:00 2001 From: ping Date: Fri, 10 Jul 2015 15:19:07 +0800 Subject: [PATCH] [kuwo] Merge KuwoSingerMusicIE into KuwoSingerIE (missed kuwo.py) --- youtube_dl/extractor/kuwo.py | 53 ++++++++++++------------------------ 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/youtube_dl/extractor/kuwo.py b/youtube_dl/extractor/kuwo.py index 6a96a1aa4..82d5f3f95 100644 --- a/youtube_dl/extractor/kuwo.py +++ b/youtube_dl/extractor/kuwo.py @@ -180,71 +180,52 @@ class KuwoChartIE(InfoExtractor): class KuwoSingerIE(InfoExtractor): IE_NAME = 'kuwo:singer' - _VALID_URL = r'http://www\.kuwo\.cn/mingxing/(?P[^/]+?)/$' - _TEST = { + _VALID_URL = r'http://www\.kuwo\.cn/mingxing/(?P[^/]+)' + _TESTS = [{ 'url': 'http://www.kuwo.cn/mingxing/bruno+mars/', 'info_dict': { 'id': 'bruno+mars', 'title': 'Bruno Mars', }, 'playlist_count': 10, - } - - def _real_extract(self, url): - singer_id = self._match_id(url) - webpage = self._download_webpage( - url, singer_id, note='Download singer info', - errnote='Unable to get singer info') - - singer_name = self._html_search_regex( - r'姓名:(.+?)', webpage, 'singer name') - - entries = [ - self.url_result("http://www.kuwo.cn/yinyue/%s/" % song_id, 'Kuwo', song_id) - for song_id in re.findall( - r'.+?', - webpage, flags=re.DOTALL) - ] - return self.playlist_result(entries, singer_id, singer_name) - - -class KuwoSingerMusicIE(InfoExtractor): - IE_NAME = 'kuwo:singermusic' - _VALID_URL = r'http://www\.kuwo\.cn/mingxing/(?P[^/]+?)/music(_[0-9]+)?.htm' - _TEST = { + }, { 'url': 'http://www.kuwo.cn/mingxing/Ali/music.htm', 'info_dict': { 'id': 'Ali', - 'title': 'Ali的热门歌曲', + 'title': 'Ali', }, 'playlist_mincount': 95, - } + }] def _real_extract(self, url): singer_id = self._match_id(url) + webpage = self._download_webpage( + url, singer_id, note='Download singer info', + errnote='Unable to get singer info') + + singer_name = self._html_search_regex( + r'
[\n\s\t]*?

(.+?)([^<>]+)', webpage, 'list name') - entries.extend([ self.url_result("http://www.kuwo.cn/yinyue/%s/" % song_id, 'Kuwo', song_id) for song_id in re.findall( r'

下一页', webpage): + ][:10 if first_page_only else None]) + + if first_page_only or not re.search(r'下一页', webpage): break - return self.playlist_result(entries, singer_id, list_name) + return self.playlist_result(entries, singer_id, singer_name) class KuwoCategoryIE(InfoExtractor):