)
-class KuwoIE(InfoExtractor):
- IE_NAME = 'kuwo:song'
- _VALID_URL = r'http://www\.kuwo\.cn/yinyue/(?P<id>[0-9]+?)/'
- _TESTS = [{
- 'url': 'http://www.kuwo.cn/yinyue/635632/',
- 'info_dict': {
- 'id': '635632',
- 'ext': 'ape',
- 'title': '爱我别走',
- 'creator': '张震岳',
- 'upload_date': '20080122',
- 'description': 'md5:ed13f58e3c3bf3f7fd9fbc4e5a7aa75c'
- },
- }, {
- 'url': 'http://www.kuwo.cn/yinyue/6446136/',
- 'info_dict': {
- 'id': '6446136',
- 'ext': 'mp3',
- 'title': '心',
- 'creator': 'IU',
- 'upload_date': '20150518',
- },
- 'params': {
- 'format': 'mp3-320'
- },
- }]
+class KuwoBaseIE(InfoExtractor):
_FORMATS = [
{'format': 'ape', 'ext': 'ape', 'preference': 100},
{'format': 'mp3-320', 'ext': 'mp3', 'br': '320kmp3', 'abr': 320, 'preference': 80},
formats = []
for file_format in self._FORMATS:
song_url = self._download_webpage(
- "http://antiserver.kuwo.cn/anti.s?format=%s&br=%s&rid=MUSIC_%s&type=convert_url&response=url" %
+ 'http://antiserver.kuwo.cn/anti.s?format=%s&br=%s&rid=MUSIC_%s&type=convert_url&response=url' %
(file_format['ext'], file_format.get('br', ''), song_id),
- song_id, note="Download %s url info" % file_format["format"],
+ song_id, note='Download %s url info' % file_format['format'],
)
if song_url.startswith('http://') or song_url.startswith('https://'):
formats.append({
self._sort_formats(formats)
return formats
+
+class KuwoIE(KuwoBaseIE):
+ IE_NAME = 'kuwo:song'
+ _VALID_URL = r'http://www\.kuwo\.cn/yinyue/(?P<id>[0-9]+?)/'
+ _TESTS = [{
+ 'url': 'http://www.kuwo.cn/yinyue/635632/',
+ 'info_dict': {
+ 'id': '635632',
+ 'ext': 'ape',
+ 'title': '爱我别走',
+ 'creator': '张震岳',
+ 'upload_date': '20080122',
+ 'description': 'md5:ed13f58e3c3bf3f7fd9fbc4e5a7aa75c'
+ },
+ }, {
+ 'url': 'http://www.kuwo.cn/yinyue/6446136/',
+ 'info_dict': {
+ 'id': '6446136',
+ 'ext': 'mp3',
+ 'title': '心',
+ 'creator': 'IU',
+ 'upload_date': '20150518',
+ },
+ 'params': {
+ 'format': 'mp3-320'
+ },
+ }]
+
def _real_extract(self, url):
song_id = self._match_id(url)
webpage = self._download_webpage(
singer_name = self._html_search_regex(
r'<div[^>]+class="s_img">\s*<a[^>]+title="([^>]+)"',
webpage, 'singer name', default=None)
- lrc_content = clean_html(get_element_by_id("lrcContent", webpage))
+ lrc_content = clean_html(get_element_by_id('lrcContent', webpage))
if lrc_content == '暂无': # indicates no lyrics
lrc_content = None
publish_time = None
if album_id is not None:
album_info_page = self._download_webpage(
- "http://www.kuwo.cn/album/%s/" % album_id, song_id,
+ 'http://www.kuwo.cn/album/%s/' % album_id, song_id,
note='Download album detail info',
errnote='Unable to get album detail info')
r'<div[^>]+class="comm"[^<]+<h1[^>]+title="([^"]+)"', webpage,
'album name')
album_intro = remove_start(
- clean_html(get_element_by_id("intro", webpage)),
+ clean_html(get_element_by_id('intro', webpage)),
'%s简介:' % album_name)
entries = [
- 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(
r'<p[^>]+class="listen"><a[^>]+href="http://www\.kuwo\.cn/yinyue/(\d+)/"',
webpage)
r'<p[^>]+class="tabDef">(\d{4}第\d{2}期)</p>', webpage, 'chart desc')
entries = [
- 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(
r'<a[^>]+href="http://www\.kuwo\.cn/yinyue/(\d+)/"', webpage)
]
errnote='Unable to get song list page #%d' % page_num)
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(
r'<p[^>]+class="m_name"><a[^>]+href="http://www\.kuwo\.cn/yinyue/([0-9]+)/',
webpage)
r'<h1[^>]+title="([^<>]+?)">[^<>]+?</h1>', webpage, 'category name')
category_desc = remove_start(
- get_element_by_id("intro", webpage).strip(),
+ get_element_by_id('intro', webpage).strip(),
'%s简介:' % category_name)
jsonm = self._parse_json(self._html_search_regex(
entries = [
self.url_result(
- "http://www.kuwo.cn/yinyue/%s/" % song['musicrid'],
+ 'http://www.kuwo.cn/yinyue/%s/' % song['musicrid'],
'Kuwo', song['musicrid'])
for song in jsonm['musiclist']
]
return self.playlist_result(entries, category_id, category_name, category_desc)
-class KuwoMvIE(KuwoIE):
+class KuwoMvIE(KuwoBaseIE):
IE_NAME = 'kuwo:mv'
_VALID_URL = r'http://www\.kuwo\.cn/mv/(?P<id>[0-9]+?)/'
- _TESTS = [{
+ _TEST = {
'url': 'http://www.kuwo.cn/mv/6480076/',
'info_dict': {
'id': '6480076',
'title': '我们家MV',
'creator': '2PM',
},
- }]
- _FORMATS = KuwoIE._FORMATS + [
+ }
+ _FORMATS = KuwoBaseIE._FORMATS + [
{'format': 'mkv', 'ext': 'mkv', 'preference': 250},
{'format': 'mp4', 'ext': 'mp4', 'preference': 200},
]
song_name = mobj.group('song')
singer_name = mobj.group('singer')
else:
- raise ExtractorError("Unable to find song or singer names")
+ raise ExtractorError('Unable to find song or singer names')
formats = self._get_formats(song_id)