Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
yfang1644 committed Oct 21, 2017
1 parent 7557105 commit 254997d
Show file tree
Hide file tree
Showing 16 changed files with 579 additions and 867 deletions.
6 changes: 4 additions & 2 deletions addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,14 @@
</addon>

<addon id="plugin.audio.ximalaya"
name="喜马拉雅FM" version="1.0.3"
name="喜马拉雅FM" version="1.0.4"
provider-name="yfang1644">
<requires>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
<import addon="plugin.video.cntv-video" version="1.0.6"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>audio</provides>
</extension>
<extension point="xbmc.addon.metadata">
Expand Down
2 changes: 1 addition & 1 deletion addons.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
389f6f9169f11c6b7dd4a8dac519edd4 addons.xml
b1e1535347dd8e27867d6c27a40c348e addons.xml
5 changes: 1 addition & 4 deletions plugin.audio.baidu/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[B]1.0.1[/B] (2014/12/24 osfans)
- 修复中央台、北京台
- 已知问题:由于年代久远,很多链接已经失效,导致电台无法收听。

[B]1.0.0[/B]
2017.10.10
- 初始版本
2 changes: 0 additions & 2 deletions plugin.audio.baidu/default.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-

from xbmcswift2 import Plugin
from urllib import quote_plus
import urllib2
from json import loads
from common import get_html
from iqiyi import video_from_vid as IQIYI_from_vid
Expand Down
297 changes: 297 additions & 0 deletions plugin.audio.kuwo/addon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

from xbmcswift2 import Plugin
from urllib import urlencode
import re
from bs4 import BeautifulSoup
from common import get_html, match1

# Plugin constants

URL_BASE = 'http://yinyue.kuwo.cn'
BANNER_FMT = '[COLOR gold][%s][/COLOR]'
musicAPI = 'http://player.kuwo.cn/webmusic/st/getNewMuiseByRid?rid=MUSIC_'
sourceAPI = 'http://antiserver.kuwo.cn/anti.s?type=convert_url&response=url'

plugin = Plugin()

@plugin.route('/musiclist/<url>')
def musiclist(url):
plugin.set_content('music')
supported_stream_types = ['aac', 'wma', 'mp3']
if url.startswith('/'):
url = URL_BASE + url
html = get_html(url)
tree = BeautifulSoup(html, 'html.parser')
soup = tree.find_all('li', {'class': 'clearfix'})

for music in soup:
mid = music.input['mid']
title = music.find('p', {'class': 'm_name'})
title = title.text.strip()
albumname = music.find('p', {'class': 'a_name'})
albumname = albumname.text.strip()

html = get_html(musicAPI + mid)
iconimage = match1(html, '<artist_pic240>(.*)</artist_pic240>')
artist = match1(html, '<artist>(.*)</artist>')

for t in supported_stream_types:
url = get_html(sourceAPI + '&format={}&rid=MUSIC_{}'.format(t, mid))
if url:
break
yield {
'label': title +'-'+ albumname,
'thumbnail': iconimage,
'path': url,
'is_playable': True,
'info': {'title': title, 'artist': artist}
}

@plugin.route('/albumlist/<url>')
def albumlist(url):
html = get_html(URL_BASE + url)
tree = BeautifulSoup(html, "html.parser")
soup = tree.find_all('ul', {'class': 'singer_list clearfix'})
li = soup[0].find_all('li')

for item in li:
itemp = item.p.text
attr = 'albumlist' if u'列表' in itemp else 'musiclist'
name = item.a['title']
name = name + '(' + itemp + ')'
yield {
'label': name,
'path': plugin.url_for(attr, url=item.a['href']),
'thumbnail': item.img['lazy_src']
}

@plugin.route('/singeralbum/<url>/<id>/<page>')
def singeralbum(url, id, page):
plugin.set_content('music')
SINGER = 'http://www.kuwo.cn'
page = int(page)

yield {
'label': BANNER_FMT % u'专辑',
'path': plugin.url_for('singeralbum', url=url,id=id,page=page)
}

html = get_html(SINGER + url.replace(' ', '%20')) # some singer name has ' '
tree = BeautifulSoup(html, "html.parser")

