netease_music 的一些改动
This commit is contained in:
parent
59336c15b6
commit
a29dc77417
@ -74,6 +74,25 @@ module.exports = {
|
|||||||
albumIds = albumIds.map(item => item.id);
|
albumIds = albumIds.map(item => item.id);
|
||||||
return albumIds;
|
return albumIds;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInfoById: async (albumId, { getRelation = true }) => {
|
||||||
|
if (!albumId) return {}
|
||||||
|
// 查询出专辑
|
||||||
|
const sql = 'SELECT * FROM album WHERE album_id = ?'
|
||||||
|
let infoResultSet = await dbUtils.query(sql, [albumId]);
|
||||||
|
if (infoResultSet.length == 0) return {};
|
||||||
|
let albumInfo = JSON.parse(JSON.stringify(infoResultSet[0]));
|
||||||
|
if (getRelation) {
|
||||||
|
// 查出专辑与歌曲对应关系
|
||||||
|
const sql2 = 'SELECT * FROM song_album_relation WHERE album_id = ?'
|
||||||
|
let relationResultSet = await dbUtils.query(sql2, [albumId]);
|
||||||
|
// 拼装
|
||||||
|
albumInfo.songIds = relationResultSet.map(song => song.song_id);
|
||||||
|
} else {
|
||||||
|
albumInfo.songIds = null;
|
||||||
|
}
|
||||||
|
return albumInfo;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -97,6 +116,25 @@ module.exports = {
|
|||||||
artistIds = artistIds.map(item => item.id);
|
artistIds = artistIds.map(item => item.id);
|
||||||
return artistIds;
|
return artistIds;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getInfoById: async (artistId, { getRelation = true }) => {
|
||||||
|
if (!artistId) return {}
|
||||||
|
// 查询出歌手
|
||||||
|
const sql = 'SELECT * FROM artist WHERE artist_id = ?'
|
||||||
|
let infoResultSet = await dbUtils.query(sql, [artistId]);
|
||||||
|
if (infoResultSet.length == 0) return {};
|
||||||
|
let artistInfo = JSON.parse(JSON.stringify(infoResultSet[0]));
|
||||||
|
if (getRelation) {
|
||||||
|
// 查出歌手与歌曲对应关系
|
||||||
|
const sql2 = 'SELECT * FROM song_artist_relation WHERE artist_id = ?'
|
||||||
|
let relationResultSet = await dbUtils.query(sql2, [artistId]);
|
||||||
|
// 拼装
|
||||||
|
artistInfo.songIds = relationResultSet.map(song => song.song_id);
|
||||||
|
} else {
|
||||||
|
artistInfo.songIds = null;
|
||||||
|
}
|
||||||
|
return artistInfo;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,21 +7,6 @@ const dataManager = require('../dataManager');
|
|||||||
|
|
||||||
const dbUtils = global.dbUtils;
|
const dbUtils = global.dbUtils;
|
||||||
|
|
||||||
// 从数据库中查询
|
|
||||||
async function getFromDatabase({ albumId }) {
|
|
||||||
// 查询出专辑
|
|
||||||
let infoResultSet = await dbUtils.query('SELECT * FROM album WHERE album_id = ?', [albumId]);
|
|
||||||
if (infoResultSet.length == 0) return {};
|
|
||||||
|
|
||||||
// 查出专辑与歌曲对应关系
|
|
||||||
let relationResultSet = await dbUtils.query('SELECT * FROM song_album_relation WHERE album_id = ?', [albumId]);
|
|
||||||
|
|
||||||
// 拼装
|
|
||||||
let albumInfo = JSON.parse(JSON.stringify(infoResultSet[0]));
|
|
||||||
albumInfo.songIds = relationResultSet.map(song => song.song_id);
|
|
||||||
return albumInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 正常应该查不出记录才对
|
// 正常应该查不出记录才对
|
||||||
/*
|
/*
|
||||||
SELECT * FROM album WHERE (full_description = '' or full_description is null) and description like '%专辑《%》,简介:%' and description not regexp '^.*?专辑《.*?》,简介:([:space:]*?|[ ]*?)。,更多.*$'
|
SELECT * FROM album WHERE (full_description = '' or full_description is null) and description like '%专辑《%》,简介:%' and description not regexp '^.*?专辑《.*?》,简介:([:space:]*?|[ ]*?)。,更多.*$'
|
||||||
@ -184,7 +169,6 @@ async function fetch({ albumId, debug = false, update = false }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getFromDatabase: getFromDatabase,
|
|
||||||
fetch: fetch,
|
fetch: fetch,
|
||||||
fetchAll: fetchAll,
|
fetchAll: fetchAll,
|
||||||
}
|
}
|
@ -7,21 +7,6 @@ const dataManager = require('../dataManager');
|
|||||||
|
|
||||||
const dbUtils = global.dbUtils;
|
const dbUtils = global.dbUtils;
|
||||||
|
|
||||||
// 从数据库中查询
|
|
||||||
async function getFromDatabase({ artistId }) {
|
|
||||||
// 查询出专辑
|
|
||||||
let infoResultSet = await dbUtils.query('SELECT * FROM artist WHERE artist_id = ?', [artistId]);
|
|
||||||
if (infoResultSet.length == 0) return {};
|
|
||||||
|
|
||||||
// 查出专辑与歌曲对应关系
|
|
||||||
let relationResultSet = await dbUtils.query('SELECT * FROM song_artist_relation WHERE artist_id = ?', [artistId]);
|
|
||||||
|
|
||||||
// 拼装
|
|
||||||
let artistInfo = JSON.parse(JSON.stringify(infoResultSet[0]));
|
|
||||||
artistInfo.songIds = relationResultSet.map(song => song.song_id);
|
|
||||||
return artistInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 从数据库中查出还缺少的歌手,并进行爬取
|
// 从数据库中查出还缺少的歌手,并进行爬取
|
||||||
async function fetchAll({ args = {} }) {
|
async function fetchAll({ args = {} }) {
|
||||||
console.log("start fetching artists ...");
|
console.log("start fetching artists ...");
|
||||||
@ -129,7 +114,6 @@ async function fetch({ artistId, debug = false }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getFromDatabase: getFromDatabase,
|
|
||||||
fetch: fetch,
|
fetch: fetch,
|
||||||
fetchAll: fetchAll,
|
fetchAll: fetchAll,
|
||||||
}
|
}
|
@ -47,10 +47,6 @@ async function test() {
|
|||||||
|
|
||||||
// let res = await testUtils.fetch();
|
// let res = await testUtils.fetch();
|
||||||
|
|
||||||
// let res = await albumInfoUtils.getFromDatabase({ albumId: "9156" });
|
|
||||||
// let res = await artistInfoUtils.getFromDatabase({ artistId: "12023508" });
|
|
||||||
// let res = await songInfoUtils.getFromDatabase({ songId: "437608327" });
|
|
||||||
|
|
||||||
// console.log(res);
|
// console.log(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user