Skip to content

Commit

Permalink
feat: 增加音质 高清环绕声、沉浸环绕声、超清母带
Browse files Browse the repository at this point in the history
  • Loading branch information
chen310 committed Jul 4, 2023
1 parent 877345c commit 33d7f49
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
39 changes: 27 additions & 12 deletions addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,23 @@ def logout():

quality = xbmcplugin.getSetting(int(sys.argv[1]), 'quality')
if quality == '0':
bitrate = 128000
level = 'standard'
elif quality == '1':
bitrate = 192000
level = 'higher'
elif quality == '2':
bitrate = 320000
level = 'exhigh'
elif quality == '3':
bitrate = 350000
level = 'lossless'
elif quality == '4':
bitrate = 999000
level = 'hires'
elif quality == '5':
level = 'jyeffect'
elif quality == '6':
level = 'sky'
elif quality == '7':
level = 'jymaster'
else:
bitrate = 128000
level = 'standard'

resolution = xbmcplugin.getSetting(int(sys.argv[1]), 'resolution')
if resolution == '0':
Expand Down Expand Up @@ -429,6 +435,12 @@ def get_songs_items(datas, privileges=[], picUrl=None, offset=0, getmv=True, sou
label += tag(' Hi-Res')
elif play['privilege']['playMaxBrLevel'] == 'lossless':
label += tag(' SQ')
elif play['privilege']['playMaxBrLevel'] == 'jyeffect':
label += tag(' 环绕声')
elif play['privilege']['playMaxBrLevel'] == 'sky':
label += tag(' 沉浸声')
elif play['privilege']['playMaxBrLevel'] == 'jymaster':
label += tag(' 超清母带')
elif play['privilege']['maxbr'] >= 999000:
label += tag(' SQ')
# payed: 0 未付费 | 3 付费单曲 | 5 付费专辑
Expand Down Expand Up @@ -593,7 +605,7 @@ def song_contextmenu(action, meida_type, song_id, mv_id, sourceId, dt):
dialog.notification(
'收藏', msg, xbmcgui.NOTIFICATION_INFO, 800, False)
elif action == 'play_song':
songs = music.songs_url([song_id], bitrate=bitrate).get("data", [])
songs = music.songs_url_v1([song_id], level=level).get("data", [])
urls = [song['url'] for song in songs]
url = urls[0]
if url is None:
Expand Down Expand Up @@ -623,14 +635,14 @@ def play(meida_type, song_id, mv_id, sourceId, dt):
dialog.notification('MV播放失败', '自动播放歌曲',
xbmcgui.NOTIFICATION_INFO, 800, False)

songs = music.songs_url([song_id], bitrate=bitrate).get("data", [])
songs = music.songs_url_v1([song_id], level=level).get("data", [])
urls = [song['url'] for song in songs]
if len(urls) == 0:
url = None
else:
url = urls[0]
elif meida_type == 'song':
songs = music.songs_url([song_id], bitrate=bitrate).get("data", [])
songs = music.songs_url_v1([song_id], level=level).get("data", [])
urls = [song['url'] for song in songs]
# 一般是网络错误
if len(urls) == 0:
Expand All @@ -656,7 +668,7 @@ def play(meida_type, song_id, mv_id, sourceId, dt):
elif meida_type == 'dj':
result = music.dj_detail(song_id)
song_id = result['program']['mainSong']['id']
songs = music.songs_url([song_id], bitrate=bitrate).get("data", [])
songs = music.songs_url_v1([song_id], level=level).get("data", [])
urls = [song['url'] for song in songs]
if len(urls) == 0:
url = None
Expand Down Expand Up @@ -1553,7 +1565,7 @@ def get_artists_items(artists):


def get_users_items(users):
vip_level = ['壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾']
vip_level = ['', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾']
items = []
for user in users:
plot_info = tag(user['nickname'], 'pink')
Expand All @@ -1577,7 +1589,10 @@ def get_users_items(users):
plot_info += level_str + '\n'
elif user['vipType'] == 11:
level = user['vipRights']['redVipLevel']
level_str = tag('vip·' + vip_level[level], 'red')
if 'redplus' in user['vipRights'] and user['vipRights']['redplus'] is not None:
level_str = tag('Svip·' + vip_level[level], 'gold')
else:
level_str = tag('vip·' + vip_level[level], 'red')
if user['userType'] == 4:
plot_info += level_str + tag(' 音乐人', 'red') + '\n'
else:
Expand Down
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.audio.music163" name="music163" version="1.5.9" provider-name="chen310">
<addon id="plugin.audio.music163" name="music163" version="1.5.10" provider-name="chen310">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
Expand Down
9 changes: 7 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self):
self.session.cookies = cookie_jar

if 'appver' not in self.session.cookies:
cookie = self.make_cookie('appver', '8.7.01')
cookie = self.make_cookie('appver', '8.10.10')
self.session.cookies.set_cookie(cookie)

for cookie in cookie_jar:
Expand Down Expand Up @@ -106,7 +106,7 @@ def make_cookie(self, name, value):
rest={},
)

def request(self, method, path, params={}, default={"code": -1}, custom_cookies={'os': 'ios'}, return_json=True):
def request(self, method, path, params={}, default={"code": -1}, custom_cookies={'os': 'android'}, return_json=True):
endpoint = "{}{}".format(BASE_URL, path)
csrf_token = ""
for cookie in self.session.cookies:
Expand Down Expand Up @@ -266,6 +266,11 @@ def songs_url(self, ids, bitrate):
params = dict(ids=ids, br=bitrate)
return self.request("POST", path, params)

def songs_url_v1(self, ids, level):
path = "/weapi/song/enhance/player/url/v1"
params = dict(ids=ids, level=level, encodeType='flac')
return self.request("POST", path, params)

# lyric http://music.163.com/api/song/lyric?os=osx&id= &lv=-1&kv=-1&tv=-1
def song_lyric(self, music_id):
path = "/weapi/song/lyric"
Expand Down
12 changes: 12 additions & 0 deletions resources/language/resource.language.zh_cn/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ msgctxt "#32015"
msgid "Hi-Res"
msgstr "Hi-Res"

msgctxt "#32016"
msgid "Spatial Audio"
msgstr "高清环绕声"

msgctxt "#32017"
msgid "Surround Audio"
msgstr "沉浸环绕声"

msgctxt "#32018"
msgid "Master"
msgstr "超清母带"

# 标清
msgctxt "#32021"
msgid "240"
Expand Down
2 changes: 1 addition & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<setting id="number_of_songs_per_page" type="number" label="33003" default="1000"/>
<setting id="show_index" type="bool" label="33004" default="false"/>
<setting id="mvfirst" type="bool" label="33005" default="true"/>
<setting id="quality" type="select" label="33006" lvalues="32011|32012|32013|32014|32015" />
<setting id="quality" type="select" label="33006" lvalues="32011|32012|32013|32014|32015|32016|32017|32018" />
<setting id="resolution" type="select" label="33007" lvalues="32021|32022|32023|32024" />
<setting id="song_naming_format" type="select" label="33015" lvalues="32031|32032|32033" />
<setting id="reverse_radio" type="bool" label="33008" default="false" />
Expand Down

0 comments on commit 33d7f49

Please sign in to comment.