From 115b365493739f81fe4f567e93f10da35fe2cad1 Mon Sep 17 00:00:00 2001 From: TRAE Bot Date: Sun, 5 Jul 2026 17:50:07 +0000 Subject: [PATCH] release v0.1.2: rewrite all plugins based on official zq_tx_v3 format --- ...0_QZv2.js => Koneko_聆澜_GIT音源_v0.1.2_QZv2.js} | 88 ++++++++++----- ....0_QZv2.js => Koneko_聆澜_QQ音乐_v0.1.2_QZv2.js} | 102 ++++++++++------- ....0_QZv2.js => Koneko_聆澜_咪咕音乐_v0.1.2_QZv2.js} | 59 ++++++---- ...0_QZv2.js => Koneko_聆澜_网易云音乐_v0.1.2_QZv2.js} | 106 ++++++++++-------- ....0_QZv2.js => Koneko_聆澜_酷我音乐_v0.1.2_QZv2.js} | 60 ++++++---- ....0_QZv2.js => Koneko_聆澜_酷狗音乐_v0.1.2_QZv2.js} | 63 ++++++----- 6 files changed, 290 insertions(+), 188 deletions(-) rename 聆澜/{Koneko_聆澜_GIT音源_v0.1.0_QZv2.js => Koneko_聆澜_GIT音源_v0.1.2_QZv2.js} (72%) rename 聆澜/{Koneko_聆澜_QQ音乐_v0.1.0_QZv2.js => Koneko_聆澜_QQ音乐_v0.1.2_QZv2.js} (81%) rename 聆澜/{Koneko_聆澜_咪咕音乐_v0.1.0_QZv2.js => Koneko_聆澜_咪咕音乐_v0.1.2_QZv2.js} (79%) rename 聆澜/{Koneko_聆澜_网易云音乐_v0.1.0_QZv2.js => Koneko_聆澜_网易云音乐_v0.1.2_QZv2.js} (90%) rename 聆澜/{Koneko_聆澜_酷我音乐_v0.1.0_QZv2.js => Koneko_聆澜_酷我音乐_v0.1.2_QZv2.js} (78%) rename 聆澜/{Koneko_聆澜_酷狗音乐_v0.1.0_QZv2.js => Koneko_聆澜_酷狗音乐_v0.1.2_QZv2.js} (79%) diff --git a/聆澜/Koneko_聆澜_GIT音源_v0.1.0_QZv2.js b/聆澜/Koneko_聆澜_GIT音源_v0.1.2_QZv2.js similarity index 72% rename from 聆澜/Koneko_聆澜_GIT音源_v0.1.0_QZv2.js rename to 聆澜/Koneko_聆澜_GIT音源_v0.1.2_QZv2.js index 85567c7..8c3467b 100644 --- a/聆澜/Koneko_聆澜_GIT音源_v0.1.0_QZv2.js +++ b/聆澜/Koneko_聆澜_GIT音源_v0.1.2_QZv2.js @@ -56,13 +56,23 @@ function requestUrl(urlStr, method, headers, body) { return doRequest(protocol, options, postData); } -function formatPlayTime(seconds) { - if (!seconds) return '00:00'; - var m = Math.floor(seconds / 60); - var s = Math.floor(seconds % 60); +// ===== 格式化辅助 ===== +function formatPlayTime(time) { + if (!time) return '--/--'; + var m = Math.floor(time / 60); + var s = Math.floor(time % 60); + if (m === 0 && s === 0) return '--/--'; return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); } +function sizeFormate(bytes) { + if (typeof bytes === 'string') bytes = parseFloat(bytes.replace(/[^0-9.]/g, '')); + var n = parseFloat(bytes); + if (isNaN(n) || n < 0) return '0.00MB'; + var mb = n / (1024 * 1024); + return mb.toFixed(2) + 'MB'; +} + // ===== Git音源配置 ===== var GITCODE_CONFIG = { owner: 'ikun_0014', repo: 'music', token: 'WzsER9knWNgC_4tjeJCtHKcN' }; function getGitcodeUrl() { @@ -71,6 +81,7 @@ function getGitcodeUrl() { var cachedList = null; var cacheTime = 0; var CACHE_TTL = 5 * 60 * 1000; +var cachedLyricMap = null; function fetchAllGitMusic() { var now = Date.now(); @@ -78,22 +89,39 @@ function fetchAllGitMusic() { return requestUrl(getGitcodeUrl(), 'GET', { 'User-Agent': 'Mozilla/5.0' }).then(function(res) { var body = Array.isArray(res.body) ? res.body : []; var list = []; - for (var i = 0; i < body.length; i++) list.push(formatGitItem(body[i])); + var lyricMap = {}; + for (var i = 0; i < body.length; i++) { + var formatted = formatGitItem(body[i]); + if (formatted) { + list.push(formatted); + var lid = formatted.id; + if (lid) lyricMap[lid] = (body[i].lyrics || body[i].lyric || ''); + } + } cachedList = list; + cachedLyricMap = lyricMap; cacheTime = now; return list; }); } function formatGitItem(item) { + if (!item) return null; var qualities = {}; var fmt = (item.format || '').toLowerCase(); - if (fmt === 'flac' && item.filesize) qualities.lossless = String(item.filesize); - else if (fmt === 'mp3' && item.filesize) qualities.exhigh = String(item.filesize); - else if (item.filesize) qualities.standard = String(item.filesize); - var picUrl = item.img || ''; + if (fmt === 'flac' && item.filesize) { + qualities['flac'] = sizeFormate(item.filesize); + qualities['320k'] = sizeFormate(item.filesize); + } else if (fmt === 'mp3' && item.filesize) { + if (item.bitrate && Number(item.bitrate) >= 320) qualities['320k'] = sizeFormate(item.filesize); + else qualities['128k'] = sizeFormate(item.filesize); + } else if (item.filesize) { + qualities['128k'] = sizeFormate(item.filesize); + } + var picUrl = item.img || item.cover || ''; + var songId = item.hash || item.relative_path || item.id || ''; return { - id: item.relative_path || '', + id: String(songId), name: item.title || item.filename || '', artists: item.artist || '未知歌手', source: 'git', @@ -101,10 +129,9 @@ function formatGitItem(item) { mPic: picUrl, sPic: picUrl, albumName: item.album || '未知专辑', - albumId: '', - interval: '', - qualities: qualities, - _gitcodeData: item + albumId: String(item.albumId || ''), + interval: String(formatPlayTime(item.duration) || '--/--'), + qualities: qualities }; } @@ -138,14 +165,14 @@ function search(str, page, limit, retryNum) { } // ===== 播放链接 ===== -function getUrl(songInfo, type) { - var q = (type === 'standard' ? '128k' : type === 'exhigh' ? '320k' : type === 'lossless' || type === 'hires' || type === 'jymaster' ? 'flac' : type) || '128k'; - var songId = songInfo.id || ''; +function getUrl(songId, quality) { + songId = String(songId || ''); + quality = String(quality || '128k'); if (!songId) return Promise.resolve(''); var ceruKey = CERU_KEY || ''; var headers = { 'User-Agent': 'QZMusic/2.0' }; if (ceruKey) headers['X-API-Key'] = ceruKey; - return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=git&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(q), 'GET', headers) + return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=git&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(quality), 'GET', headers) .then(function(res) { if (res.body && typeof res.body === 'object' && res.body.url) return res.body.url; if (res.body && typeof res.body === 'object' && res.body.data && res.body.data.url) return res.body.data.url; @@ -156,14 +183,19 @@ function getUrl(songInfo, type) { // ===== 封面图 ===== function getPic(songInfo) { - if (songInfo.pic) return Promise.resolve(songInfo.pic); + if (songInfo && songInfo.pic) return Promise.resolve(songInfo.pic); return Promise.resolve(''); } // ===== 歌词 ===== function getLyric(songInfo) { - if (songInfo._gitcodeData && songInfo._gitcodeData.lyrics) return Promise.resolve(songInfo._gitcodeData.lyrics); - return Promise.resolve(''); + var id = (songInfo && songInfo.id) || ''; + if (!id) return Promise.resolve(''); + if (cachedLyricMap && cachedLyricMap[id]) return Promise.resolve(cachedLyricMap[id]); + return fetchAllGitMusic().then(function() { + if (cachedLyricMap && cachedLyricMap[id]) return cachedLyricMap[id]; + return ''; + }).catch(function() { return ''; }); } // ===== 音乐详情 ===== @@ -195,18 +227,18 @@ var pluginInfo = { info: { id: 'koneko_ceru_git', name: 'GIT音源 - Koneko 聆澜', - version: '0.1.0', + version: '0.1.2', source: 'git', - description: 'GIT音源,基于 CeruMusic musicSdk 搜索 + Ceru 播放接口' + description: 'GIT音源,基于 GitCode audio_database.json 本地搜索 + Ceru 播放接口' }, ext: [], env: [{ key: 'ceru_key', name: 'Ceru API Key', description: '聆澜播放接口密钥' }], quality: [ - { name: '标准', ui: '标', id: '128k' }, - { name: '高品', ui: 'HQ', id: '320k' }, - { name: '无损', ui: 'SQ', id: 'flac' } + { name: '标准音质', ui: '标', id: '128k' }, + { name: '高品音质', ui: 'HQ', id: '320k' }, + { name: '无损音质', ui: 'SQ', id: 'flac' } ], - supportFunc: [] + supportFunc: ['search_song', 'search_playlist', 'playlist', 'album', 'lyric'] } module.exports = { @@ -215,7 +247,7 @@ module.exports = { hotSearch: { getList: hotSearch }, leaderboard: { getBoards: leaderboard }, songList: songList, - artists: singer, + singer: singer, album: album, getLyric: getLyric, getPic: getPic, diff --git a/聆澜/Koneko_聆澜_QQ音乐_v0.1.0_QZv2.js b/聆澜/Koneko_聆澜_QQ音乐_v0.1.2_QZv2.js similarity index 81% rename from 聆澜/Koneko_聆澜_QQ音乐_v0.1.0_QZv2.js rename to 聆澜/Koneko_聆澜_QQ音乐_v0.1.2_QZv2.js index 823cfc1..ae03749 100644 --- a/聆澜/Koneko_聆澜_QQ音乐_v0.1.0_QZv2.js +++ b/聆澜/Koneko_聆澜_QQ音乐_v0.1.2_QZv2.js @@ -56,6 +56,30 @@ function requestUrl(urlStr, method, headers, body) { return doRequest(protocol, options, postData); } +// ===== 格式化辅助 ===== +function formatPlayTime(time) { + if (!time) return '--/--'; + var m = Math.floor(time / 60); + var s = Math.floor(time % 60); + if (m === 0 && s === 0) return '--/--'; + return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); +} + +function sizeFormate(bytes) { + if (typeof bytes === 'string') bytes = parseFloat(bytes.replace(/[^0-9.]/g, '')); + var n = parseFloat(bytes); + if (isNaN(n) || n < 0) return '0.00MB'; + var mb = n / (1024 * 1024); + return mb.toFixed(2) + 'MB'; +} + +function formatSingerName(arr, key) { + if (!arr || !arr.length) return ''; + var names = []; + for (var i = 0; i < arr.length; i++) names.push(arr[i][key] || arr[i]); + return names.join('、'); +} + // ===== QQ音乐zzcSign ===== var PART_1_INDEXES = [23, 14, 6, 36, 16, 40, 7, 19]; var PART_2_INDEXES = [16, 1, 32, 12, 19, 27, 8, 5]; @@ -105,13 +129,6 @@ function signRequest(data) { }, JSON.stringify(data)); } -function formatPlayTime(seconds) { - if (!seconds) return '00:00'; - var m = Math.floor(seconds / 60); - var s = Math.floor(seconds % 60); - return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); -} - // ===== 搜索实现 ===== function musicSearch(str, page, limit) { var body = { @@ -126,37 +143,33 @@ function musicSearch(str, page, limit) { function handleSearchResult(rawList) { var list = []; + if (!rawList) return list; for (var i = 0; i < rawList.length; i++) { var item = rawList[i]; if (!item.file || !item.file.media_mid) continue; var qualities = {}; var file = item.file; - if (file.size_128mp3 !== 0) qualities.standard = String(file.size_128mp3 || ''); - if (file.size_320mp3 !== 0) qualities.exhigh = String(file.size_320mp3 || ''); - if (file.size_flac !== 0) qualities.lossless = String(file.size_flac || ''); - if (file.size_hires !== 0) qualities.hires = String(file.size_hires || ''); + if (file.size_128mp3) qualities['128k'] = sizeFormate(file.size_128mp3); + if (file.size_320mp3) qualities['320k'] = sizeFormate(file.size_320mp3); + if (file.size_flac) qualities['flac'] = sizeFormate(file.size_flac); var albumId = ''; var albumName = ''; if (item.album) { albumName = item.album.name; albumId = item.album.mid; } - var singerName = ''; - if (item.singer && item.singer.length) { - var ns = []; - for (var j = 0; j < item.singer.length; j++) ns.push(item.singer[j].name); - singerName = ns.join('、'); - } - var picUrl = albumId ? 'https://y.gtimg.cn/music/photo_new/T002R500x500M000' + albumId + '.jpg' : (item.singer && item.singer.length ? 'https://y.gtimg.cn/music/photo_new/T001R500x500M000' + item.singer[0].mid + '.jpg' : ''); + var singerName = formatSingerName(item.singer, 'name'); + var picUrl = albumId && albumId !== '空' + ? 'https://y.gtimg.cn/music/photo_new/T002R500x500M000' + albumId + '.jpg' + : (item.singer && item.singer.length ? 'https://y.gtimg.cn/music/photo_new/T001R500x500M000' + item.singer[0].mid + '.jpg' : ''); list.push({ - id: item.mid, - songId: item.id, + id: String(item.mid), name: item.name + (item.title_extra || ''), artists: singerName, source: 'tx', - interval: formatPlayTime(item.interval), pic: picUrl, mPic: picUrl, sPic: picUrl, albumName: albumName, - albumId: albumId, + albumId: String(albumId || ''), + interval: String(formatPlayTime(item.interval) || '--/--'), qualities: qualities }); } @@ -177,13 +190,13 @@ function search(str, page, limit, retryNum) { } // ===== 播放链接 ===== -function getUrl(songInfo, type) { - var q = (type === 'standard' ? '128k' : type === 'exhigh' ? '320k' : type === 'lossless' || type === 'hires' || type === 'jymaster' ? 'flac' : type) || '128k'; - var songId = songInfo.id || songInfo.songId || ''; +function getUrl(songId, quality) { + songId = String(songId || ''); + quality = String(quality || '128k'); var ceruKey = CERU_KEY || ''; var headers = { 'User-Agent': 'QZMusic/2.0' }; if (ceruKey) headers['X-API-Key'] = ceruKey; - return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=tx&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(q), 'GET', headers) + return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=tx&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(quality), 'GET', headers) .then(function(res) { if (res.body && typeof res.body === 'object' && res.body.url) return res.body.url; if (res.body && typeof res.body === 'object' && res.body.data && res.body.data.url) return res.body.data.url; @@ -194,16 +207,15 @@ function getUrl(songInfo, type) { // ===== 封面图 ===== function getPic(songInfo) { - if (songInfo.pic) return Promise.resolve(songInfo.pic); - if (songInfo.img) return Promise.resolve(songInfo.img); - var albumId = songInfo.albumId || ''; + if (songInfo && songInfo.pic) return Promise.resolve(songInfo.pic); + var albumId = songInfo && songInfo.albumId ? String(songInfo.albumId) : ''; if (albumId) return Promise.resolve('https://y.gtimg.cn/music/photo_new/T002R500x500M000' + albumId + '.jpg'); return Promise.resolve(''); } // ===== 歌词 ===== function getLyric(songInfo) { - var songmid = songInfo.id || ''; + var songmid = (songInfo && songInfo.id) || (songInfo && songInfo.songId) || ''; return requestUrl('https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?format=json&nobase64=1&songmid=' + encodeURIComponent(songmid), 'GET', { 'User-Agent': 'Mozilla/5.0 (Linux; Android 10)', 'Referer': 'https://y.qq.com/portal/player.html' @@ -226,15 +238,19 @@ function musicDetail(songmid) { if (res.body && res.body.req && res.body.req.data && res.body.req.data.info && res.body.req.data.info.track_info) { var t = res.body.req.data.info.track_info; var albumId = t.album ? t.album.mid : ''; - var singerName = ''; - if (t.singer && t.singer.length) { var ns = []; for (var j = 0; j < t.singer.length; j++) ns.push(t.singer[j].name); singerName = ns.join('、'); } + var singerName = formatSingerName(t.singer, 'name'); var picUrl = albumId ? 'https://y.gtimg.cn/music/photo_new/T002R500x500M000' + albumId + '.jpg' : ''; return { - id: t.mid, songId: t.id, - name: t.name, artists: singerName, - albumName: t.album ? t.album.name : '', albumId: albumId, - source: 'tx', interval: formatPlayTime(t.interval), - pic: picUrl, mPic: picUrl, sPic: picUrl, + id: String(t.mid), + name: t.name, + artists: singerName, + source: 'tx', + pic: picUrl, + mPic: picUrl, + sPic: picUrl, + albumName: t.album ? t.album.name : '', + albumId: String(albumId || ''), + interval: String(formatPlayTime(t.interval) || '--/--'), qualities: {} }; } @@ -294,18 +310,18 @@ var pluginInfo = { info: { id: 'koneko_ceru_tx', name: 'QQ音乐 - Koneko 聆澜', - version: '0.1.0', + version: '0.1.2', source: 'tx', description: 'QQ音乐音源,基于 CeruMusic musicSdk 搜索 + Ceru 播放接口' }, ext: [], env: [{ key: 'ceru_key', name: 'Ceru API Key', description: '聆澜播放接口密钥' }], quality: [ - { name: '标准', ui: '标', id: '128k' }, - { name: '高品', ui: 'HQ', id: '320k' }, - { name: '无损', ui: 'SQ', id: 'flac' } + { name: '标准音质', ui: '标', id: '128k' }, + { name: '高品音质', ui: 'HQ', id: '320k' }, + { name: '无损音质', ui: 'SQ', id: 'flac' } ], - supportFunc: [] + supportFunc: ['search_song', 'search_playlist', 'playlist', 'album', 'lyric'] } module.exports = { @@ -314,7 +330,7 @@ module.exports = { hotSearch: { getList: hotSearch }, leaderboard: { getBoards: leaderboard }, songList: songList, - artists: singer, + singer: singer, album: album, getLyric: getLyric, getPic: getPic, diff --git a/聆澜/Koneko_聆澜_咪咕音乐_v0.1.0_QZv2.js b/聆澜/Koneko_聆澜_咪咕音乐_v0.1.2_QZv2.js similarity index 79% rename from 聆澜/Koneko_聆澜_咪咕音乐_v0.1.0_QZv2.js rename to 聆澜/Koneko_聆澜_咪咕音乐_v0.1.2_QZv2.js index c92e087..d45392d 100644 --- a/聆澜/Koneko_聆澜_咪咕音乐_v0.1.0_QZv2.js +++ b/聆澜/Koneko_聆澜_咪咕音乐_v0.1.2_QZv2.js @@ -56,13 +56,23 @@ function requestUrl(urlStr, method, headers, body) { return doRequest(protocol, options, postData); } -function formatPlayTime(seconds) { - if (!seconds) return '00:00'; - var m = Math.floor(seconds / 60); - var s = Math.floor(seconds % 60); +// ===== 格式化辅助 ===== +function formatPlayTime(time) { + if (!time) return '--/--'; + var m = Math.floor(time / 60); + var s = Math.floor(time % 60); + if (m === 0 && s === 0) return '--/--'; return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); } +function sizeFormate(bytes) { + if (typeof bytes === 'string') bytes = parseFloat(bytes.replace(/[^0-9.]/g, '')); + var n = parseFloat(bytes); + if (isNaN(n) || n < 0) return '0.00MB'; + var mb = n / (1024 * 1024); + return mb.toFixed(2) + 'MB'; +} + // ===== 搜索实现 ===== function musicSearch(str, page, limit) { var url = 'https://jadeite.migu.cn/music_search/v3/search?text=' + encodeURIComponent(str) + '&pageNo=' + page + '&pageSize=' + limit + '&searchSwitch={"song":1}'; @@ -78,21 +88,24 @@ function musicSearch(str, page, limit) { function handleSearchResult(rawList) { var list = []; + if (!rawList) return list; for (var i = 0; i < rawList.length; i++) { var item = rawList[i]; var qualities = {}; if (item.newRateFormats) { for (var j = 0; j < item.newRateFormats.length; j++) { var fmt = item.newRateFormats[j]; - if (fmt.formatType === 'SQ' && fmt.size) qualities.lossless = String(fmt.size); - if (fmt.formatType === 'HQ' && fmt.size) qualities.exhigh = String(fmt.size); - if (fmt.formatType === 'LQ' && fmt.size) qualities.standard = String(fmt.size); + if (fmt.formatType === 'LQ' && fmt.size) qualities['128k'] = sizeFormate(fmt.size); + if (fmt.formatType === 'HQ' && fmt.size) qualities['320k'] = sizeFormate(fmt.size); + if (fmt.formatType === 'SQ' && fmt.size) qualities['flac'] = sizeFormate(fmt.size); } } var picUrl = item.img || (item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : ''); - if (picUrl && picUrl.startsWith('/')) picUrl = 'https://d.musicapp.migu.cn' + picUrl; + if (picUrl && picUrl.indexOf('/') === 0) picUrl = 'https://d.musicapp.migu.cn' + picUrl; + var intervalStr = item.length ? String(item.length).replace(/.*(\d\d:\d\d)$/, '$1') : '--/--'; + if (!intervalStr) intervalStr = '--/--'; list.push({ - id: item.copyrightId || item.id || '', + id: String(item.copyrightId || item.id || ''), name: item.title || item.songName || '', artists: item.artist || item.singerName || '', source: 'mg', @@ -100,8 +113,8 @@ function handleSearchResult(rawList) { mPic: picUrl, sPic: picUrl, albumName: item.album || item.albumName || '', - albumId: item.albumId || '', - interval: item.length ? item.length.replace(/.*(\d\d:\d\d)$/, '$1') : '', + albumId: String(item.albumId || ''), + interval: intervalStr, qualities: qualities }); } @@ -119,13 +132,13 @@ function search(str, page, limit, retryNum) { } // ===== 播放链接 ===== -function getUrl(songInfo, type) { - var q = (type === 'standard' ? '128k' : type === 'exhigh' ? '320k' : type === 'lossless' || type === 'hires' || type === 'jymaster' ? 'flac' : type) || '128k'; - var songId = songInfo.id || ''; +function getUrl(songId, quality) { + songId = String(songId || ''); + quality = String(quality || '128k'); var ceruKey = CERU_KEY || ''; var headers = { 'User-Agent': 'QZMusic/2.0' }; if (ceruKey) headers['X-API-Key'] = ceruKey; - return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=mg&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(q), 'GET', headers) + return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=mg&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(quality), 'GET', headers) .then(function(res) { if (res.body && typeof res.body === 'object' && res.body.url) return res.body.url; if (res.body && typeof res.body === 'object' && res.body.data && res.body.data.url) return res.body.data.url; @@ -136,13 +149,13 @@ function getUrl(songInfo, type) { // ===== 封面图 ===== function getPic(songInfo) { - if (songInfo.pic) return Promise.resolve(songInfo.pic); + if (songInfo && songInfo.pic) return Promise.resolve(songInfo.pic); return Promise.resolve(''); } // ===== 歌词 ===== function getLyric(songInfo) { - var copyrightId = songInfo.id || ''; + var copyrightId = (songInfo && songInfo.id) || ''; if (!copyrightId) return Promise.resolve(''); return requestUrl('http://music.migu.cn/v3/api/music/audioPlayer/getLyric?copyrightId=' + encodeURIComponent(copyrightId), 'GET', { 'User-Agent': 'Mozilla/5.0 (Linux; Android 10)', @@ -182,18 +195,18 @@ var pluginInfo = { info: { id: 'koneko_ceru_mg', name: '咪咕音乐 - Koneko 聆澜', - version: '0.1.0', + version: '0.1.2', source: 'mg', description: '咪咕音乐音源,基于 CeruMusic musicSdk 搜索 + Ceru 播放接口' }, ext: [], env: [{ key: 'ceru_key', name: 'Ceru API Key', description: '聆澜播放接口密钥' }], quality: [ - { name: '标准', ui: '标', id: '128k' }, - { name: '高品', ui: 'HQ', id: '320k' }, - { name: '无损', ui: 'SQ', id: 'flac' } + { name: '标准音质', ui: '标', id: '128k' }, + { name: '高品音质', ui: 'HQ', id: '320k' }, + { name: '无损音质', ui: 'SQ', id: 'flac' } ], - supportFunc: [] + supportFunc: ['search_song', 'search_playlist', 'playlist', 'album', 'lyric'] } module.exports = { @@ -202,7 +215,7 @@ module.exports = { hotSearch: { getList: hotSearch }, leaderboard: { getBoards: leaderboard }, songList: songList, - artists: singer, + singer: singer, album: album, getLyric: getLyric, getPic: getPic, diff --git a/聆澜/Koneko_聆澜_网易云音乐_v0.1.0_QZv2.js b/聆澜/Koneko_聆澜_网易云音乐_v0.1.2_QZv2.js similarity index 90% rename from 聆澜/Koneko_聆澜_网易云音乐_v0.1.0_QZv2.js rename to 聆澜/Koneko_聆澜_网易云音乐_v0.1.2_QZv2.js index 19e1f77..737a53c 100644 --- a/聆澜/Koneko_聆澜_网易云音乐_v0.1.0_QZv2.js +++ b/聆澜/Koneko_聆澜_网易云音乐_v0.1.2_QZv2.js @@ -112,12 +112,22 @@ function weapi(params) { } // ===== 格式化辅助 ===== -function formatPlayTime(seconds) { - var m = Math.floor(seconds / 60); - var s = Math.floor(seconds % 60); +function formatPlayTime(time) { + if (!time) return '--/--'; + var m = Math.floor(time / 60); + var s = Math.floor(time % 60); + if (m === 0 && s === 0) return '--/--'; return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); } +function sizeFormate(bytes) { + if (typeof bytes === 'string') bytes = parseFloat(bytes.replace(/[^0-9.]/g, '')); + var n = parseFloat(bytes); + if (isNaN(n) || n < 0) return '0.00MB'; + var mb = n / (1024 * 1024); + return mb.toFixed(2) + 'MB'; +} + function formatSingerName(arr, key) { if (!arr || !arr.length) return ''; var names = []; @@ -125,6 +135,13 @@ function formatSingerName(arr, key) { return names.join('、'); } +function formatPlayCount(count) { + if (!count && count !== 0) return ''; + if (count >= 100000000) return (count / 100000000).toFixed(1) + '亿'; + if (count >= 10000) return (count / 10000).toFixed(1) + '万'; + return String(count); +} + // ===== 搜索实现 ===== function musicSearch(str, page, limit) { var form = eapi('/api/search/song/list/page', { @@ -154,14 +171,12 @@ function handleSearchResult(rawList) { if (!item.baseInfo || !item.baseInfo.simpleSongData) continue; var s = item.baseInfo.simpleSongData; var qualities = {}; - if (s.l && s.l.size) qualities.standard = String(s.l.size); - if (s.m && s.m.size) qualities.standard = String(s.m.size); - if (s.h && s.h.size) qualities.exhigh = String(s.h.size); - if (s.sq && s.sq.size) qualities.lossless = String(s.sq.size); - if (s.hr && s.hr.size) qualities.hires = String(s.hr.size); + if (s.l && s.l.size) qualities['128k'] = sizeFormate(s.l.size); + if (s.h && s.h.size) qualities['320k'] = sizeFormate(s.h.size); + if (s.sq && s.sq.size) qualities['flac'] = sizeFormate(s.sq.size); var picUrl = s.al && s.al.picUrl ? s.al.picUrl : ''; list.push({ - id: s.id, + id: String(s.id), name: s.name, artists: formatSingerName(s.ar, 'name'), source: 'wy', @@ -169,8 +184,8 @@ function handleSearchResult(rawList) { mPic: picUrl, sPic: picUrl, albumName: s.al && s.al.name ? s.al.name : '', - albumId: s.al && s.al.id ? s.al.id : '', - interval: formatPlayTime((s.dt || 0) / 1000), + albumId: String(s.al && s.al.id ? s.al.id : ''), + interval: String(formatPlayTime((s.dt || 0) / 1000) || '--/--'), qualities: qualities }); } @@ -197,13 +212,13 @@ function search(str, page, limit, retryNum) { } // ===== 播放链接 ===== -function getUrl(songInfo, type) { - var q = (type === 'standard' ? '128k' : type === 'exhigh' ? '320k' : type === 'lossless' || type === 'hires' || type === 'jymaster' ? 'flac' : type) || '128k'; - var songId = songInfo.id || ''; +function getUrl(songId, quality) { + songId = String(songId || ''); + quality = String(quality || '128k'); var ceruKey = CERU_KEY || ''; var headers = { 'User-Agent': 'QZMusic/2.0' }; if (ceruKey) headers['X-API-Key'] = ceruKey; - return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=wy&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(q), 'GET', headers) + return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=wy&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(quality), 'GET', headers) .then(function(res) { if (res.body && typeof res.body === 'object' && res.body.url) return res.body.url; if (res.body && typeof res.body === 'object' && res.body.data && res.body.data.url) return res.body.data.url; @@ -215,14 +230,16 @@ function getUrl(songInfo, type) { // ===== 封面图 ===== function getPic(songInfo) { - if (songInfo.pic) return Promise.resolve(songInfo.pic); + if (songInfo && songInfo.pic) return Promise.resolve(songInfo.pic); + var id = songInfo && songInfo.id ? String(songInfo.id) : ''; + if (!id) return Promise.resolve(''); return requestUrl('https://music.163.com/weapi/v3/song/detail', 'POST', { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36', - 'Referer': 'https://music.163.com/song?id=' + songInfo.id, + 'Referer': 'https://music.163.com/song?id=' + id, 'Origin': 'https://music.163.com', 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': WY_COOKIE - }, querystring.stringify(weapi({ c: '[{"id":' + songInfo.id + '}]', ids: '[' + songInfo.id + ']' }))) + }, querystring.stringify(weapi({ c: '[{"id":' + id + '}]', ids: '[' + id + ']' }))) .then(function(res) { if (res.body && res.body.songs && res.body.songs.length) return res.body.songs[0].al.picUrl; return ''; @@ -232,8 +249,8 @@ function getPic(songInfo) { // ===== 歌词 ===== function getLyric(songInfo) { - var songmid = songInfo.id || ''; - return requestUrl('https://music.163.com/api/song/lyric?id=' + songmid + '&lv=1&kv=1&tv=-1', 'GET', { + var songmid = (songInfo && songInfo.id) || ''; + return requestUrl('https://music.163.com/api/song/lyric?id=' + encodeURIComponent(songmid) + '&lv=1&kv=1&tv=-1', 'GET', { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36', 'Referer': 'https://music.163.com/song?id=' + songmid, 'Cookie': WY_COOKIE @@ -256,7 +273,7 @@ function musicDetail(songmid) { var s = res.body.songs[0]; var picUrl = s.al && s.al.picUrl ? s.al.picUrl : ''; return { - id: s.id, + id: String(s.id), name: s.name, artists: formatSingerName(s.ar, 'name'), source: 'wy', @@ -264,8 +281,8 @@ function musicDetail(songmid) { mPic: picUrl, sPic: picUrl, albumName: s.al && s.al.name ? s.al.name : '', - albumId: s.al && s.al.id ? s.al.id : '', - interval: formatPlayTime((s.dt || 0) / 1000), + albumId: String(s.al && s.al.id ? s.al.id : ''), + interval: String(formatPlayTime((s.dt || 0) / 1000) || '--/--'), qualities: {} }; } @@ -356,7 +373,7 @@ function leaderboardGetList(id, page) { var item = tracks[i]; var picUrl = item.al && item.al.picUrl ? item.al.picUrl : ''; list.push({ - id: item.id, + id: String(item.id), name: item.name, artists: formatSingerName(item.ar, 'name'), source: 'wy', @@ -364,8 +381,8 @@ function leaderboardGetList(id, page) { mPic: picUrl, sPic: picUrl, albumName: item.al && item.al.name ? item.al.name : '', - albumId: item.al && item.al.id ? item.al.id : '', - interval: formatPlayTime((item.dt || 0) / 1000), + albumId: String(item.al && item.al.id ? item.al.id : ''), + interval: String(formatPlayTime((item.dt || 0) / 1000) || '--/--'), qualities: {} }); } @@ -373,14 +390,11 @@ function leaderboardGetList(id, page) { }).catch(function() { return { list: [], total: 0, source: 'wy' }; }); } -// ===== 歌单 ===== -function formatPlayCount(count) { - if (!count && count !== 0) return ''; - if (count >= 100000000) return (count / 100000000).toFixed(1) + '亿'; - if (count >= 10000) return (count / 10000).toFixed(1) + '万'; - return String(count); +function leaderboard() { + return Promise.resolve(BOARD_LIST); } +// ===== 歌单 ===== var songList = { limit_list: 30, sortList: [ @@ -461,14 +475,14 @@ var songList = { var item = tracks[i]; var picUrl = item.al && item.al.picUrl ? item.al.picUrl : ''; list.push({ - id: item.id, + id: String(item.id), name: item.name, artists: formatSingerName(item.ar, 'name'), source: 'wy', pic: picUrl, mPic: picUrl, sPic: picUrl, albumName: item.al && item.al.name ? item.al.name : '', - albumId: item.al && item.al.id ? item.al.id : '', - interval: formatPlayTime((item.dt || 0) / 1000), + albumId: String(item.al && item.al.id ? item.al.id : ''), + interval: String(formatPlayTime((item.dt || 0) / 1000) || '--/--'), qualities: {} }); } @@ -532,11 +546,11 @@ var singer = { var item = res.body.songs[i]; var picUrl = item.al && item.al.picUrl ? item.al.picUrl : ''; list.push({ - id: item.id, name: item.name, artists: formatSingerName(item.artists, 'name'), + id: String(item.id), name: item.name, artists: formatSingerName(item.artists, 'name'), source: 'wy', pic: picUrl, mPic: picUrl, sPic: picUrl, albumName: item.album && item.album.name ? item.album.name : '', - albumId: item.album && item.album.id ? item.album.id : '', - interval: formatPlayTime((item.duration || 0) / 1000), qualities: {} + albumId: String(item.album && item.album.id ? item.album.id : ''), + interval: String(formatPlayTime((item.duration || 0) / 1000) || '--/--'), qualities: {} }); } return { list: list, total: res.body.total || 0, page: page, limit: limit, source: 'wy' }; @@ -593,11 +607,11 @@ var album = { var item = res.body.songs[i]; var picUrl = item.al && item.al.picUrl ? item.al.picUrl : ''; list.push({ - id: item.id, name: item.name, artists: formatSingerName(item.ar, 'name'), + id: String(item.id), name: item.name, artists: formatSingerName(item.ar, 'name'), source: 'wy', pic: picUrl, mPic: picUrl, sPic: picUrl, albumName: item.al && item.al.name ? item.al.name : '', - albumId: item.al && item.al.id ? item.al.id : '', - interval: formatPlayTime((item.dt || 0) / 1000), qualities: {} + albumId: String(item.al && item.al.id ? item.al.id : ''), + interval: String(formatPlayTime((item.dt || 0) / 1000) || '--/--'), qualities: {} }); } return { list: list, total: list.length, page: page, limit: limit, source: 'wy' }; @@ -610,7 +624,7 @@ var pluginInfo = { info: { id: 'koneko_ceru_wy', name: '网易云音乐 - Koneko 聆澜', - version: '0.1.0', + version: '0.1.2', source: 'wy', description: '网易云音乐音源,基于 CeruMusic musicSdk 搜索 + Ceru 播放接口' }, @@ -623,11 +637,11 @@ var pluginInfo = { { key: 'cookie', name: '网易云Cookie', description: '网易云音乐登录Cookie(需包含MUSIC_U=),用于个人歌单、收藏等功能' } ], quality: [ - { name: '标准', ui: '标', id: '128k' }, - { name: '高品', ui: 'HQ', id: '320k' }, - { name: '无损', ui: 'SQ', id: 'flac' } + { name: '标准音质', ui: '标', id: '128k' }, + { name: '高品音质', ui: 'HQ', id: '320k' }, + { name: '无损音质', ui: 'SQ', id: 'flac' } ], - supportFunc: ['musicSearch', 'tipSearch', 'hotSearch', 'leaderboard', 'songList', 'singer', 'album', 'getLyric', 'getPic', 'getUrl', 'musicDetail', 'musicInfo'] + supportFunc: ['search_song', 'search_playlist', 'playlist', 'album', 'lyric'] } module.exports = { diff --git a/聆澜/Koneko_聆澜_酷我音乐_v0.1.0_QZv2.js b/聆澜/Koneko_聆澜_酷我音乐_v0.1.2_QZv2.js similarity index 78% rename from 聆澜/Koneko_聆澜_酷我音乐_v0.1.0_QZv2.js rename to 聆澜/Koneko_聆澜_酷我音乐_v0.1.2_QZv2.js index d3f6c2e..583918d 100644 --- a/聆澜/Koneko_聆澜_酷我音乐_v0.1.0_QZv2.js +++ b/聆澜/Koneko_聆澜_酷我音乐_v0.1.2_QZv2.js @@ -56,13 +56,23 @@ function requestUrl(urlStr, method, headers, body) { return doRequest(protocol, options, postData); } -function formatPlayTime(seconds) { - if (!seconds) return '00:00'; - var m = Math.floor(seconds / 60); - var s = Math.floor(seconds % 60); +// ===== 格式化辅助 ===== +function formatPlayTime(time) { + if (!time) return '--/--'; + var m = Math.floor(time / 60); + var s = Math.floor(time % 60); + if (m === 0 && s === 0) return '--/--'; return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); } +function sizeFormate(bytes) { + if (typeof bytes === 'string') bytes = parseFloat(bytes.replace(/[^0-9.]/g, '')); + var n = parseFloat(bytes); + if (isNaN(n) || n < 0) return '0.00MB'; + var mb = n / (1024 * 1024); + return mb.toFixed(2) + 'MB'; +} + // ===== 搜索实现 ===== function musicSearch(str, page, limit) { var url = 'https://kuwo-api.vercel.app/api/search?key=' + encodeURIComponent(str) + '&page=' + page + '&limit=' + limit; @@ -74,15 +84,19 @@ function musicSearch(str, page, limit) { function handleSearchResult(rawList) { var list = []; + if (!rawList) return list; for (var i = 0; i < rawList.length; i++) { var item = rawList[i]; var qualities = {}; - if (item.filesize) qualities.standard = String(item.filesize); - if (item.sqfilesize) qualities.exhigh = String(item.sqfilesize); - if (item.flacfilesize) qualities.lossless = String(item.flacfilesize); - var picUrl = item.pic || ''; + var size128 = item.filesize || item.mp3size || item.mp3Size || 0; + var size320 = item.sqfilesize || item.hqsize || item['320size'] || item['320filesize'] || 0; + var sizeFlac = item.flacfilesize || item.flacsize || item.flacSize || 0; + if (size128) qualities['128k'] = sizeFormate(size128); + if (size320) qualities['320k'] = sizeFormate(size320); + if (sizeFlac) qualities['flac'] = sizeFormate(sizeFlac); + var picUrl = item.pic || item.albumpic || ''; list.push({ - id: item.id || item.rid || '', + id: String(item.rid || item.id || ''), name: item.name || '', artists: item.artist || '', source: 'kw', @@ -90,8 +104,8 @@ function handleSearchResult(rawList) { mPic: picUrl, sPic: picUrl, albumName: item.album || '', - albumId: item.albumid || '', - interval: item.duration ? formatPlayTime(item.duration) : '', + albumId: String(item.albumid || ''), + interval: String(formatPlayTime(item.duration) || '--/--'), qualities: qualities }); } @@ -109,13 +123,13 @@ function search(str, page, limit, retryNum) { } // ===== 播放链接 ===== -function getUrl(songInfo, type) { - var q = (type === 'standard' ? '128k' : type === 'exhigh' ? '320k' : type === 'lossless' || type === 'hires' || type === 'jymaster' ? 'flac' : type) || '128k'; - var songId = songInfo.id || ''; +function getUrl(songId, quality) { + songId = String(songId || ''); + quality = String(quality || '128k'); var ceruKey = CERU_KEY || ''; var headers = { 'User-Agent': 'QZMusic/2.0' }; if (ceruKey) headers['X-API-Key'] = ceruKey; - return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=kw&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(q), 'GET', headers) + return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=kw&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(quality), 'GET', headers) .then(function(res) { if (res.body && typeof res.body === 'object' && res.body.url) return res.body.url; if (res.body && typeof res.body === 'object' && res.body.data && res.body.data.url) return res.body.data.url; @@ -126,13 +140,13 @@ function getUrl(songInfo, type) { // ===== 封面图 ===== function getPic(songInfo) { - if (songInfo.pic) return Promise.resolve(songInfo.pic); + if (songInfo && songInfo.pic) return Promise.resolve(songInfo.pic); return Promise.resolve(''); } // ===== 歌词 ===== function getLyric(songInfo) { - var rid = songInfo.id || ''; + var rid = (songInfo && songInfo.id) || ''; if (!rid) return Promise.resolve(''); return requestUrl('https://kuwo-api.vercel.app/api/lyric?id=' + encodeURIComponent(rid), 'GET', { 'User-Agent': 'Mozilla/5.0 (Linux; Android 10)' @@ -171,18 +185,18 @@ var pluginInfo = { info: { id: 'koneko_ceru_kw', name: '酷我音乐 - Koneko 聆澜', - version: '0.1.0', + version: '0.1.2', source: 'kw', description: '酷我音乐音源,基于 CeruMusic musicSdk 搜索 + Ceru 播放接口' }, ext: [], env: [{ key: 'ceru_key', name: 'Ceru API Key', description: '聆澜播放接口密钥' }], quality: [ - { name: '标准', ui: '标', id: '128k' }, - { name: '高品', ui: 'HQ', id: '320k' }, - { name: '无损', ui: 'SQ', id: 'flac' } + { name: '标准音质', ui: '标', id: '128k' }, + { name: '高品音质', ui: 'HQ', id: '320k' }, + { name: '无损音质', ui: 'SQ', id: 'flac' } ], - supportFunc: [] + supportFunc: ['search_song', 'search_playlist', 'playlist', 'album', 'lyric'] } module.exports = { @@ -191,7 +205,7 @@ module.exports = { hotSearch: { getList: hotSearch }, leaderboard: { getBoards: leaderboard }, songList: songList, - artists: singer, + singer: singer, album: album, getLyric: getLyric, getPic: getPic, diff --git a/聆澜/Koneko_聆澜_酷狗音乐_v0.1.0_QZv2.js b/聆澜/Koneko_聆澜_酷狗音乐_v0.1.2_QZv2.js similarity index 79% rename from 聆澜/Koneko_聆澜_酷狗音乐_v0.1.0_QZv2.js rename to 聆澜/Koneko_聆澜_酷狗音乐_v0.1.2_QZv2.js index a06b6cd..6596602 100644 --- a/聆澜/Koneko_聆澜_酷狗音乐_v0.1.0_QZv2.js +++ b/聆澜/Koneko_聆澜_酷狗音乐_v0.1.2_QZv2.js @@ -56,33 +56,44 @@ function requestUrl(urlStr, method, headers, body) { return doRequest(protocol, options, postData); } -function formatPlayTime(seconds) { - if (!seconds) return '00:00'; - var m = Math.floor(seconds / 60); - var s = Math.floor(seconds % 60); +// ===== 格式化辅助 ===== +function formatPlayTime(time) { + if (!time) return '--/--'; + var m = Math.floor(time / 60); + var s = Math.floor(time % 60); + if (m === 0 && s === 0) return '--/--'; return (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); } +function sizeFormate(bytes) { + if (typeof bytes === 'string') bytes = parseFloat(bytes.replace(/[^0-9.]/g, '')); + var n = parseFloat(bytes); + if (isNaN(n) || n < 0) return '0.00MB'; + var mb = n / (1024 * 1024); + return mb.toFixed(2) + 'MB'; +} + // ===== 搜索实现 ===== function musicSearch(str, page, limit) { var url = 'http://mobilecdn.kugou.com/api/v3/search/song?showtype=14&highlight=em&pagesize=' + limit + '&page=' + page + '&keyword=' + encodeURIComponent(str); return requestUrl(url, 'GET', { 'User-Agent': 'Mozilla/5.0 (Linux; Android 10)' }).then(function(res) { - if (res.body && res.body.data && res.body.data.info) return res.body.data.info; + if (res.body && res.body.data && res.body.data.info) return res.body.data; throw new Error('kg search failed'); }); } function handleSearchResult(rawList) { var list = []; + if (!rawList) return list; for (var i = 0; i < rawList.length; i++) { var item = rawList[i]; var qualities = {}; - if (item.filesize) qualities.standard = String(item.filesize); - if (item.sqfilesize) qualities.exhigh = String(item.sqfilesize); - if (item.flacfilesize) qualities.lossless = String(item.flacfilesize); + if (item.filesize) qualities['128k'] = sizeFormate(item.filesize); + if (item.sqfilesize) qualities['320k'] = sizeFormate(item.sqfilesize); + if (item.flacfilesize) qualities['flac'] = sizeFormate(item.flacfilesize); var picUrl = item.img || ''; list.push({ - id: item.hash || item.audio_id || '', + id: String(item.hash || item.audio_id || ''), name: item.songname || '', artists: item.singername || '', source: 'kg', @@ -90,8 +101,8 @@ function handleSearchResult(rawList) { mPic: picUrl, sPic: picUrl, albumName: item.album_name || '', - albumId: item.album_id || '', - interval: item.duration ? formatPlayTime(item.duration) : '', + albumId: String(item.album_id || ''), + interval: String(formatPlayTime(item.duration) || '--/--'), qualities: qualities }); } @@ -102,20 +113,22 @@ function search(str, page, limit, retryNum) { if (retryNum === undefined) retryNum = 0; if (++retryNum > 3) return Promise.reject(new Error('try max num')); if (!limit) limit = 30; - return musicSearch(str, page, limit).then(function(rawList) { + return musicSearch(str, page, limit).then(function(data) { + var rawList = data.info || []; + var total = data.total || rawList.length * 10; var list = handleSearchResult(rawList); - return { list: list, allPage: page + 1, limit: limit, total: list.length * 10, source: 'kg' }; + return { list: list, allPage: Math.ceil(total / limit), limit: limit, total: total, source: 'kg' }; }); } // ===== 播放链接 ===== -function getUrl(songInfo, type) { - var q = (type === 'standard' ? '128k' : type === 'exhigh' ? '320k' : type === 'lossless' || type === 'hires' || type === 'jymaster' ? 'flac' : type) || '128k'; - var songId = songInfo.id || ''; +function getUrl(songId, quality) { + songId = String(songId || ''); + quality = String(quality || '128k'); var ceruKey = CERU_KEY || ''; var headers = { 'User-Agent': 'QZMusic/2.0' }; if (ceruKey) headers['X-API-Key'] = ceruKey; - return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=kg&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(q), 'GET', headers) + return requestUrl('https://source.shiqianjiang.cn/api/music/url?source=kg&songId=' + encodeURIComponent(songId) + '&quality=' + encodeURIComponent(quality), 'GET', headers) .then(function(res) { if (res.body && typeof res.body === 'object' && res.body.url) return res.body.url; if (res.body && typeof res.body === 'object' && res.body.data && res.body.data.url) return res.body.data.url; @@ -126,13 +139,13 @@ function getUrl(songInfo, type) { // ===== 封面图 ===== function getPic(songInfo) { - if (songInfo.pic) return Promise.resolve(songInfo.pic); + if (songInfo && songInfo.pic) return Promise.resolve(songInfo.pic); return Promise.resolve(''); } // ===== 歌词 ===== function getLyric(songInfo) { - var hash = songInfo.id || ''; + var hash = (songInfo && songInfo.id) || ''; if (!hash) return Promise.resolve(''); return requestUrl('https://krcs.kugou.com/search?ver=1&man=yes&client=mobi&keyword=&duration=&hash=' + encodeURIComponent(hash) + '&album_audio_id=', 'GET', { 'User-Agent': 'Mozilla/5.0 (Linux; Android 10)' @@ -182,18 +195,18 @@ var pluginInfo = { info: { id: 'koneko_ceru_kg', name: '酷狗音乐 - Koneko 聆澜', - version: '0.1.0', + version: '0.1.2', source: 'kg', description: '酷狗音乐音源,基于 CeruMusic musicSdk 搜索 + Ceru 播放接口' }, ext: [], env: [{ key: 'ceru_key', name: 'Ceru API Key', description: '聆澜播放接口密钥' }], quality: [ - { name: '标准', ui: '标', id: '128k' }, - { name: '高品', ui: 'HQ', id: '320k' }, - { name: '无损', ui: 'SQ', id: 'flac' } + { name: '标准音质', ui: '标', id: '128k' }, + { name: '高品音质', ui: 'HQ', id: '320k' }, + { name: '无损音质', ui: 'SQ', id: 'flac' } ], - supportFunc: [] + supportFunc: ['search_song', 'search_playlist', 'playlist', 'album', 'lyric'] } module.exports = { @@ -202,7 +215,7 @@ module.exports = { hotSearch: { getList: hotSearch }, leaderboard: { getBoards: leaderboard }, songList: songList, - artists: singer, + singer: singer, album: album, getLyric: getLyric, getPic: getPic,