print 'XXXXXXXXXXXXXXXXX', SINGER+url
# ALBUM #######################################
soup = tree.find_all('div', {'id': 'album'})
li = soup[0].find_all('li')
for album in li:
name = album.find('span', {'class': 'name'})
thumb = album.find('div', {'class': 'cover'})
image = thumb.img['src']
yield {
'label': name.text.strip(),
'path': plugin.url_for('musiclist', url=name.a['href']),
'thumbnail': str(image) # why is unicode not string??
}

# MV ###############################################
soup = tree.find_all('div', {'id': 'mv'})
li = soup[0].find_all('li')
yield {
'label': BANNER_FMT % u'MV',
'path': plugin.url_for('singeralbum', url=url, id=id, page=page)
}
for mv in li:
name = mv.find('span', {'class': 'name'})
html = get_html(name.a['href'])
mp4 = match1(html, 'var mp4url.+(http:.+?mp4)')
image = mv.find('div', {'class': 'cover'})
image = image.img['src']
yield {
'label': name.text.strip(),
'path': mp4,
'is_playable': True,
'thumbnail': str(image),
'info': {'title': name.text.strip()}
}

# SONGS ###############################################
aurl = 'http://www.kuwo.cn/artist/contentMusicsAjax'
aurl += '?artistId=%s&pn=%d&rn=15' % (id, page)
html = get_html(aurl)
yield {
'label': BANNER_FMT % u'单曲',
'path': plugin.url_for('singeralbum', url=url, id=id, page=page)
}
l = re.compile('"id":"MUSIC_(\d+)').findall(html)
maxpage = re.compile('data-page="(\d+)"').findall(html)
maxpage = int(maxpage[0])

tree = BeautifulSoup(html, 'html.parser')
soup = tree.find_all('li', {'class': 'onLine'})

if page > 0:
yield {
'label': BANNER_FMT % u'上一页',
'path': plugin.url_for('singeralbum', url=url, id=id, page=page-1)
}

for song in soup:
mid = re.compile('\d+').findall(song.a['href'])
mid = mid[0]
html = get_html(musicAPI + mid)
iconimage = match1(html, '<artist_pic240>(.*)</artist_pic240>')
artist = match1(html, '<artist>(.*)</artist>')

for t in ['aac', 'wma', 'mp3']:
url = get_html(sourceAPI + '&format={}&rid=MUSIC_{}'.format(t, mid))
if url:
break
yield {
'label': song.a.text,
'path': url,
'thumbnail': iconimage,
'is_playable': True,
'info': {'title': song.a.text, 'artist': artist}
}

if page < maxpage:
yield {
'label': BANNER_FMT % u'下一页',
'path': plugin.url_for('singeralbum', url=url, id=id, page=page+1)
}

@plugin.route('/singergroup/<url>/<page>/<letter>')
def singergroup(url, page, letter):
SINGER = 'http://www.kuwo.cn'
page = int(page)
cletter = letter if letter != '0' else ''
html = get_html(SINGER + url + cletter + '&pn='.format(page))
# pn=page number, prefix=alphabet, initial singer name
tree = BeautifulSoup(html, "html.parser")
soup = tree.find_all('div', {'class': 'artistTop'})

if page > 0:
yield {
'label': BANNER_FMT % u'上一页',
'path': plugin.url_for('singergroup', url=url, page=page-1, letter=letter)
}

for artist in soup:
aurl = artist.a['href'].encode('utf-8')
name = re.compile('name=(.+)').findall(aurl)
name = name[0]
artistid = artist.find('div', {'class': 'artistnav'})['data-id']
yield {
'label': name,
'path': plugin.url_for('singeralbum', url=aurl, id=artistid, page=0),
'thumbnail': artist.img['src']
}

soup = tree.find('div', {'class': 'page'})
maxpage = int(soup['data-page'])
if page < maxpage:
yield {
'label': BANNER_FMT % u'下一页',
'path': plugin.url_for('singergroup', url=url, page=page+1, letter=letter)
}

for abc in range(0x41, 0x5B): # A--Z
yield {
'label': chr(abc),
'path': plugin.url_for('singergroup', url=url, page=page, letter=chr(abc))
}

