Skip to content

Commit

Permalink
patch some audio plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
yfang1644 committed Oct 25, 2017
1 parent 5ebfdff commit 0417a60
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 525 deletions.
42 changes: 0 additions & 42 deletions plugin.audio.doubanfm/DoubanFM.py

This file was deleted.

79 changes: 51 additions & 28 deletions plugin.audio.doubanfm/default.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-

from xbmcswift2 import Plugin, ListItem
from xbmcswift2 import Plugin
from urllib import urlencode
import urllib2
from json import load
from common import get_html


LIST = ['为你推荐', '最热', '流行', '摇滚', '民谣', '原声',
Expand All @@ -20,18 +19,14 @@
def GetInfo(url):
req = urllib2.Request(url)
req.add_header('User-Agent', __UserAgent)
response = urllib2.urlopen(req)
response = urllib2.urlopen(req, timeout=15)
info = load(response)
return info

@plugin.route('/play/<url>')
def play(url):
plugin.set_content('episode')
plugin.set_resolved_url(url)


@plugin.route('/list_in_channel/<channel_id>')
def list_in_channel(channel_id):
plugin.set_content('music')

songAPI = HOST + 'playlist'
req = {
'kbps': 128,
Expand All @@ -41,22 +36,26 @@ def list_in_channel(channel_id):
'type': 'n'
}
data = urlencode(req)
results = GetInfo(songAPI + '?' + data)
song = results.get('song', [])
if len(song) > 0:
song = song[0]
print song
item = {
'label': song['title'],
'path': plugin.url_for('play', url=song['url']),
'thumbnail': song['picture'],
'icon': song['singers'][0]['avatar'],
'is_playable': True,
'info': {'duration': song['length']}
}
return [item]
else:
return []
items = []
cnt = 0
while (True):
results = GetInfo(songAPI + '?' + data)
song = results.get('song', [])
if len(song) > 0:
song = song[0]
items += [{
'label': song['title'],
'path': song['url'],
'thumbnail': song['picture'],
'icon': song['singers'][0]['avatar'],
'is_playable': True,
'info': {'title': song['title'], 'duration': song['length']}
}]
cnt += 1
if cnt >= 20:
break

return items


@plugin.route('/channels')
Expand All @@ -73,6 +72,7 @@ def channels():

@plugin.route('/albumlist/<albumid>')
def albumlist(albumid):
plugin.set_content('music')
playlistAPI = HOST + 'songlist/{}/?kbps=128'
results = GetInfo(playlistAPI.format(albumid))

Expand All @@ -81,9 +81,12 @@ def albumlist(albumid):
'thumbnail': item['picture'],
'icon': results['cover'],
'is_playable': True,
'path': plugin.url_for(play, url=item['url']),
'path': item['url'],
'info': {
'title': item['title'],
'duration': item['length'],
'genre': results['title'],
'artist': item['artist'],
'plot': results['description']
}
} for item in results['songs']]
Expand All @@ -109,19 +112,39 @@ def catalog(cid):
'icon': item['creator']['picture'],
'thumbnail': item['cover'],
'info': {
'title': item['title'].encode('utf-8'),
'plot': item['description'],
'genre': LIST[int(cid)],
'duration': item['duration']
'artist': '',
'duration': item['duration'],
}
} for item in results]
return items


@plugin.route('/')
def root():

# MAINLIST = {'scenario': '心情/场景', 'language': '语言',
# 'artist': '艺术家', 'track': '单曲',
# 'brand':'天猫理想生活','genre': '风格/流派'}
# rootAPI = HOST + 'rec_channels?specific=all'
# results = GetInfo(rootAPI)
#
# channels = results['data']['channels']
# items = []
# for labels in MAINLIST
# for x in channels[labels]:
# items.append({
# 'label': x['name'],
# 'path': plugin.url_for('list_in_channel', channel_id=x['id']),
# 'thumbnail': x['banner'],
# 'info': {'plot': x['intro']}
# })
#
items = [{'label': '频道列表',
'path': plugin.url_for('channels'),
}]
}]
items += [{
'label': title,
'path': plugin.url_for('catalog', cid=i),
Expand Down
Loading

0 comments on commit 0417a60

Please sign in to comment.