diff --git a/addons.xml b/addons.xml index 4a7ee0e..e99d066 100644 --- a/addons.xml +++ b/addons.xml @@ -165,9 +165,12 @@ - + version="1.0.0" + provider-name="yfang1644"> + + + + audio @@ -229,8 +232,11 @@ - + provider-name="yfang1644"> + + + + audio diff --git a/addons.xml.md5 b/addons.xml.md5 index fe73a4e..13cb491 100644 --- a/addons.xml.md5 +++ b/addons.xml.md5 @@ -1 +1 @@ -b1e1535347dd8e27867d6c27a40c348e addons.xml +14f423fbec943540d4b2e2adb14c3cce addons.xml diff --git a/plugin.audio.kugoufm/addon.py b/plugin.audio.kugoufm/addon.py new file mode 100644 index 0000000..986e8eb --- /dev/null +++ b/plugin.audio.kugoufm/addon.py @@ -0,0 +1,118 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from xbmcswift2 import Plugin +import time + +BANNER_PAGE = '[COLOR gold]%s[/COLOR]' + +plugin = Plugin() +url_for = plugin.url_for + +userAgent = 'Opera/9.80 (Android 2.3.4; Linux; Opera Mobi/build-1107180945; U; en-GB) Presto/2.8.149 Version/11.10' +HOST_URL = 'http://m.kugou.com' +headers = {'User-Agent': userAgent, 'Referer': HOST_URL} + +def getHttpData(u, query): + import urllib2 + import json + from urllib import urlencode + + url = '%s/app/i/%s?%s' % (HOST_URL, u, urlencode(query)) + req = urllib2.Request(url, headers=headers) + response = urllib2.urlopen(req) + httpdata = response.read() + response.close() + return json.loads(httpdata) + +def getSingerPic(title, size=200): + import re + # 根据歌手获得相应的信息 + singerList = re.findall('(【.*?】)?(.*?)-', title) + if singerList: + query = {'singerName': singerList[0][1], + 'size': size, + 'd': time.time()*1000} + singerUrl = 'getSingerHead_new.php' + singerJson = getHttpData(singerUrl, query) + return singerJson.get('url', '') + return '' + + +def getSongInfo(hashId): + #根据hash 获得mp3的相应信息 + query = {'hash': hashId, 'cmd': 'playInfo'} + songUrl = 'getSongInfo.php' + songJson = getHttpData(songUrl, query) + return songJson['url'] + + +#http://m.kugou.com/app/i/fmSongs.php?fmid=891&size=30 +def getSongs(fmid, t=None, size=30): + #只选取前80首歌(可以查询的歌曲相当的多!!!) 返回的是相应的json + listUrl = 'fmSongs.php' + offset = {"time": int(t if t else time.time())} + query = {'fmid': str(fmid), 'offset': str(offset),'size': size} + listJson = getHttpData(listUrl, query) + return listJson['data'][0]['songs'] + + +#http://m.kugou.com/app/i/fmList.php?pageindex=1&pagesize=30 +def getFmList(page, pagesize=30): + #获得酷狗Fm列表 json + query = {'pageindex': page, 'pagesize': pagesize} + url = 'fmList.php' + reqJson = getHttpData(url, query) + return reqJson + + +# 获得相应电台的歌曲的列表 +@plugin.route('/getPlayList/') +def getPlayList(fmid): + plugin.set_content('music') + t = int(time.time()) + songs = getSongs(fmid, t) + # 判断songs是否存在 + if not songs: return [] + items = [{ + 'label': song['name'], + 'path': getSongInfo(song['hash']), + 'is_playable': True, + 'info': {'title': song['name'], 'duration': song['time']/1000} + } for song in songs] + + return items + +@plugin.route('/') +def index(page=1): + currpage = int(page) + pagesize = 30 + lists = getFmList(page, pagesize) + totalPages = (lists['recordcount']-1)//pagesize + 1 + items = [] + for i in lists['data']: + items.append({ + 'label': i['fmname'], + 'path': url_for('getPlayList', fmid=i['fmid']), + 'thumbnail': 'http://imge.kugou.com/fmlogo/145/%s' % i['imgurl'], + 'icon': 'http://imge.kugou.com/fmlogo/145/%s' % i['imgurl'], + 'info': {'title': i['fmname']} + }) + + # 设置分页 + if currpage > 1: + linkpage = currpage - 1 + items.append({ + 'label': '上一页 【[COLOR FF00FF00]%s[/COLOR]/[COLOR FFFF0000]%s[/COLOR]】'%(linkpage,totalPages), + 'path': url_for('index',page=linkpage) + }) + if currpage < totalPages: + linkpage = currpage + 1 + items.append({ + 'label': '下一页 【[COLOR FF00FF00]%s[/COLOR]/[COLOR FFFF0000]%s[/COLOR]】'%(linkpage,totalPages), + 'path': url_for('index',page=linkpage) + }) + return items + +if __name__ == '__main__': + plugin.run() diff --git a/plugin.audio.kugoufm/addon.xml b/plugin.audio.kugoufm/addon.xml index 3771cba..555c86f 100644 --- a/plugin.audio.kugoufm/addon.xml +++ b/plugin.audio.kugoufm/addon.xml @@ -2,8 +2,11 @@ - + provider-name="yfang1644"> + + + + audio diff --git a/plugin.audio.kugoufm/changelog.txt b/plugin.audio.kugoufm/changelog.txt index bc69774..9d31ed7 100644 --- a/plugin.audio.kugoufm/changelog.txt +++ b/plugin.audio.kugoufm/changelog.txt @@ -1,11 +1,2 @@ -[B]1.0.1[/B] 2015/1/3 osfans -- 修正无法获取歌手照片导致的脚本错误 - -[B]1.0.0[/B] 2014/12 osfans -- 歌手照片 电台图标 -- 所有电台 -- 动态歌曲列表,加速载入列表 - -[B]0.0.1[/B] 2013/10 keygle -- 插件实现的都是基本功能,连歌手、歌手图片也没提供; -- 音频来源于酷狗的html5版,格式为m4a,感觉比mp3差点,连接速度还行。 +[B]1.0.1[/B] 2017.10.22 +- 基于 osfans 版本,重写函数结构 diff --git a/plugin.audio.kugoufm/default.py b/plugin.audio.kugoufm/default.py deleted file mode 100644 index e044fc5..0000000 --- a/plugin.audio.kugoufm/default.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -import xbmc -import xbmcplugin -import xbmcgui -import kugou -import sys -import urlparse -import urllib -import time - - -# 显示 酷狗FM 的相应的专辑 -def index(page): - currpage = int(page) - pagesize = 30 - lists = kugou.getFmList(page, pagesize) - totalPages = (lists['recordcount']-1)//pagesize + 1 - for i in lists['data']: - li = xbmcgui.ListItem(i['fmname']) - li.setInfo(type="Music", infoLabels={"Title": i['fmname']}) - icon = 'http://imge.kugou.com/fmlogo/145/%s' % i['imgurl'] - li.setIconImage(icon) - query = {'act': 'list', 'fmid': i['fmid'], 'icon': icon} - url = "%s?%s" % (plugin_url, urllib.urlencode(query)) - xbmcplugin.addDirectoryItem(handle, url, li, True) - # 设置分页 - if currpage > 1: - linkpage = currpage - 1 - prevLi = xbmcgui.ListItem('上一页 【[COLOR FF00FF00]%s[/COLOR]/[COLOR FFFF0000]%s[/COLOR]】'%(linkpage,totalPages)) - u = "%s?act=index&page=%s" % (plugin_url, linkpage) - xbmcplugin.addDirectoryItem(handle, u, prevLi, True) - if currpage < totalPages: - linkpage = currpage + 1 - nextLi = xbmcgui.ListItem('下一页 【[COLOR FF00FF00]%s[/COLOR]/[COLOR FFFF0000]%s[/COLOR]】'%(linkpage,totalPages)) - u = "%s?act=index&page=%s" % (plugin_url, linkpage) - xbmcplugin.addDirectoryItem(handle, u, nextLi, True) - xbmcplugin.endOfDirectory(handle) - - -# 获得相应电台的歌曲的列表 -def getPlayList(fmid, icon): - title = '播放当前专辑所有歌曲' - listitemAll = xbmcgui.ListItem(title, iconImage=icon) - listitemAll.setInfo(type="Music", infoLabels={"Title": title}) - t = int(time.time()) - query = {'act': 'playList', 'fmid': fmid, 'time': t} - listUrl = '%s?%s' % (plugin_url, urllib.urlencode(query)) - xbmcplugin.addDirectoryItem(handle, listUrl, listitemAll, False) - songs = kugou.getSongs(fmid, t) - # 判断songs是否存在 - if songs: - for song in songs: - listitem = xbmcgui.ListItem(song['name']) - listitem.setInfo(type="Music", infoLabels={"Title": song['name'], }) - url = plugin_url+"?act=play&title="+song['name'].encode('utf-8')+"&hash="+urllib.quote_plus(song['hash'].encode('utf-8')) - xbmcplugin.addDirectoryItem(handle, url, listitem, False) - xbmcplugin.endOfDirectory(handle) - - -#播放当前Fm列表里的歌曲 -def playList(fmid, t): - playlist = xbmc.PlayList(0) - playlist.clear() - for song in kugou.getSongs(fmid, t): - listitem = xbmcgui.ListItem(song['name']) - listitem.setInfo(type="Music", infoLabels={"Title": song['name']}) - playlist.add(kugou.getSongInfo(song['hash']), listitem) - xbmc.Player().play(playlist) - - -# 播放音乐 -def play(hashId, title): - playlist = xbmc.PlayList(0) - playlist.clear() # 中止播放列表 - xbmc.Player().stop() - mp3path = kugou.getSongInfo(hashId) - icon = kugou.getSingerPic(title, 100) - thumbnail = kugou.getSingerPic(title, 200) - listitem=xbmcgui.ListItem(title, iconImage=icon, thumbnailImage=thumbnail) - listitem.setInfo(type="Music", infoLabels={"Title": title}) - xbmc.Player().play(mp3path, listitem) - -plugin_url = sys.argv[0] -handle = int(sys.argv[1]) -params = sys.argv[2][1:] -params = dict(urlparse.parse_qsl(params)) - -act = params.get('act', 'index') -fmid = params.get("fmid", '') - -if act == 'index': - page = params.get("page", 1) - index(page) -elif act == 'list': - icon = params.get('icon', '') - getPlayList(fmid, icon) -elif act == 'playList': - t = params.get('time', 0) - playList(fmid, t) -elif act == 'play': - hashId = urllib.unquote_plus(params['hash']) - title = params.get('title', '') - play(hashId, title) diff --git a/plugin.audio.kugoufm/kugou.py b/plugin.audio.kugoufm/kugou.py deleted file mode 100644 index 130c379..0000000 --- a/plugin.audio.kugoufm/kugou.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import urllib2 -import urllib -import re -import json -import time - -userAgent = 'Opera/9.80 (Android 2.3.4; Linux; Opera Mobi/build-1107180945; U; en-GB) Presto/2.8.149 Version/11.10' -homepage = 'http://m.kugou.com' -headers = {'User-Agent': userAgent, 'Referer': homepage} - - -def getHttpData(u, query): - url = '%s/app/i/%s?%s' % (homepage, u, urllib.urlencode(query)) - req = urllib2.Request(url, headers=headers) - response = urllib2.urlopen(req) - httpdata = response.read() - response.close() - return httpdata - - -def getSingerPic(title, size=200): - # 根据歌手获得相应的信息 - singerList = re.findall('(【.*?】)?(.*?)-', title) - if singerList: - query = {'singerName': singerList[0][1], - 'size': size, - 'd': time.time()*1000} - singerUrl = 'getSingerHead_new.php' - singerInfo = getHttpData(singerUrl, query) - return json.loads(singerInfo).get('url', '') - return '' - - -def getSongInfo(hashId): - #根据hash 获得mp3的相应信息 - query = {'hash': hashId, 'cmd': 'playInfo'} - songUrl = 'getSongInfo.php' - songStr = getHttpData(songUrl, query) - songJson = json.loads(songStr) - return songJson['url'] - - -def getSongs(fmid, t=None, size=30): - #只选取前80首歌(可以查询的歌曲相当的多!!!) 返回的是相应的json - listUrl = 'fmSongs.php' - offset = {"time": int(t if t else time.time())} - query = {'fmid': str(fmid), 'offset': str(offset),'size': size} - listStr = getHttpData(listUrl, query) - listJson = json.loads(listStr) - return listJson['data'][0]['songs'] - - -def getFmList(page, pagesize=30): - #获得酷狗Fm列表 json - query = {'pageindex': page, 'pagesize': pagesize} - url = 'fmList.php' - reqStr = getHttpData(url, query) - reqJson = json.loads(reqStr) - return reqJson - -if __name__ == '__main__': - getSingerPic(" ") diff --git a/plugin.audio.kugoufm/plugin.audio.kugoufm-1.0.1.zip b/plugin.audio.kugoufm/plugin.audio.kugoufm-1.0.1.zip index f5712cd..73c6381 100644 Binary files a/plugin.audio.kugoufm/plugin.audio.kugoufm-1.0.1.zip and b/plugin.audio.kugoufm/plugin.audio.kugoufm-1.0.1.zip differ diff --git a/plugin.audio.kuwo/addon.py b/plugin.audio.kuwo/addon.py index f940768..a3567d5 100644 --- a/plugin.audio.kuwo/addon.py +++ b/plugin.audio.kuwo/addon.py @@ -2,10 +2,9 @@ # -*- coding: utf-8 -*- from xbmcswift2 import Plugin -from urllib import urlencode import re from bs4 import BeautifulSoup -from common import get_html, match1 +from common import get_html, r1 # Plugin constants @@ -16,6 +15,10 @@ plugin = Plugin() +@plugin.route('/stay') +def stay(): + pass + @plugin.route('/musiclist/') def musiclist(url): plugin.set_content('music') @@ -26,28 +29,54 @@ def musiclist(url): tree = BeautifulSoup(html, 'html.parser') soup = tree.find_all('li', {'class': 'clearfix'}) + musicList = [] + mvList = [] 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() + song = music.find_all('p', {'class': ['m_name','a_name','video']}) + title = song[0].a.text + albumname = song[1].a.text html = get_html(musicAPI + mid) - iconimage = match1(html, '(.*)') - artist = match1(html, '(.*)') + iconimage = r1('(.*)', html) + artist = r1('(.*)', html) for t in supported_stream_types: url = get_html(sourceAPI + '&format={}&rid=MUSIC_{}'.format(t, mid)) if url: + musicList.append({ + 'label': title +'-'+ albumname, + 'path': url, + 'thumbnail': iconimage, + 'is_playable': True, + 'info': {'title': title, 'artist': artist} + }) break - yield { - 'label': title +'-'+ albumname, - 'thumbnail': iconimage, - 'path': url, - 'is_playable': True, - 'info': {'title': title, 'artist': artist} - } + + if song[2].a is not None: + html = get_html(mv.a['href']) + mp4 = r1('var mp4url.+(http:.+?mp4)', html) + mvList.append({ + 'label': title +'-'+ albumname, + 'path': mp4, + 'is_playable': True, + 'thumbnail': iconimage, + 'info': {'title': title, 'artist': artist} + }) + + if len(musicList) > 0: + musicList.insert(0, { + 'label': BANNER_FMT % u'音乐', + 'path': plugin.url_for('stay') + }) + + if len(mvList) > 0: + mvList.insert(0, { + 'label': BANNER_FMT % u'MV', + 'path': plugin.url_for('stay') + }) + + return musicList + mvList @plugin.route('/albumlist/') def albumlist(url): @@ -75,13 +104,12 @@ def singeralbum(url, id, page): yield { 'label': BANNER_FMT % u'专辑', - 'path': plugin.url_for('singeralbum', url=url,id=id,page=page) + 'path': plugin.url_for('stay') } 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') @@ -100,12 +128,12 @@ def singeralbum(url, id, page): li = soup[0].find_all('li') yield { 'label': BANNER_FMT % u'MV', - 'path': plugin.url_for('singeralbum', url=url, id=id, page=page) + 'path': plugin.url_for('stay') } for mv in li: name = mv.find('span', {'class': 'name'}) html = get_html(name.a['href']) - mp4 = match1(html, 'var mp4url.+(http:.+?mp4)') + mp4 = r1('var mp4url.+(http:.+?mp4)', html) image = mv.find('div', {'class': 'cover'}) image = image.img['src'] yield { @@ -117,13 +145,13 @@ def singeralbum(url, id, page): } # 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) + 'path': plugin.url_for('stay') } + aurl = 'http://www.kuwo.cn/artist/contentMusicsAjax' + aurl += '?artistId=%s&pn=%d&rn=15' % (id, page) + html = get_html(aurl) l = re.compile('"id":"MUSIC_(\d+)').findall(html) maxpage = re.compile('data-page="(\d+)"').findall(html) maxpage = int(maxpage[0]) @@ -141,8 +169,8 @@ def singeralbum(url, id, page): mid = re.compile('\d+').findall(song.a['href']) mid = mid[0] html = get_html(musicAPI + mid) - iconimage = match1(html, '(.*)') - artist = match1(html, '(.*)') + iconimage = r1('(.*)', html) + artist = r1('(.*)', html) for t in ['aac', 'wma', 'mp3']: url = get_html(sourceAPI + '&format={}&rid=MUSIC_{}'.format(t, mid)) @@ -212,7 +240,7 @@ def singerlist(): for singer in soup: yield { 'label': BANNER_FMT % singer.span.text, - 'path': plugin.url_for('singerlist') + 'path': plugin.url_for('stay') } li = singer.find_all('dd') for item in li: @@ -257,7 +285,7 @@ def sortlist(): for sdlist in soup: yield { 'label': BANNER_FMT % sdlist.h1.text, - 'path': plugin.url_for('sortlist') + 'path': plugin.url_for('stay') } li = sdlist.find_all('li') @@ -276,7 +304,7 @@ def category(): for hotlist in soup: yield { 'label': BANNER_FMT % hotlist.h1.text, - 'path': plugin.url_for('category') + 'path': plugin.url_for('stay') } x = hotlist.find_all('ul', {'class': 'clearfix'}) li = x[0].find_all('li') diff --git a/plugin.audio.radiocn/addon.py b/plugin.audio.radiocn/addon.py new file mode 100644 index 0000000..2d3ea4b --- /dev/null +++ b/plugin.audio.radiocn/addon.py @@ -0,0 +1,191 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from xbmcswift2 import Plugin +from urllib import urlencode +import urllib2 +from json import loads + +BaseHtml = 'http://www.radio.cn/pc-portal/erji' +BaseAPI = 'http://tacc.radio.cn/pcpages' +BANNER_FMT = '[B][COLOR gold][%s][/COLOR][/B]' + +UserAgent = "Mozilla/5.0 (X11; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0" +headers = {"Host": "www.radio.cn", + "User-Agent": UserAgent, + "Referer": "http://www.radio.cn/index.php?option=default,radio"} + +plugin = Plugin() +url_for = plugin.url_for + +def request(url, js=True): + print('request', url) + req = urllib2.Request(url) + response = urllib2.urlopen(req) + cont = response.read() + response.close() + if js: + cont = loads(cont.strip("()")) + return cont + +@plugin.route('/stay') +def stay(): + pass + +@plugin.route('/station//') +def station(place_id, type_id): + #name, mode, icon, area, type + plugin.set_content('video') + req = { + 'place_id': '' if place_id == '0' else place_id, + 'type_id': '' if type_id == '0' else type_id + } + c = request(BaseAPI+'/radiopages?' + urlencode(req)) + items = [] + + items.append({ + 'label': BANNER_FMT % '地区', + 'path': plugin.url_for('stay') + }) + for place in c['data']['place']: + items.append({ + 'label': place['name'], + 'path': url_for('station', place_id=place['id'],type_id=type_id) + }) + items.append({ + 'label': BANNER_FMT % '类型', + 'path': url_for('stay') + }) + for type in c['data']['type']: + items.append({ + 'label': type['name'], + 'path': url_for('station', place_id=place_id,type_id=type['id']) + }) + + for top in c['data']['top']: + items.append({ + 'label': top['name'], + 'path': top['streams'][0]['url'], + 'thumbnail': top['icon'][0]['url'], + 'is_playable': True, + 'info': {'title': top['name']} + }) + return items + +@plugin.route('/sections/') +def sections(id): + plugin.set_content('music') + req = { + 'od_id': id, + # 'start': 1, + 'rows': 2000 + } + c = request(BaseAPI + '/odchannelpages?' + urlencode(req)) + items = [] + for item in c['data']['program']: + items.append({ + 'label': item['name'], + 'path': item['streams'][0]['url'], + 'thumbnail': item['imageUrl'][0]['url'], + 'is_playable': True, + 'info': {'title': item['name'], + 'plot': item['description'], + 'duration': int(item['duration']) + } + }) + return items + +@plugin.route('/classification//') +def classification(cate_id, page): + req = { + 'per_page': 16, + 'page': page, + 'cate_id': '' if cate_id == '0' else cate_id + } + c = request(BaseAPI + '/categorypages?'+urlencode(req)) + items = [] + for cat in c['data']['category']: + items.append({ + 'label': cat['name'], + 'path': url_for('classification', cate_id=cat['id'], page='1') + }) + + for chn in c['data']['odchannel']: + items.append({ + 'label': chn['name'], + 'path': url_for('sections', id=chn['id']), + 'thumbnail': chn['imageUrl'][0]['url'], + 'info': {'title': chn['name'], + 'plot': chn['description'], + 'artist': chn.get('source', '')} + }) + + items += [{'label': BANNER_FMT % u'分页', 'path': url_for('stay')}] + for i_page in range(int(c['data']['total_page'])): + if i_page == int(page)-1: continue + items.append({ + 'label': str(i_page+1), + 'path': url_for('classification', cate_id=cate_id, page=i_page+1) + }) + return items + +@plugin.route('/oneanchor/') +def oneanchor(id): + c = request(BaseAPI + '/oneanchor?' + 'anchorId=' + id) + items = [{ + 'label': item['name'], + 'path': url_for('sections', id=item['id']), + 'thumbnail': item['img'], + } for item in c['ondemands']] + + return items + +@plugin.route('/podcast/') +def podcast(domain): + c = request(BaseAPI + '/anchorpages?') + items = [{ + 'label': item['name'], + 'path': url_for('podcast', domain=item['id']) + } for item in c['AnchorsLabeldomain']] + items.insert(0, {'label': BANNER_FMT % u'主播分类', + 'path': url_for('stay')}) + + if domain == '0': + domain = c['allAnchors']['id'] + req = { + 'limit': 2000, + 'offset': 1, + 'labeldomainId': domain + } + c = request(BaseAPI + '/anchorsByDomain?' + urlencode(req)) + + for item in c['allAnchors']['anchors']: + items.append({ + 'label': item['name'], + 'path': url_for('oneanchor', id=item['id']), + 'thumbnail': item['img'], + 'info': {'plot': item['description']}, + }) + + return items + +@plugin.route('/') +def root(): + items = [ + { + 'label': '电台', + 'path': url_for('station', place_id='0', type_id='0') + }, + { + 'label': '分类', + 'path': url_for('classification', cate_id='0', page=1) + }, + { + 'label': '主播', + 'path': url_for('podcast', domain = '0') + } + ] + return items + +if __name__ == '__main__': + plugin.run() diff --git a/plugin.audio.radiocn/addon.xml b/plugin.audio.radiocn/addon.xml index 5e85c81..81b04bd 100644 --- a/plugin.audio.radiocn/addon.xml +++ b/plugin.audio.radiocn/addon.xml @@ -1,9 +1,12 @@ - + version="1.0.0" + provider-name="yfang1644"> + + + + audio diff --git a/plugin.audio.radiocn/changelog.txt b/plugin.audio.radiocn/changelog.txt index ffecb85..e64992f 100644 --- a/plugin.audio.radiocn/changelog.txt +++ b/plugin.audio.radiocn/changelog.txt @@ -1,2 +1,2 @@ -[B]1.0[/B] (2015/01/20 osfans) +[B]1.0.0[/B] (2017/10/20) - 初始版本 diff --git a/plugin.audio.radiocn/default.py b/plugin.audio.radiocn/default.py deleted file mode 100644 index 7655e50..0000000 --- a/plugin.audio.radiocn/default.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -import music -import xbmc -import xbmcgui -import xbmcplugin -import urllib -import urllib2 -import sys - - -def addList(lists): - #name, mode, icon, area, type, channelId - n = len(lists) - plugin = sys.argv[0] - handle = int(sys.argv[1]) - for item in lists: - name = item['name'] - mode = item['mode'] - isFolder = music.isFolder(mode) - li = xbmcgui.ListItem(name) - icon = item.get('icon', '') - if icon: - li.setIconImage(icon) - u = "%s?%s" % (plugin, urllib.urlencode(item)) - xbmcplugin.addDirectoryItem(handle, u, li, isFolder, n) - xbmcplugin.endOfDirectory(handle) - - -def play(params): - name = params.get("name", "") - icon = params.get("icon", "") - channelId = params.get("channelId", "") - if channelId: - li = xbmcgui.ListItem(name) - info = {'title': name} - li.setInfo(type='Video', infoLabels = info) - if icon: - li.setThumbnailImage(icon) - url = music.getStreamUrl(channelId) - xbmc.Player().play(url, li) - - -def get_params(): # get part of the url, help to judge the param of the url, direcdory - param = {} - params = sys.argv[2] - if len(params) >= 2: - cleanedparams = params.rsplit('?',1) - if len(cleanedparams) == 2: - cleanedparams = cleanedparams[1] - else: - cleanedparams = params.replace('?','') - param = dict(urllib2.urlparse.parse_qsl(cleanedparams)) - print(param) - return param - - -params = get_params() -mode = params.get("mode", music.MODE_MENU) - -l = [] -if mode == music.MODE_MENU: - l = music.getMenu() -elif mode == music.MODE_CHANNELS: - area = params.get("area", "0") - type = params.get("type", "0") - l = music.getChannels(area, type) -elif mode == music.MODE_PLAY: - play(params) -if l: - addList(l) diff --git a/plugin.audio.radiocn/music.py b/plugin.audio.radiocn/music.py deleted file mode 100644 index 4d1d037..0000000 --- a/plugin.audio.radiocn/music.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import urllib2 -import urllib -import re -import json - -baseHtml = "http://bk2.radio.cn/mms4/videoPlay" -typeHtml = baseHtml + "/getAreaAndType.jspa" -channelHtml = baseHtml + "/pcGetChannels.jspa" -playinfoHtml = baseHtml + "/getChannelPlayInfoJson.jspa" - -UserAgent = "Mozilla/5.0 (X11; Linux i686; rv:35.0) Gecko/20100101 Firefox/35.0" -headers = {"Host": "bk2.radio.cn", - "User-Agent": UserAgent, - "Referer": "http://www.radio.cn/index.php?option=default,radio"} - -MODE_NONE = "none" -MODE_MENU = "menu" -MODE_CHANNELS = "channels" -MODE_PLAY = "play" - - -def request(url, js=True): - print('request', url) - req = urllib2.Request(url, headers=headers) - response = urllib2.urlopen(req) - cont = response.read() - response.close() - if js: - cont = json.loads(cont.strip("()")) - return cont - - -def isFolder(mode): - return mode in (MODE_MENU, MODE_CHANNELS) - - -def getMenu(): - #name, mode, icon, area, type - c = request(typeHtml) - d = {"area": "地区", "type": "类型"} - l = [] - for i in sorted(d.keys()): - h = '[COLOR FFDEB887]【%s】[/COLOR]' % (d[i]) - item = {'name': h, 'mode': MODE_NONE} - l.append(item) - for j in c[i]: - item = {'name': j['value'].encode('utf-8'), - 'mode': MODE_CHANNELS, - 'icon': j['url'].encode('utf-8')} - item[i] = j['key'].encode('utf-8') - l.append(item) - return l - - -def getChannels(area=0, type=0): - url = channelHtml - query = {"area": area, "type": type, "callback": ""} - url = "%s?%s" % (url, urllib.urlencode(query)) - c = request(url) - l = [] - # name, mode, icon, param - for j in c: - item = {'name': j['channelName'].encode('utf-8'), - 'mode': MODE_PLAY, - 'icon': j['icon'].encode('utf-8'), - 'channelId': j['channelId']} - l.append(item) - return l - - -def getStreamUrl(channelId): - url = playinfoHtml - query = {"channelId": channelId, - "location": "http://www.radio.cn/index.php?option=default,radio", - "terminalType": "PC", - "callback": ""} - url = "%s?%s" % (url, urllib.urlencode(query)) - c = request(url) - return c['streams'][0]['url'] - - -if __name__ == '__main__': - print(getStreamUrl(183)) diff --git a/plugin.audio.radiocn/plugin.audio.radiocn-1.0.zip b/plugin.audio.radiocn/plugin.audio.radiocn-1.0.0.zip similarity index 71% rename from plugin.audio.radiocn/plugin.audio.radiocn-1.0.zip rename to plugin.audio.radiocn/plugin.audio.radiocn-1.0.0.zip index 5f3a715..fe4f087 100644 Binary files a/plugin.audio.radiocn/plugin.audio.radiocn-1.0.zip and b/plugin.audio.radiocn/plugin.audio.radiocn-1.0.0.zip differ diff --git a/plugin.audio.ximalaya/addon.py b/plugin.audio.ximalaya/addon.py index 7e3e609..0d8f0e8 100644 --- a/plugin.audio.ximalaya/addon.py +++ b/plugin.audio.ximalaya/addon.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- from xbmcswift2 import Plugin, xbmcaddon -from urllib import urlencode import re from json import loads from bs4 import BeautifulSoup @@ -97,7 +96,7 @@ def httphead(url): @plugin.route('/') def root(): - + plugin.set_content('music') html = get_html(HOST_URL + '/dq/all/') html = re.sub('\t|\r|\n', '', html) tree = BeautifulSoup(html, 'html.parser') @@ -119,6 +118,7 @@ def root(): @plugin.route('/sublist/') def sublist(cid): + plugin.set_content('music') html = get_html(HOST_URL + '/dq/all/') tree = BeautifulSoup(html, 'html.parser') @@ -133,6 +133,7 @@ def sublist(cid): @plugin.route('/albumlist/') def albumlist(url): + plugin.set_content('music') html = get_html(url) tree = BeautifulSoup(html, 'html.parser') soup = tree.find_all('div', {'class': 'discoverAlbum_wrapper'}) @@ -160,17 +161,11 @@ def albumlist(url): 'path': plugin.url_for('albumlist', url=httphead(url.encode('utf-8'))) } -@plugin.route('/play/') -def play(url): - plugin.set_content('music') - plugin.resolved_url(url) @plugin.route('/playList///') def playList(url, page, order): plugin.set_content('music') - pdata = {'page': page, 'order': order} - data = urlencode(pdata) - html = get_html(url + '?' + data) + html = get_html(url + '?page={}&order={}'.format(page, order)) tree = BeautifulSoup(html, 'html.parser') info = tree.find_all('div', {'class': 'rich_intro'})