mirror of
https://github.com/ZxwyWebSite/lx-source.git
synced 2025-05-23 21:37:42 +08:00
2024-01-15 v1.0.2-b11
This commit is contained in:
parent
8d16e3be98
commit
ad64fa1492
7
src/env/env.go
vendored
7
src/env/env.go
vendored
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = `1.0.2-b10`
|
Version = `1.0.2-b11`
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -64,8 +64,9 @@ type (
|
|||||||
// 代理
|
// 代理
|
||||||
Proxy_Enable bool `comment:"使用代理"`
|
Proxy_Enable bool `comment:"使用代理"`
|
||||||
Proxy_Address string `comment:"代理地址 (支持http, socks)"`
|
Proxy_Address string `comment:"代理地址 (支持http, socks)"`
|
||||||
// 平台账号
|
// 验证
|
||||||
// ...(待实现)
|
MusicIdVerify bool `comment:"(beta) 验证音乐ID可用性"`
|
||||||
|
ForceFallback bool `comment:"忽略音质限制,强制获取试听音频"`
|
||||||
} // `comment:""`
|
} // `comment:""`
|
||||||
Conf_Custom struct {
|
Conf_Custom struct {
|
||||||
// wy (暂未实现)
|
// wy (暂未实现)
|
||||||
|
@ -30,13 +30,16 @@ var (
|
|||||||
// kw_pool = &sync.Pool{New: func() any { return new(KwApi_Song) }}
|
// kw_pool = &sync.Pool{New: func() any { return new(KwApi_Song) }}
|
||||||
kg_pool = &sync.Pool{New: func() any { return new(KgApi_Song) }}
|
kg_pool = &sync.Pool{New: func() any { return new(KgApi_Song) }}
|
||||||
// tx_pool = &sync.Pool{New: func() any { return new(res_tx) }}
|
// tx_pool = &sync.Pool{New: func() any { return new(res_tx) }}
|
||||||
|
wv_pool *sync.Pool
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
func init() {
|
||||||
errHttpReq = `无法连接解析接口`
|
env.Inits.Add(func() {
|
||||||
errNoLink = `无法获取试听链接`
|
if env.Config.Source.MusicIdVerify {
|
||||||
errDisable = `该音乐源已被禁用`
|
wv_pool = &sync.Pool{New: func() any { return new(WyApi_Vef) }}
|
||||||
)
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 查询
|
// 查询
|
||||||
func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
||||||
@ -48,30 +51,50 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
|||||||
// var outlink string
|
// var outlink string
|
||||||
jx := env.Loger.NewGroup(`Sources`) //sources.Loger.AppGroup(`builtin`) //env.Loger.NewGroup(`JieXiApis`)
|
jx := env.Loger.NewGroup(`Sources`) //sources.Loger.AppGroup(`builtin`) //env.Loger.NewGroup(`JieXiApis`)
|
||||||
switch c.Source {
|
switch c.Source {
|
||||||
case s_wy:
|
case sources.S_wy:
|
||||||
if !env.Config.Custom.Wy_Enable {
|
if !env.Config.Custom.Wy_Enable {
|
||||||
msg = errDisable
|
msg = sources.ErrDisable
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 可用性验证
|
||||||
|
if env.Config.Source.MusicIdVerify {
|
||||||
|
vef := wv_pool.Get().(*WyApi_Vef)
|
||||||
|
defer wv_pool.Put(vef)
|
||||||
|
vurl := ztool.Str_FastConcat(`https://`, vef_wy, `&id=`, c.MusicID)
|
||||||
|
_, err := ztool.Net_HttpReq(http.MethodGet, vurl, nil, header_wy, &vef)
|
||||||
|
if err != nil {
|
||||||
|
jx.Error(`Wy, VefReq: %s`, err)
|
||||||
|
msg = sources.ErrHttpReq
|
||||||
|
return
|
||||||
|
}
|
||||||
|
jx.Debug(`Wy, Vef: %+v`, vef)
|
||||||
|
if vef.Code != 200 || !vef.Success {
|
||||||
|
msg = ztool.Str_FastConcat(`暂不可用:`, vef.Message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 获取外链
|
||||||
resp := wy_pool.Get().(*WyApi_Song)
|
resp := wy_pool.Get().(*WyApi_Song)
|
||||||
defer wy_pool.Put(resp)
|
defer wy_pool.Put(resp)
|
||||||
|
// 分流逻辑 (暂无其它节点)
|
||||||
// urls := [...]string{
|
// urls := [...]string{
|
||||||
// ztool.Str_FastConcat(`http://`, api_wy, `?id=`, c.MusicID, `&level=`, rquery, `&noCookie=true`),
|
// ztool.Str_FastConcat(`http://`, api_wy, `?id=`, c.MusicID, `&level=`, rquery, `&noCookie=true`),
|
||||||
// ztool.Str_FastConcat(`https://`, api_wy, `&id=`, c.MusicID, `&level=`, rquery, `&encodeType=`, c.Extname),
|
// ztool.Str_FastConcat(`https://`, api_wy, `&id=`, c.MusicID, `&level=`, rquery, `&encodeType=`, c.Extname),
|
||||||
// }
|
// }
|
||||||
// url := urls[rand.Intn(len(urls))]
|
// url := urls[rand.Intn(len(urls))]
|
||||||
url := ztool.Str_FastConcat(`https://`, api_wy, `&id=`, c.MusicID, `&level=`, rquery, `&encodeType=`, c.Extname)
|
url := ztool.Str_FastConcat(
|
||||||
|
`https://`, api_wy, `&id=`, c.MusicID, `&level=`, rquery,
|
||||||
|
`×tamp=`, strconv.FormatInt(time.Now().UnixMilli(), 10),
|
||||||
|
)
|
||||||
// jx.Debug(`Wy, Url: %v`, url)
|
// jx.Debug(`Wy, Url: %v`, url)
|
||||||
// wy源增加后端重试 默认3次
|
// wy源增加后端重试 默认3次
|
||||||
for i := 0; true; i++ {
|
for i := 0; true; i++ {
|
||||||
// _, err := ztool.Net_HttpReq(http.MethodGet, url, nil, header_wy, &resp)
|
_, err := ztool.Net_HttpReq(http.MethodGet, url, nil, header_wy, &resp)
|
||||||
_, err := ztool.Net_HttpReq(http.MethodGet, url, nil, nil, &resp)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jx.Error(`HttpReq, Err: %s, ReTry: %v`, err, i)
|
jx.Error(`HttpReq, Err: %s, ReTry: %v`, err, i)
|
||||||
if i > 3 {
|
if i > 3 {
|
||||||
jx.Error(`Wy, HttpReq: %s`, err)
|
jx.Error(`Wy, HttpReq: %s`, err)
|
||||||
msg = errHttpReq //err.Error()
|
msg = sources.ErrHttpReq
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
@ -96,7 +119,7 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
|||||||
}
|
}
|
||||||
// jx.Info(`WyLink, RealQuality: %v`, data.Level)
|
// jx.Info(`WyLink, RealQuality: %v`, data.Level)
|
||||||
outlink = data.URL
|
outlink = data.URL
|
||||||
case s_mg:
|
case sources.S_mg:
|
||||||
resp := mg_pool.Get().(*MgApi_Song)
|
resp := mg_pool.Get().(*MgApi_Song)
|
||||||
defer mg_pool.Put(resp)
|
defer mg_pool.Put(resp)
|
||||||
|
|
||||||
@ -105,7 +128,7 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
|||||||
_, err := ztool.Net_HttpReq(http.MethodGet, url, nil, header_mg, &resp)
|
_, err := ztool.Net_HttpReq(http.MethodGet, url, nil, header_mg, &resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jx.Error(`Mg, HttpReq: %s`, err)
|
jx.Error(`Mg, HttpReq: %s`, err)
|
||||||
msg = errHttpReq //err.Error()
|
msg = sources.ErrHttpReq
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jx.Debug(`Mg, Resp: %+v`, resp)
|
jx.Debug(`Mg, Resp: %+v`, resp)
|
||||||
@ -114,9 +137,9 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
|||||||
} // else {
|
} // else {
|
||||||
// jx.Debug(`Mg, Err: %#v`, resp)
|
// jx.Debug(`Mg, Err: %#v`, resp)
|
||||||
// }
|
// }
|
||||||
case s_kw:
|
case sources.S_kw:
|
||||||
if !env.Config.Custom.Kw_Enable {
|
if !env.Config.Custom.Kw_Enable {
|
||||||
msg = errDisable
|
msg = sources.ErrDisable
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ourl, emsg := kw.Url(c.MusicID, c.Quality)
|
ourl, emsg := kw.Url(c.MusicID, c.Quality)
|
||||||
@ -125,7 +148,7 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
outlink = ourl
|
outlink = ourl
|
||||||
case s_kg:
|
case sources.S_kg:
|
||||||
resp := kg_pool.Get().(*KgApi_Song)
|
resp := kg_pool.Get().(*KgApi_Song)
|
||||||
defer kg_pool.Put(resp)
|
defer kg_pool.Put(resp)
|
||||||
|
|
||||||
@ -142,10 +165,10 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
|||||||
_, err := ztool.Net_HttpReq(http.MethodGet, url, nil, nil, &resp)
|
_, err := ztool.Net_HttpReq(http.MethodGet, url, nil, nil, &resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jx.Error(`Kg, HttpReq: %s`, err)
|
jx.Error(`Kg, HttpReq: %s`, err)
|
||||||
msg = errHttpReq //err.Error()
|
msg = sources.ErrHttpReq
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jx.Debug(`Kw, Resp: %+v`, resp)
|
jx.Debug(`Kg, Resp: %+v`, resp)
|
||||||
if resp.ErrCode != 0 {
|
if resp.ErrCode != 0 {
|
||||||
msg = ztool.Str_FastConcat(`Error: `, strconv.Itoa(resp.ErrCode))
|
msg = ztool.Str_FastConcat(`Error: `, strconv.Itoa(resp.ErrCode))
|
||||||
return
|
return
|
||||||
@ -158,15 +181,19 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
|||||||
}
|
}
|
||||||
if data.PlayBackupURL == `` {
|
if data.PlayBackupURL == `` {
|
||||||
if data.PlayURL == `` {
|
if data.PlayURL == `` {
|
||||||
msg = errNoLink
|
msg = sources.ErrNoLink
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
outlink = data.PlayURL
|
outlink = data.PlayURL
|
||||||
}
|
}
|
||||||
outlink = data.PlayBackupURL
|
outlink = data.PlayBackupURL
|
||||||
case s_tx:
|
case sources.S_tx:
|
||||||
sep := c.Split()
|
// sep := c.Split()
|
||||||
ourl, emsg := tx.Url(sep[0], c.Quality)
|
if len(c.MusicID) != 14 {
|
||||||
|
msg = sources.E_VefMusicId
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ourl, emsg := tx.Url(c.MusicID, c.Quality)
|
||||||
if emsg != `` {
|
if emsg != `` {
|
||||||
msg = emsg
|
msg = emsg
|
||||||
return
|
return
|
||||||
|
File diff suppressed because one or more lines are too long
@ -24,6 +24,7 @@ const (
|
|||||||
E_QNotSupport = `不支持的音质`
|
E_QNotSupport = `不支持的音质`
|
||||||
E_QNotMatch = `实际音质不匹配`
|
E_QNotMatch = `实际音质不匹配`
|
||||||
E_NoLink = `无法获取音乐链接`
|
E_NoLink = `无法获取音乐链接`
|
||||||
|
E_VefMusicId = `音乐ID校验失败`
|
||||||
// 内置错误
|
// 内置错误
|
||||||
ErrHttpReq = `无法连接解析接口`
|
ErrHttpReq = `无法连接解析接口`
|
||||||
ErrNoLink = `无法获取试听链接`
|
ErrNoLink = `无法获取试听链接`
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
## Lx-Source/更新日志
|
## Lx-Source/更新日志
|
||||||
|
|
||||||
|
#### \# 2024-01-15 v1.0.2-b11 (beta)
|
||||||
|
<!-- + 支持ForceFallback(忽略音质限制,获取试听音频) -->
|
||||||
|
+ 测试版MusicId验证
|
||||||
|
+ (注:任何前置验证都必然会延长响应时间,请确认会用到再开启)
|
||||||
|
+ 修复wy源内置接口
|
||||||
|
|
||||||
#### \# 2024-01-13 v1.0.2-b10 (beta)
|
#### \# 2024-01-13 v1.0.2-b10 (beta)
|
||||||
+ 不再支持自定义Public目录,默认使用内置embedFS提供服务
|
+ 不再支持自定义Public目录,默认使用内置embedFS提供服务
|
||||||
+ 修改脚本更新路径为 `public/lx-custom-source.js`
|
+ 修改脚本更新路径为 `public/lx-custom-source.js`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user