mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-01-07 17:16:08 +00:00
[kuwo] Merge KuwoSingerMusicIE into KuwoSingerIE (missed kuwo.py)
This commit is contained in:
parent
2b0fa1f7dd
commit
1633491bff
|
@ -180,15 +180,22 @@ class KuwoChartIE(InfoExtractor):
|
||||||
|
|
||||||
class KuwoSingerIE(InfoExtractor):
|
class KuwoSingerIE(InfoExtractor):
|
||||||
IE_NAME = 'kuwo:singer'
|
IE_NAME = 'kuwo:singer'
|
||||||
_VALID_URL = r'http://www\.kuwo\.cn/mingxing/(?P<id>[^/]+?)/$'
|
_VALID_URL = r'http://www\.kuwo\.cn/mingxing/(?P<id>[^/]+)'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
'url': 'http://www.kuwo.cn/mingxing/bruno+mars/',
|
'url': 'http://www.kuwo.cn/mingxing/bruno+mars/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'bruno+mars',
|
'id': 'bruno+mars',
|
||||||
'title': 'Bruno Mars',
|
'title': 'Bruno Mars',
|
||||||
},
|
},
|
||||||
'playlist_count': 10,
|
'playlist_count': 10,
|
||||||
}
|
}, {
|
||||||
|
'url': 'http://www.kuwo.cn/mingxing/Ali/music.htm',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'Ali',
|
||||||
|
'title': 'Ali',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 95,
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
singer_id = self._match_id(url)
|
singer_id = self._match_id(url)
|
||||||
|
@ -197,54 +204,28 @@ class KuwoSingerIE(InfoExtractor):
|
||||||
errnote='Unable to get singer info')
|
errnote='Unable to get singer info')
|
||||||
|
|
||||||
singer_name = self._html_search_regex(
|
singer_name = self._html_search_regex(
|
||||||
r'姓名:<span>(.+?)</span>', webpage, 'singer name')
|
r'<div class="title clearfix">[\n\s\t]*?<h1>(.+?)<span', 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'<a href="http://www\.kuwo\.cn/yinyue/([0-9]+)/" .+?>.+?</a>',
|
|
||||||
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<id>[^/]+?)/music(_[0-9]+)?.htm'
|
|
||||||
_TEST = {
|
|
||||||
'url': 'http://www.kuwo.cn/mingxing/Ali/music.htm',
|
|
||||||
'info_dict': {
|
|
||||||
'id': 'Ali',
|
|
||||||
'title': 'Ali的热门歌曲',
|
|
||||||
},
|
|
||||||
'playlist_mincount': 95,
|
|
||||||
}
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
|
||||||
singer_id = self._match_id(url)
|
|
||||||
|
|
||||||
list_name = None
|
|
||||||
entries = []
|
entries = []
|
||||||
|
first_page_only = False if re.match(r'.+/music(?:_[0-9]+)?\.htm', url) else True
|
||||||
for page_num in itertools.count(1):
|
for page_num in itertools.count(1):
|
||||||
webpage = self._download_webpage(
|
webpage = self._download_webpage(
|
||||||
'http://www.kuwo.cn/mingxing/%s/music_%d.htm' % (singer_id, page_num),
|
'http://www.kuwo.cn/mingxing/%s/music_%d.htm' % (singer_id, page_num),
|
||||||
singer_id, note='Download song list page #%d' % page_num,
|
singer_id, note='Download song list page #%d' % page_num,
|
||||||
errnote='Unable to get song list page #%d' % page_num)
|
errnote='Unable to get song list page #%d' % page_num)
|
||||||
|
|
||||||
if list_name is None:
|
|
||||||
list_name = self._html_search_regex(
|
|
||||||
r'<h1>([^<>]+)<span>', webpage, 'list name')
|
|
||||||
|
|
||||||
entries.extend([
|
entries.extend([
|
||||||
self.url_result("http://www.kuwo.cn/yinyue/%s/" % song_id, 'Kuwo', song_id)
|
self.url_result("http://www.kuwo.cn/yinyue/%s/" % song_id, 'Kuwo', song_id)
|
||||||
for song_id in re.findall(
|
for song_id in re.findall(
|
||||||
r'<p class="m_name"><a href="http://www\.kuwo\.cn/yinyue/([0-9]+)/',
|
r'<p class="m_name"><a href="http://www\.kuwo\.cn/yinyue/([0-9]+)/',
|
||||||
webpage)
|
webpage)
|
||||||
])
|
][:10 if first_page_only else None])
|
||||||
if not re.search(r'<a href="[^"]+">下一页</a>', webpage):
|
|
||||||
|
if first_page_only or not re.search(r'<a href="[^"]+">下一页</a>', webpage):
|
||||||
break
|
break
|
||||||
|
|
||||||
return self.playlist_result(entries, singer_id, list_name)
|
return self.playlist_result(entries, singer_id, singer_name)
|
||||||
|
|
||||||
|
|
||||||
class KuwoCategoryIE(InfoExtractor):
|
class KuwoCategoryIE(InfoExtractor):
|
||||||
|
|
Loading…
Reference in a new issue