init
This commit is contained in:
89
source/Huibq_lxmusic音源.js
Normal file
89
source/Huibq_lxmusic音源.js
Normal file
@@ -0,0 +1,89 @@
|
||||
/*!
|
||||
* @name Huibq_lxmusic源
|
||||
* @description Github搜索“洛雪音乐音源”,反馈可前往GitHub提Issues或加入群组https://t.me/+Xh7BWUUPqUZlMDU1,禁止批量下载!
|
||||
* @version v1.2.0
|
||||
* @author Huibq
|
||||
*/
|
||||
const DEV_ENABLE = false
|
||||
const API_URL = 'https://render.niuma666bet.buzz'
|
||||
const API_KEY = 'share-v2'
|
||||
const MUSIC_QUALITY = {
|
||||
kw: ['128k', '320k'],
|
||||
kg: ['128k', '320k'],
|
||||
tx: ['128k', '320k'],
|
||||
wy: ['128k', '320k'],
|
||||
mg: ['128k', '320k'],
|
||||
}
|
||||
const MUSIC_SOURCE = Object.keys(MUSIC_QUALITY)
|
||||
const { EVENT_NAMES, request, on, send, utils, env, version } = globalThis.lx
|
||||
const httpFetch = (url, options = { method: 'GET' }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(url, options, (err, resp) => {
|
||||
if (err) return reject(err)
|
||||
resolve(resp)
|
||||
})
|
||||
})
|
||||
}
|
||||
const handleGetMusicUrl = async (source, musicInfo, quality) => {
|
||||
const songId = musicInfo.hash ?? musicInfo.songmid
|
||||
|
||||
const request = await httpFetch(`${API_URL}/url/${source}/${songId}/${quality}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': `${env ? `lx-music-${env}/${version}` : `lx-usic-request/${version}`}`,
|
||||
'X-Request-Key': API_KEY,
|
||||
},
|
||||
})
|
||||
const { body } = request
|
||||
if (!body || isNaN(Number(body.code))) throw new Error('unknow error')
|
||||
switch (body.code) {
|
||||
case 0:
|
||||
return body.url
|
||||
case 1:
|
||||
throw new Error('block ip')
|
||||
case 2:
|
||||
throw new Error('get music url failed')
|
||||
case 4:
|
||||
throw new Error('internal server error')
|
||||
case 5:
|
||||
throw new Error('too many requests')
|
||||
case 6:
|
||||
throw new Error('param error')
|
||||
default:
|
||||
throw new Error(body.msg ?? 'unknow error')
|
||||
}
|
||||
}
|
||||
const musicSources = {}
|
||||
MUSIC_SOURCE.forEach(item => {
|
||||
musicSources[item] = {
|
||||
name: item,
|
||||
type: 'music',
|
||||
actions: ['musicUrl'],
|
||||
qualitys: MUSIC_QUALITY[item],
|
||||
}
|
||||
})
|
||||
on(EVENT_NAMES.request, ({ action, source, info }) => {
|
||||
switch (action) {
|
||||
case 'musicUrl':
|
||||
if (env != 'mobile') {
|
||||
console.group(`Handle Action(musicUrl)`)
|
||||
console.log('source', source)
|
||||
console.log('quality', info.type)
|
||||
console.log('musicInfo', info.musicInfo)
|
||||
console.groupEnd()
|
||||
} else {
|
||||
console.log(`Handle Action(musicUrl)`)
|
||||
console.log('source', source)
|
||||
console.log('quality', info.type)
|
||||
console.log('musicInfo', info.musicInfo)
|
||||
}
|
||||
return handleGetMusicUrl(source, info.musicInfo, info.type)
|
||||
.then(data => Promise.resolve(data))
|
||||
.catch(err => Promise.reject(err))
|
||||
default:
|
||||
console.error(`action(${action}) not support`)
|
||||
return Promise.reject('action not support')
|
||||
}
|
||||
})
|
||||
send(EVENT_NAMES.inited, { status: true, openDevTools: DEV_ENABLE, sources: musicSources })
|
||||
17
source/[独家音源] v4.0.js
Normal file
17
source/[独家音源] v4.0.js
Normal file
File diff suppressed because one or more lines are too long
7
source/聚合API音源.js
Normal file
7
source/聚合API音源.js
Normal file
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* @name 聚合API接口 (CF)
|
||||
* @description v3
|
||||
* @version 3
|
||||
* @author lerd
|
||||
*/
|
||||
let{stringify:t,parse:a}=JSON;let x=(r)=>{throw new Error(r)};let{EVENT_NAMES:n,request:b,on,send:y,version:v}=globalThis.lx;let A='https://api.music.lerd.dpdns.org';let h=(u,o={method:'GET'})=>new Promise((s,j)=>{b(u,o,(e,r)=>{if(e)return j(e);s(r)})});h(A+'/init.conf').then(r=>{if(r.body.code!==200)x("脚本初始化失败");let U=r.body.data;if(U.update.version>v)y(n.updateAlert,U.update);y(n.inited,U.init);}).catch(e=>x(e));on(n.request,async({action,source,info})=>{let r=await h(`${A}/${source}`,{method:'POST',body:t(info),headers:{'Content-Type':'application/json'}});let B=r.body;if(B.code===200)return B.data.url;else if(B.code===303){let S=a(t(B.data));let D=S.request;let F=S.response;try{let z=await h(encodeURI(D.url),D.options);if(F.check.key.reduce((a,c)=>a&&a[c],z)==F.check.value){let u=F.url.reduce((a,c)=>a&&a[c],z);if(u.startsWith("http"))return u;}}catch(e){x(e)}}else x(B.msg);});
|
||||
5
source/野花音源.js
Normal file
5
source/野花音源.js
Normal file
File diff suppressed because one or more lines are too long
5
source/野草音源.js
Normal file
5
source/野草音源.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user