mirror of
https://github.com/ZxwyWebSite/lx-source.git
synced 2025-05-23 21:37:42 +08:00
2023-12-25 v1.0.2-b0.7
This commit is contained in:
parent
48028bd51b
commit
4c3bafde4c
@ -1,6 +1,7 @@
|
||||
package caches
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/ZxwyWebSite/ztool"
|
||||
@ -51,7 +52,7 @@ func (c *Query) Free() { c.query = ``; query_pool.Put(c) }
|
||||
|
||||
// 根据音质判断文件后缀
|
||||
func rext(q string) string {
|
||||
if q == `128k` || q == `320k` {
|
||||
if ztool.Chk_IsMatch(q, `128k`, `320k`) /*q == `128k` || q == `320k`*/ {
|
||||
return `mp3`
|
||||
}
|
||||
return `flac`
|
||||
@ -81,6 +82,19 @@ func (c *Query) Query() string {
|
||||
return c.query
|
||||
}
|
||||
|
||||
// 分割查询字符串
|
||||
/*
|
||||
kg: 分割 Hash-Album 如 "6DC276334F56E22BE2A0E8254D332B45-13097991"
|
||||
tx: 分割 songmid-strMediaMid 如 "002fktJg3cmSpC-000V6uuv35Cwnh"
|
||||
*/
|
||||
func (c *Query) Split() []string {
|
||||
sep := strings.Split(c.MusicID, `-`)
|
||||
if len(sep) >= 2 {
|
||||
return sep
|
||||
}
|
||||
return append(sep, ``)
|
||||
}
|
||||
|
||||
// 初始化缓存
|
||||
func New(c Cache) (Cache, error) {
|
||||
err := c.Init()
|
||||
|
@ -40,11 +40,26 @@ func (c *Cache) Get(q *caches.Query) string {
|
||||
}
|
||||
|
||||
func (c *Cache) Set(q *caches.Query, l string) string {
|
||||
err := ztool.Net_DownloadFile(l, ztool.Str_FastConcat(c.Path, `/`, q.Query()), nil)
|
||||
fpath := ztool.Str_FastConcat(c.Path, `/`, q.Query())
|
||||
// if env.Config.Main.FFConv && q.Source == `kg` { // ztool.Chk_IsMatch(q.Source, `kg`)
|
||||
// err := ztool.Fbj_MkdirAll(fpath, 0644)
|
||||
// if err != nil {
|
||||
// loger.Error(`DownloadFile_Mkdir: %v`, err)
|
||||
// return ``
|
||||
// }
|
||||
// out, err := ztool.Cmd_aWaitExec(ztool.Str_FastConcat(`ffmpeg -i "`, l, `" -vn`, ` -c:a copy`, ` "`, fpath, `"`))
|
||||
// if err != nil {
|
||||
// loger.Error(`DownloadFile_Exec: %v, Output: %v`, err, out)
|
||||
// return ``
|
||||
// }
|
||||
// loger.Debug(`FFMpeg_Out: %v`, out)
|
||||
// } else {
|
||||
err := ztool.Net_DownloadFile(l, fpath, nil)
|
||||
if err != nil {
|
||||
loger.Error(`DownloadFile: %v`, err)
|
||||
return ``
|
||||
}
|
||||
// }
|
||||
// env.Cache.Set(q.Query(), struct{}{}, 3600)
|
||||
return c.getLink(q.Query())
|
||||
// fpath := filepath.Join(c.Path, q.String)
|
||||
|
3
src/env/env.go
vendored
3
src/env/env.go
vendored
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
Version = `1.0.2-b0.6`
|
||||
Version = `1.0.2-b0.7`
|
||||
)
|
||||
|
||||
var (
|
||||
@ -30,6 +30,7 @@ type (
|
||||
LogPath string `comment:"文件日志路径,不填禁用"`
|
||||
Print bool `comment:"控制台输出"`
|
||||
SysLev bool `comment:"(实验性) 设置进程高优先级"`
|
||||
// FFConv bool `comment:"(实验性) 使用FFMpeg修复音频(本地缓存)"`
|
||||
}
|
||||
Conf_Apis struct {
|
||||
// BindAddr string `comment:"外部访问地址,用于生成文件链接"`
|
||||
|
@ -48,8 +48,8 @@ const httpRequest = (url, options) => new Promise((resolve, reject) => {
|
||||
const musicUrl = async (source, info, quality) => {
|
||||
const start = new Date().getTime();
|
||||
const id = info.hash ?? info.copyrightId ?? info.songmid // 音乐id kg源为hash, mg源为copyrightId
|
||||
const album = source == 'kg' && info.albumId != void 0 ? '-' + info.albumId : ''
|
||||
const query = `${source}/${id}${album}/${quality}`
|
||||
const ext = source == 'kg' ? info.albumId : source == 'tx' ? info.strMediaMid : ''
|
||||
const query = `${source}/${id}${(ext != '' && ext != void 0) ? '-' + ext : ''}/${quality}`
|
||||
console.log('创建任务: %s, 音乐信息: %O', query, info)
|
||||
const body = await httpRequest(`${apiaddr}link/${query}`, { method: 'get' });
|
||||
console.log('返回数据: %O', body, `, 耗时 ${new Date().getTime() - start} ms`)
|
||||
|
@ -125,14 +125,15 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
||||
resp := kg_pool.Get().(*KgApi_Song)
|
||||
defer kg_pool.Put(resp)
|
||||
|
||||
sep := strings.Split(c.MusicID, `-`) // 分割 Hash-Album 如 6DC276334F56E22BE2A0E8254D332B45-13097991
|
||||
alb := func() string {
|
||||
if len(sep) >= 2 {
|
||||
return sep[1]
|
||||
}
|
||||
return ``
|
||||
}()
|
||||
url := ztool.Str_FastConcat(api_kg, `&hash=`, sep[0], `&album_id=`, alb, `&_=`, strconv.FormatInt(time.Now().UnixMilli(), 10))
|
||||
// sep := strings.Split(c.MusicID, `-`) // 分割 Hash-Album 如 6DC276334F56E22BE2A0E8254D332B45-13097991
|
||||
// alb := func() string {
|
||||
// if len(sep) >= 2 {
|
||||
// return sep[1]
|
||||
// }
|
||||
// return ``
|
||||
// }()
|
||||
sep := c.Split()
|
||||
url := ztool.Str_FastConcat(api_kg, `&hash=`, sep[0], `&album_id=`, sep[1], `&_=`, strconv.FormatInt(time.Now().UnixMilli(), 10))
|
||||
// jx.Debug(`Kg, Url: %s`, url)
|
||||
_, err := ztool.Net_HttpReq(http.MethodGet, url, nil, nil, &resp)
|
||||
if err != nil {
|
||||
@ -163,9 +164,16 @@ func (s *Source) GetLink(c *caches.Query) (outlink string, msg string) {
|
||||
resp := tx_pool.Get().(*res_tx)
|
||||
defer tx_pool.Put(resp)
|
||||
|
||||
sep := c.Split()
|
||||
url := ztool.Str_FastConcat(api_tx,
|
||||
`{"comm":{"ct":24,"cv":0,"format":"json","uin":"10086"},"req":{"method":"GetCdnDispatch","module":"CDN.SrfCdnDispatchServer","param":{"calltype":0,"guid":"1535153710","userip":""}},"req_0":{"method":"CgiGetVkey","module":"vkey.GetVkeyServer","param":{"guid":"1535153710","loginflag":1,"platform":"20","songmid":["`,
|
||||
c.MusicID, `"],"songtype":[0],"uin":"10086"}}}`,
|
||||
`{"comm":{"ct":24,"cv":0,"format":"json","uin":"10086"},"req":{"method":"GetCdnDispatch","module":"CDN.SrfCdnDispatchServer","param":{"calltype":0,"guid":"1535153710","userip":""}},"req_0":{"method":"CgiGetVkey","module":"vkey.GetVkeyServer","param":{`,
|
||||
func(s string) string {
|
||||
if s == `` {
|
||||
return ``
|
||||
}
|
||||
return ztool.Str_FastConcat(`"filename":["`, rquery, s, `.`, c.Extname, `"],`)
|
||||
}(sep[1]),
|
||||
`"guid":"1535153710","loginflag":1,"platform":"20","songmid":["`, sep[0], `"],"songtype":[0],"uin":"10086"}}}`,
|
||||
)
|
||||
// jx.Debug(`Tx, Url: %s`, url)
|
||||
out, err := ztool.Net_HttpReq(http.MethodGet, url, nil, header_tx, &resp)
|
||||
|
@ -216,32 +216,39 @@ const (
|
||||
|
||||
var (
|
||||
// 音质列表 ( [通用音质][音乐平台]对应音质 )
|
||||
/*
|
||||
注: kg源使用对应hash匹配音质,故为空
|
||||
*/
|
||||
qualitys = map[string]map[string]string{
|
||||
`128k`: {
|
||||
s_wy: `standard`,
|
||||
s_mg: `1`,
|
||||
s_kw: `128k`,
|
||||
s_kg: ``,
|
||||
s_tx: ``,
|
||||
s_tx: `M500`,
|
||||
},
|
||||
`320k`: {
|
||||
s_wy: `exhigh`,
|
||||
s_mg: `2`,
|
||||
s_kw: `320k`,
|
||||
// s_kg: ``,
|
||||
// s_tx: `M800`,
|
||||
},
|
||||
`flac`: {
|
||||
s_wy: `lossless`,
|
||||
s_mg: `3`,
|
||||
s_kw: `2000k`,
|
||||
// s_tx: `F000`,
|
||||
},
|
||||
`flac24bit`: {
|
||||
s_wy: `hires`,
|
||||
s_mg: `4`,
|
||||
// s_tx: `RS01`,
|
||||
},
|
||||
`fl24`: {
|
||||
s_wy: `hires`,
|
||||
s_mg: `4`,
|
||||
},
|
||||
// `fl24`: {
|
||||
// s_wy: `hires`,
|
||||
// s_mg: `4`,
|
||||
// },
|
||||
}
|
||||
// ApiAddr
|
||||
api_wy string
|
||||
|
@ -1,5 +1,12 @@
|
||||
## Lx-Source/更新日志
|
||||
|
||||
#### 2023-12-25 v1.0.2-b0.7 (beta)
|
||||
<!-- + 支持调用 ffmpeg 恢复kg一分钟试听数据真实长度
|
||||
+ (测试版,需要Path里有ffmpeg命令,配置文件 [Main].FFConv=true 开启) -->
|
||||
+ 修复tx试听源,获取128k音质 (原先默认获取的是96k的m4a)
|
||||
+ **很不幸,又要更新客户端脚本了...**
|
||||
+ (要不直接把musicinfo Post到服务端处理吧)
|
||||
|
||||
### 2023-12-24 v1.0.2-b0.6 (beta)
|
||||
#### 功能:
|
||||
<!-- + 将试听接口独立为直连接口,其它源未实现的自动回退到此接口 (可在配置中关闭) -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user