luci-app-unblockneteasemusic: sync with upstream source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2021-03-01 20:08:39 +08:00
parent f296b74a46
commit c8ba0e3586
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
10 changed files with 19 additions and 171 deletions

View File

@ -1,20 +1,22 @@
# Copyright (C) 2016 Openwrt.org
#
# This is a free software, use it under GNU General Public License v3.0.
# Copyright (C) 2021 ImmortalWrt
# (https://immortalwrt.org)
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
# Created By ImmortalWrt
# https://github.com/project-openwrt
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for UnblockNeteaseMusic
LUCI_DEPENDS:=+bash +busybox +coreutils +coreutils-nohup +curl +dnsmasq-full +ipset +libopenssl +node
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-unblockneteasemusic
PKG_VERSION:=2.8
PKG_RELEASE:=8
PKG_RELEASE:=10
PKG_MAINTAINER:=ImmortalWrt
PKG_MAINTAINER:=CN_SZTL <cnsztl@immortalwrt.org>
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -11,9 +11,9 @@ function index()
entry({"admin", "services", "unblockneteasemusic"},firstchild(), _("解除网易云音乐播放限制"), 50).dependent = false
entry({"admin", "services", "unblockneteasemusic", "general"},cbi("unblockneteasemusic"), _("基本设定"), 1)
entry({"admin", "services", "unblockneteasemusic", "upgrade"},form("unblockneteasemusic_upgrade"), _("更新组件"), 2).leaf = true
entry({"admin", "services", "unblockneteasemusic", "log"},form("unblockneteasemusiclog"), _("日志"), 3)
entry({"admin", "services", "unblockneteasemusic", "general"},cbi("unblockneteasemusic/unblockneteasemusic"), _("基本设定"), 1)
entry({"admin", "services", "unblockneteasemusic", "upgrade"},form("unblockneteasemusic/unblockneteasemusic_upgrade"), _("更新组件"), 2).leaf = true
entry({"admin", "services", "unblockneteasemusic", "log"},form("unblockneteasemusic/unblockneteasemusiclog"), _("日志"), 3)
entry({"admin", "services", "unblockneteasemusic", "status"},call("act_status")).leaf=true
entry({"admin", "services", "unblockneteasemusic", "update_luci"},call("act_update_luci"))
@ -57,7 +57,7 @@ end
function update_core()
core_cloud_ver=luci.sys.exec("curl -s 'https://github.com/1715173329/UnblockNeteaseMusic/commits/enhanced' |tr -d '\n' |grep -Eo 'commit\/[0-9a-z]+' |sed -n 1p |sed 's#commit/##g'")
core_cloud_ver_mini=luci.sys.exec("curl -s 'https://github.com/1715173329/UnblockNeteaseMusic/commits/enhanced' |tr -d '\n' |grep -Eo 'BtnGroup-item.> [0-9a-z]+' |sed -n 1p |sed 's#BtnGroup-item.> ##g'")
core_cloud_ver_mini=string.sub(core_cloud_ver, 1, 7)
if not core_cloud_ver or not core_cloud_ver_mini then
return "1"
else

View File

