1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

添加hifini_music爬虫代码

This commit is contained in:
2022-10-28 00:23:50 +08:00
parent a39fa9dc18
commit 6ce6b0cd46
3 changed files with 218 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
const dbUtils = global.dbUtils;
let insertCollectionTemplate = async (tableName, dataList) => {
if (dataList.length == 0) return;
return await dbUtils.query(`
INSERT INTO ${tableName} ( ${Object.keys(dataList[0]).map(field => `\`${field}\``).join(",")} ) VALUES ?
ON DUPLICATE KEY UPDATE ${Object.keys(dataList[0]).map(field => `${field}=VALUES(${field})`).join(", ")}
`, [dataList.map(item => Object.values(item))]);
}
module.exports = {
thread: {
insertCollection: async (threadList) => {
return await insertCollectionTemplate("hifini_thread", threadList);
},
update: async (threadId, threadInfo) => {
return await dbUtils.query(`UPDATE hifini_thread SET ? WHERE thread_id = ${threadId}`, threadInfo);
},
getIdsToFetch: async () => {
return await dbUtils.query(`SELECT thread_id FROM hifini_thread where music_title='' and music_pic='' and music_url=''`);
},
getIdsToFetchRealUrl: async () => {
return await dbUtils.query(`SELECT thread_id,music_url FROM hifini_thread where music_url like 'get_music.php?key=%' and music_real_url=''`);
}
},
tag: {
insertCollection: async (tagList) => {
return await insertCollectionTemplate("hifini_tag", tagList);
},
},
thread_tag: {
insertCollection: async (tagList) => {
return await insertCollectionTemplate("hifini_thread_tag_relation", tagList);
},
},
};