fix: map search result fields songmid->id, singer->artists for QZv2 Music model
This commit is contained in:
@@ -90,11 +90,11 @@ function formatGitItem(item) {
|
||||
else if (fmt === 'mp3') { types.push({ type: '320k', size: item.filesize || '' }); _types['320k'] = { size: item.filesize || '' }; }
|
||||
else { types.push({ type: '128k', size: item.filesize || '' }); _types['128k'] = { size: item.filesize || '' }; }
|
||||
return {
|
||||
singer: item.artist || '未知歌手',
|
||||
artists: item.artist || '未知歌手',
|
||||
name: item.title || item.filename || '',
|
||||
albumName: item.album || '未知专辑',
|
||||
albumId: '',
|
||||
songmid: item.relative_path || '',
|
||||
id: item.relative_path || '',
|
||||
source: 'git',
|
||||
interval: '',
|
||||
img: item.img || '',
|
||||
@@ -112,7 +112,7 @@ function musicSearch(str, page, limit) {
|
||||
var filtered = [];
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var item = list[i];
|
||||
if (regex.test(item.singer) || regex.test(item.name) || regex.test(item.albumName)) filtered.push(item);
|
||||
if (regex.test(item.artists) || regex.test(item.name) || regex.test(item.albumName)) filtered.push(item);
|
||||
}
|
||||
var start = (page - 1) * limit;
|
||||
return { data: filtered.slice(start, start + limit), total: filtered.length };
|
||||
@@ -136,7 +136,7 @@ function search(str, page, limit, retryNum) {
|
||||
// ===== 播放链接 =====
|
||||
function getUrl(songInfo, type) {
|
||||
var q = type || '128k';
|
||||
var songId = songInfo.songmid || '';
|
||||
var songId = songInfo.id || '';
|
||||
if (!songId) return Promise.resolve('');
|
||||
var ceruKey = process.env.ceru_key || '';
|
||||
var headers = { 'User-Agent': 'QZMusic/2.0' };
|
||||
@@ -211,7 +211,7 @@ module.exports = {
|
||||
hotSearch: { getList: hotSearch },
|
||||
leaderboard: { getBoards: leaderboard },
|
||||
songList: songList,
|
||||
singer: singer,
|
||||
artists: singer,
|
||||
album: album,
|
||||
getLyric: getLyric,
|
||||
getPic: getPic,
|
||||
|
||||
@@ -143,13 +143,13 @@ function handleSearchResult(rawList) {
|
||||
singerName = ns.join('、');
|
||||
}
|
||||
list.push({
|
||||
singer: singerName,
|
||||
artists: singerName,
|
||||
name: item.name + (item.title_extra || ''),
|
||||
albumName: albumName,
|
||||
albumId: albumId,
|
||||
source: 'tx',
|
||||
interval: formatPlayTime(item.interval),
|
||||
songmid: item.mid,
|
||||
id: item.mid,
|
||||
songId: item.id,
|
||||
img: 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' : ''),
|
||||
lrc: null,
|
||||
@@ -175,7 +175,7 @@ function search(str, page, limit, retryNum) {
|
||||
// ===== 播放链接 =====
|
||||
function getUrl(songInfo, type) {
|
||||
var q = type || '128k';
|
||||
var songId = songInfo.songmid || songInfo.id || '';
|
||||
var songId = songInfo.id || '';
|
||||
var ceruKey = process.env.ceru_key || '';
|
||||
var headers = { 'User-Agent': 'QZMusic/2.0' };
|
||||
if (ceruKey) headers['X-API-Key'] = ceruKey;
|
||||
@@ -198,7 +198,7 @@ function getPic(songInfo) {
|
||||
|
||||
// ===== 歌词 =====
|
||||
function getLyric(songInfo) {
|
||||
var songmid = songInfo.songmid || '';
|
||||
var songmid = songInfo.id || '';
|
||||
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'
|
||||
@@ -224,10 +224,10 @@ function musicDetail(songmid) {
|
||||
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('、'); }
|
||||
return {
|
||||
singer: singerName, name: t.name,
|
||||
artists: singerName, name: t.name,
|
||||
albumName: t.album ? t.album.name : '', albumId: albumId,
|
||||
source: 'tx', interval: formatPlayTime(t.interval),
|
||||
songmid: t.mid, songId: t.id,
|
||||
id: t.mid, songId: t.id,
|
||||
img: albumId ? 'https://y.gtimg.cn/music/photo_new/T002R500x500M000' + albumId + '.jpg' : '',
|
||||
lrc: null, types: [], _types: {}, typeUrl: {}
|
||||
};
|
||||
@@ -308,7 +308,7 @@ module.exports = {
|
||||
hotSearch: { getList: hotSearch },
|
||||
leaderboard: { getBoards: leaderboard },
|
||||
songList: songList,
|
||||
singer: singer,
|
||||
artists: singer,
|
||||
album: album,
|
||||
getLyric: getLyric,
|
||||
getPic: getPic,
|
||||
|
||||
@@ -90,13 +90,13 @@ function handleSearchResult(rawList) {
|
||||
var img = item.img || (item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : '');
|
||||
if (img && img.startsWith('/')) img = 'https://d.musicapp.migu.cn' + img;
|
||||
list.push({
|
||||
singer: item.artist || item.singerName || '',
|
||||
artists: item.artist || item.singerName || '',
|
||||
name: item.title || item.songName || '',
|
||||
albumName: item.album || item.albumName || '',
|
||||
albumId: item.albumId || '',
|
||||
source: 'mg',
|
||||
interval: item.length ? item.length.replace(/.*(\d\d:\d\d)$/, '$1') : '',
|
||||
songmid: item.copyrightId || item.id || '',
|
||||
id: item.copyrightId || item.id || '',
|
||||
songId: item.copyrightId || item.id || '',
|
||||
img: img,
|
||||
lrc: null,
|
||||
@@ -119,7 +119,7 @@ function search(str, page, limit, retryNum) {
|
||||
// ===== 播放链接 =====
|
||||
function getUrl(songInfo, type) {
|
||||
var q = type || '128k';
|
||||
var songId = songInfo.songmid || songInfo.id || '';
|
||||
var songId = songInfo.id || '';
|
||||
var ceruKey = process.env.ceru_key || '';
|
||||
var headers = { 'User-Agent': 'QZMusic/2.0' };
|
||||
if (ceruKey) headers['X-API-Key'] = ceruKey;
|
||||
@@ -140,7 +140,7 @@ function getPic(songInfo) {
|
||||
|
||||
// ===== 歌词 =====
|
||||
function getLyric(songInfo) {
|
||||
var copyrightId = songInfo.songmid || '';
|
||||
var copyrightId = 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)',
|
||||
@@ -200,7 +200,7 @@ module.exports = {
|
||||
hotSearch: { getList: hotSearch },
|
||||
leaderboard: { getBoards: leaderboard },
|
||||
songList: songList,
|
||||
singer: singer,
|
||||
artists: singer,
|
||||
album: album,
|
||||
getLyric: getLyric,
|
||||
getPic: getPic,
|
||||
|
||||
@@ -156,13 +156,13 @@ function handleSearchResult(rawList) {
|
||||
if (s.sq) { types.push({ type: 'flac', size: '' }); _types.flac = { size: '' }; }
|
||||
if (s.hr) { types.push({ type: 'hires', size: '' }); _types.hires = { size: '' }; }
|
||||
list.push({
|
||||
singer: formatSingerName(s.ar, 'name'),
|
||||
artists: formatSingerName(s.ar, 'name'),
|
||||
name: s.name,
|
||||
albumName: s.al && s.al.name ? s.al.name : '',
|
||||
albumId: s.al && s.al.id ? s.al.id : '',
|
||||
source: 'wy',
|
||||
interval: formatPlayTime((s.dt || 0) / 1000),
|
||||
songmid: s.id,
|
||||
id: s.id,
|
||||
img: s.al && s.al.picUrl ? s.al.picUrl : '',
|
||||
lrc: null,
|
||||
types: types,
|
||||
@@ -195,7 +195,7 @@ function search(str, page, limit, retryNum) {
|
||||
// ===== 播放链接 =====
|
||||
function getUrl(songInfo, type) {
|
||||
var q = type || '128k';
|
||||
var songId = songInfo.songmid || songInfo.id || '';
|
||||
var songId = songInfo.id || '';
|
||||
var ceruKey = process.env.ceru_key || '';
|
||||
var headers = { 'User-Agent': 'QZMusic/2.0' };
|
||||
if (ceruKey) headers['X-API-Key'] = ceruKey;
|
||||
@@ -214,10 +214,10 @@ function getPic(songInfo) {
|
||||
if (songInfo.img) return Promise.resolve(songInfo.img);
|
||||
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.songmid,
|
||||
'Referer': 'https://music.163.com/song?id=' + songInfo.id,
|
||||
'Origin': 'https://music.163.com',
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}, querystring.stringify(weapi({ c: '[{"id":' + songInfo.songmid + '}]', ids: '[' + songInfo.songmid + ']' })))
|
||||
}, querystring.stringify(weapi({ c: '[{"id":' + songInfo.id + '}]', ids: '[' + songInfo.id + ']' })))
|
||||
.then(function(res) {
|
||||
if (res.body && res.body.songs && res.body.songs.length) return res.body.songs[0].al.picUrl;
|
||||
return '';
|
||||
@@ -227,7 +227,7 @@ function getPic(songInfo) {
|
||||
|
||||
// ===== 歌词 =====
|
||||
function getLyric(songInfo) {
|
||||
var songmid = songInfo.songmid || '';
|
||||
var songmid = songInfo.id || '';
|
||||
return requestUrl('https://music.163.com/api/song/lyric?id=' + 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
|
||||
@@ -248,13 +248,13 @@ function musicDetail(songmid) {
|
||||
if (res.body && res.body.songs && res.body.songs.length) {
|
||||
var s = res.body.songs[0];
|
||||
return {
|
||||
singer: formatSingerName(s.ar, 'name'),
|
||||
artists: formatSingerName(s.ar, 'name'),
|
||||
name: s.name,
|
||||
albumName: s.al && s.al.name ? s.al.name : '',
|
||||
albumId: s.al && s.al.id ? s.al.id : '',
|
||||
source: 'wy',
|
||||
interval: formatPlayTime((s.dt || 0) / 1000),
|
||||
songmid: s.id,
|
||||
id: s.id,
|
||||
img: s.al && s.al.picUrl ? s.al.picUrl : '',
|
||||
lrc: null,
|
||||
types: [],
|
||||
@@ -352,7 +352,7 @@ module.exports = {
|
||||
hotSearch: { getList: hotSearch },
|
||||
leaderboard: { getBoards: leaderboard },
|
||||
songList: songList,
|
||||
singer: singer,
|
||||
artists: singer,
|
||||
album: album,
|
||||
getLyric: getLyric,
|
||||
getPic: getPic,
|
||||
|
||||
@@ -78,13 +78,13 @@ function handleSearchResult(rawList) {
|
||||
types.push({ type: '128k', size: '' }); _types['128k'] = { size: '' };
|
||||
types.push({ type: '320k', size: '' }); _types['320k'] = { size: '' };
|
||||
list.push({
|
||||
singer: item.artist || '',
|
||||
artists: item.artist || '',
|
||||
name: item.name || '',
|
||||
albumName: item.album || '',
|
||||
albumId: item.albumid || '',
|
||||
source: 'kw',
|
||||
interval: item.duration ? formatPlayTime(item.duration) : '',
|
||||
songmid: item.id || item.rid || '',
|
||||
id: item.id || item.rid || '',
|
||||
songId: item.id || item.rid || '',
|
||||
img: item.pic || '',
|
||||
lrc: null,
|
||||
@@ -107,7 +107,7 @@ function search(str, page, limit, retryNum) {
|
||||
// ===== 播放链接 =====
|
||||
function getUrl(songInfo, type) {
|
||||
var q = type || '128k';
|
||||
var songId = songInfo.songmid || songInfo.id || '';
|
||||
var songId = songInfo.id || '';
|
||||
var ceruKey = process.env.ceru_key || '';
|
||||
var headers = { 'User-Agent': 'QZMusic/2.0' };
|
||||
if (ceruKey) headers['X-API-Key'] = ceruKey;
|
||||
@@ -128,7 +128,7 @@ function getPic(songInfo) {
|
||||
|
||||
// ===== 歌词 =====
|
||||
function getLyric(songInfo) {
|
||||
var rid = songInfo.songmid || '';
|
||||
var rid = 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)'
|
||||
@@ -187,7 +187,7 @@ module.exports = {
|
||||
hotSearch: { getList: hotSearch },
|
||||
leaderboard: { getBoards: leaderboard },
|
||||
songList: songList,
|
||||
singer: singer,
|
||||
artists: singer,
|
||||
album: album,
|
||||
getLyric: getLyric,
|
||||
getPic: getPic,
|
||||
|
||||
@@ -78,13 +78,13 @@ function handleSearchResult(rawList) {
|
||||
types.push({ type: '128k', size: '' }); _types['128k'] = { size: '' };
|
||||
types.push({ type: '320k', size: '' }); _types['320k'] = { size: '' };
|
||||
list.push({
|
||||
singer: item.singername || '',
|
||||
artists: item.singername || '',
|
||||
name: item.songname || '',
|
||||
albumName: item.album_name || '',
|
||||
albumId: item.album_id || '',
|
||||
source: 'kg',
|
||||
interval: item.duration ? formatPlayTime(item.duration) : '',
|
||||
songmid: item.hash || item.audio_id || '',
|
||||
id: item.hash || item.audio_id || '',
|
||||
songId: item.hash || item.audio_id || '',
|
||||
img: item.img || '',
|
||||
lrc: null,
|
||||
@@ -107,7 +107,7 @@ function search(str, page, limit, retryNum) {
|
||||
// ===== 播放链接 =====
|
||||
function getUrl(songInfo, type) {
|
||||
var q = type || '128k';
|
||||
var songId = songInfo.songmid || songInfo.id || '';
|
||||
var songId = songInfo.id || '';
|
||||
var ceruKey = process.env.ceru_key || '';
|
||||
var headers = { 'User-Agent': 'QZMusic/2.0' };
|
||||
if (ceruKey) headers['X-API-Key'] = ceruKey;
|
||||
@@ -128,7 +128,7 @@ function getPic(songInfo) {
|
||||
|
||||
// ===== 歌词 =====
|
||||
function getLyric(songInfo) {
|
||||
var hash = songInfo.songmid || '';
|
||||
var hash = 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)'
|
||||
@@ -198,7 +198,7 @@ module.exports = {
|
||||
hotSearch: { getList: hotSearch },
|
||||
leaderboard: { getBoards: leaderboard },
|
||||
songList: songList,
|
||||
singer: singer,
|
||||
artists: singer,
|
||||
album: album,
|
||||
getLyric: getLyric,
|
||||
getPic: getPic,
|
||||
|
||||
Reference in New Issue
Block a user