@ -23,6 +23,7 @@ music_source:value("xiami", translate("虾米音乐"))
music_source:value("baidu", translate("百度音乐"))
music_source:value("joox", translate("JOOX音乐"))
music_source:value("youtube", translate("Youtube音乐"))
music_source:value("bilibili", translate("Bilibili音乐"))
music_source.description = translate("自定义模式下,多个音源请用空格隔开")
music_source.default = "default"
music_source.rmempty = false
@ -63,11 +64,6 @@ youtube_key.description = translate("API Key申请地址https://developers.go
youtube_key.datatype = "string"
youtube_key:depends("use_custom_cookie", 1)
use_remote_qq_server = s:option(Flag, "use_remote_qq_server", translate("使用云端QQ音源解析"))
use_remote_qq_server.description = translate("通过云端服务器以获取QQ音源信息无需开通QQ绿钻")
use_remote_qq_server.default = 0
use_remote_qq_server.rmempty = false
auto_update = s:option(Flag, "auto_update", translate("启用自动更新"))
auto_update.description = translate("启用后,每天将定时自动检查最新版本并更新")
auto_update.default = 0

View File

@ -5,7 +5,6 @@ config unblockneteasemusic
option enable_flac '0'
option replace_music_source 'dont_replace'
option use_custom_cookie '0'
option use_remote_qq_server '0'
option auto_update '1'
option update_time '3'
option daemon_enable '1'

View File

@ -192,9 +192,6 @@ start()
[ ! -e "/usr/share/$NAME/core/app.js" ] && { rm -f "/usr/share/$NAME/local_ver"; bash "/usr/share/$NAME/update.sh" "update_core_non_restart"; }
[ ! -e "/usr/share/$NAME/core/app.js" ] && { echo "Core Not Found, please download it before starting." >> "/tmp/$NAME.log"; exit 1; }
[ "${use_remote_qq_server}" -ne "1" ] && qq_server_mode="local" || qq_server_mode="remote"
bash "/usr/share/$NAME/gen_qq_provider.sh" "${qq_server_mode}" "${enable_flac}" > "/usr/share/$NAME/core/src/provider/qq.js"
[ -n "${neteasemusic_cookie}" ] && {
ub_cookie_line="$(sed -n -e "/netease.path.includes('song\/enhance')/=" "/usr/share/$NAME/core/src/hook.js")";
[ -n "${ub_cookie_line}" ] && { let ub_cookie_endline="ub_cookie_line+6"; sed -i "${ub_cookie_line},${ub_cookie_endline}d" "/usr/share/$NAME/core/src/hook.js"; }
@ -253,10 +250,10 @@ stop()
{ [ -f "${self_issue_cert_crt}" ] && [ -f "${self_issue_cert_key}" ]; } && {
{ [ "${self_issue_cert_crt}" != "/usr/share/$NAME/core/server.crt" ] && [ "${self_issue_cert_key}" != "/usr/share/$NAME/core/server.key" ]; } && {
sed -i "/${self_issue_cert_crt//\//\\/}/d"
sed -i "/${self_issue_cert_crt//\//\\/}/d" "${UPGRADE_CONF}"
echo "${self_issue_cert_crt}" >> "${UPGRADE_CONF}"
sed -i "/${self_issue_cert_key//\//\\/}/d"
sed -i "/${self_issue_cert_key//\//\\/}/d" "${UPGRADE_CONF}"
echo "${self_issue_cert_key}" >> "${UPGRADE_CONF}"
}
}

View File

@ -1,146 +0,0 @@
#!/bin/bash
# Created By ImmortalWrt
# https://github.com/project-openwrt
header="const cache = require('../cache')
const insure = require('./insure')
const select = require('./select')
const request = require('../request')
const headers = {
'origin': 'http://y.qq.com/',
'referer': 'http://y.qq.com/',"
body="const playable = song => {
const switchFlag = song['switch'].toString(2).split('')
switchFlag.pop()
switchFlag.reverse()
const playFlag = switchFlag[0]
const tryFlag = switchFlag[13]
return ((playFlag == 1) || ((playFlag == 1) && (tryFlag == 1)))
}
const format = song => ({
id: {song: song.mid, file: song.file.media_mid},
name: song.name,
duration: song.interval * 1000,
album: {id: song.album.mid, name: song.album.name},
artists: song.singer.map(({mid, name}) => ({id: mid, name}))
})
const search = info => {
const url =
'https://c.y.qq.com/soso/fcgi-bin/client_search_cp?' +
'ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.center&' +
't=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=1&n=20&w=' +
encodeURIComponent(info.keyword) + '&' +
'g_tk=5381&jsonpCallback=MusicJsonCallback10005317669353331&loginUin=0&hostUin=0&' +
'format=jsonp&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq&needNewCode=0'
return request('GET', url)
.then(response => response.jsonp())
.then(jsonBody => {
const list = jsonBody.data.song.list.map(format)
const matched = select(list, info)
return matched ? matched.id : Promise.reject()
})
}"
if [ "$1" == "local" ]
then echo -e "// local_mode
${header}
'cookie': process.env.QQ_COOKIE || null // 'uin=; qm_keyst=',
}
${body}
const single = (id, format) => {
const uin = ((headers.cookie || '').match(/uin=(\d+)/) || [])[1] || '0'
const concatenate = vkey => {
if (!vkey) return Promise.reject()
const host = ['streamoc.music.tc.qq.com', 'mobileoc.music.tc.qq.com', 'isure.stream.qqmusic.qq.com', 'dl.stream.qqmusic.qq.com', 'aqqmusic.tc.qq.com/amobile.music.tc.qq.com'][3]
return \`http://\${host}/\${format.join(id.file)}?vkey=\${vkey}&uin=0&fromtag=8&guid=7332953645\`
}
const url =
'https://u.y.qq.com/cgi-bin/musicu.fcg?data=' +
encodeURIComponent(JSON.stringify({
req_0: {
module: 'vkey.GetVkeyServer',
method: 'CgiGetVkey',
param: {
guid: '7332953645',
loginflag: 1,
filename: [format.join(id.file)],
songmid: [id.song],
songtype: [0],
uin,
platform: '20'
}
}
}))
return request('GET', url, headers)
.then(response => response.json())
.then(jsonBody => {
const { sip, midurlinfo } = jsonBody.req_0.data
return midurlinfo[0].purl ? sip[0] + midurlinfo[0].purl : Promise.reject()
})
}
const track = id => {
id.key = id.file
return Promise.all(
[['F000', '.flac'], ['M800', '.mp3'], ['M500', '.mp3']].slice((headers.cookie || typeof(window) !== 'undefined') ? (select.ENABLE_FLAC ? 0 : 1) : 2)
.map(format => single(id, format).catch(() => null))
)
.then(result => result.find(url => url) || Promise.reject())
.catch(() => insure().qq.track(id))
}
const check = info => cache(search, info).then(track)
module.exports = {check, track}"
elif [ "$1" == "remote" ]
then [ "$2" == "1" ] && { flac_quality="'flac', "; loop_times="4"; } || loop_times="3"
echo -e "// remote_mode
${header}
'cookie': null
}
${body}
const track = id => {
const typeObj = [${flac_quality}'320', '128', 'm4a']
let i = 0
while (i < ${loop_times}) {
type = typeObj[i]
let url =
'https://api.qq.jsososo.com/song/url?id=' +
id.song + '&mediaId=' + id.file + '&type=' + \`\${type}\`
return request('GET', url)
.then(response => response.json())
.then(jsonBody => {
let res = jsonBody.result
if (res === 100) {
let songUrl = jsonBody.data
return songUrl
} else if (i === $[${loop_times}-1]) {
return Promise.reject()
} else {
return
}
})
.catch(() => insure().qq.track(id))
i++
}
}
const check = info => cache(search, info).then(track)
module.exports = {check, track}"
else echo -e "Usage: $0 [local|remote] (1)"
fi

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Created By ImmortalWrt
# https://github.com/project-openwrt
# https://github.com/immortalwrt
NAME="unblockneteasemusic"

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Created By ImmortalWrt
# https://github.com/project-openwrt
# https://github.com/immortalwrt
NAME="unblockneteasemusic"
@ -19,7 +19,7 @@ function clean_log(){
}
function check_luci_latest_version(){
luci_latest_ver="$(curl -s 'https://github.com/project-openwrt/luci-app-unblockneteasemusic/releases/latest'| grep -Eo '[0-9\.]+\-[0-9]+')"
luci_latest_ver="$(curl -s 'https://github.com/immortalwrt/luci-app-unblockneteasemusic/releases/latest'| grep -Eo '[0-9\.]+\-[0-9]+')"
[ -z "${luci_latest_ver}" ] && { echo -e "\nFailed to check latest LuCI version, please try again later." >> "/tmp/$NAME.log"; exit 1; }
if [ "$(opkg info "luci-app-unblockneteasemusic" |sed -n "2p" |tr -d "Version: ")" != "${luci_latest_ver}" ]; then
clean_log
@ -37,7 +37,7 @@ function update_luci(){
mkdir -p "/tmp" > "/dev/null" 2>&1
curl -sL "https://github.com/project-openwrt/luci-app-unblockneteasemusic/releases/download/v${luci_latest_ver}/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk" -o "/tmp/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk" > "/dev/null" 2>&1
curl -sL "https://github.com/immortalwrt/luci-app-unblockneteasemusic/releases/download/v${luci_latest_ver}/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk" -o "/tmp/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk" > "/dev/null" 2>&1
opkg install "/tmp/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk"
rm -f "/tmp/luci-app-unblockneteasemusic_${luci_latest_ver}_all.ipk"
rm -rf "/tmp/luci-indexcache" "/tmp/luci-modulecache"