@plugin.route('/singerlist')
def singerlist():
html = get_html('http://www.kuwo.cn/artist/index')
tree = BeautifulSoup(html, "html.parser")
soup = tree.find_all('dl', {'class': 'area'})

for singer in soup:
yield {
'label': BANNER_FMT % singer.span.text,
'path': plugin.url_for('singerlist')
}
li = singer.find_all('dd')
for item in li:
url = item.a['href'].encode('utf-8')
yield {
'label': item.text.strip(),
'path': plugin.url_for('singergroup', url=url, page=0, letter='0')
}

@plugin.route('/sortitem/<url>')
def sortitem(url):
html = get_html(url)
tree = BeautifulSoup(html, "html.parser")
soup = tree.find_all('div', {'class': 'music clearfix'})

for item in soup:
yield {
'label': item.a['title'],
'path': plugin.url_for('musiclist', url=item.a['href']),
'thumbnail': item.img['lazy_src']
}

soup = tree.find_all('div', {'class': 'page'})
li = soup[0].find_all('a')

for item in li:
url = item['href']
curr = item.get('class', '')
if 'current' in curr:
continue
yield {
'label': item.text,
'path': plugin.url_for('sortitem', url=item['href'])
}

@plugin.route('/sortlist')
def sortlist():
html = get_html('http://www.kuwo.cn/album/')
tree = BeautifulSoup(html, "html.parser")
soup = tree.find_all('div', {'class': 'sdlist clearfix'})

for sdlist in soup:
yield {
'label': BANNER_FMT % sdlist.h1.text,
'path': plugin.url_for('sortlist')
}
li = sdlist.find_all('li')

for item in li:
yield {
'label': item.text,
'path': plugin.url_for('sortitem', url=item.a['href'])
}

@plugin.route('/category')
def category():
html = get_html(URL_BASE + '/category.htm')
tree = BeautifulSoup(html, "html.parser")
soup = tree.find_all('div', {'class': 'hotlist'})

for hotlist in soup:
yield {
'label': BANNER_FMT % hotlist.h1.text,
'path': plugin.url_for('category')
}
x = hotlist.find_all('ul', {'class': 'clearfix'})
li = x[0].find_all('li')

for item in li:
yield {
'label': item.text,
'path': plugin.url_for('albumlist', url=item.a['href'])
}

@plugin.route('/')
def root():
LIST = {u'分类': 'category', u'歌手': 'singerlist', u'专辑': 'sortlist'}
for item in LIST:
yield {'label': item, 'path': plugin.url_for(LIST[item])}

if __name__ == '__main__':
plugin.run()
3 changes: 2 additions & 1 deletion plugin.audio.kuwo/addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
version="2.2.4"
provider-name="yfang1644">
<requires>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
<import addon="plugin.video.cntv-video" version="1.0.6"/>
</requires>
<extension
point="xbmc.python.pluginsource" library="default.py">
point="xbmc.python.pluginsource" library="addon.py">
<provides>audio</provides>
</extension>
<extension point="xbmc.addon.metadata">
Expand Down
26 changes: 2 additions & 24 deletions plugin.audio.kuwo/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,2 @@
2017/06/23 yfang1644
href="#@"为当前页,跳过title

[B]2.2.1[/B] (2017/03/18 yfang1644)
- 从 yinyue.kuwo.cn/category.htm 起点

[B]2.2.0[/B] (2015/01/08 osfans)
- 添加搜索、曲风、标签

[B]2.1.0[/B] (2015/01/06 osfans)
- 添加排行榜

[B]2.0.0[/B] (2015/01/05 osfans)
- 独立模块
- 添加歌曲信息
- 添加歌手分类与图片
- 添加“随便一听”

[B]1.0.1[/B] (2014/12/17 osfans)
- 强制指定脚本编码格式为UTF-8,解决脚本运行错误
- 添加cookie,解决无法播放问题

[B]1.0.0[/B]
- 初始版本
2017.10.20
rewrite kuwo music plugin
Loading

0 comments on commit 254997d

Please sign in to comment.