netease_music 的一些改动
This commit is contained in:
parent
a29dc77417
commit
70e15f7e49
@ -5,6 +5,7 @@ const sleepUtils = require('../../../utils/sleepUtils');
|
||||
const dataManager = require('../dataManager');
|
||||
|
||||
const dbUtils = global.dbUtils;
|
||||
const oldPlaylistUtils = require('./playlistUtils_old');
|
||||
|
||||
// refer:
|
||||
// https://neteasecloudmusicapi-docs.4everland.app/
|
||||
@ -27,10 +28,9 @@ async function fetchTop({ args = {} }) {
|
||||
let hasMore = true;
|
||||
while (hasMore) {
|
||||
try {
|
||||
var result = await top_playlist({
|
||||
id: 1
|
||||
});
|
||||
fs.writeFileSync(path.join(__dirname, "../../temp", `test.json`), JSON.stringify(result.body));
|
||||
// var result = await top_playlist({ id: 1 });
|
||||
var result = await top_playlist_highquality({ id: 1 });
|
||||
// fs.writeFileSync(path.join(__dirname, "../../temp", `test.json`), JSON.stringify(result.body));
|
||||
} catch (errors) {
|
||||
console.error("error", errors);
|
||||
await sleepUtils.sleep(10 * 1000);
|
||||
@ -38,23 +38,23 @@ async function fetchTop({ args = {} }) {
|
||||
|
||||
// 针对每一个歌单调用相关歌单接口,然后加入待爬取歌单
|
||||
|
||||
hasMore = false;
|
||||
console.log(result.body.playlists);
|
||||
}
|
||||
console.log(result);
|
||||
hasMore = result.more;
|
||||
|
||||
return;
|
||||
let playlists = result.body.playlists;
|
||||
// console.log(playlists);
|
||||
|
||||
for (let i = 0; i < songIds.length; i++) {
|
||||
for (let i in playlists) {
|
||||
await global.checkIsExit();
|
||||
const songId = songIds[i];
|
||||
console.log(`${i + 1}/${songIds.length} | playlist: ${songId} | ${args.min || "?"}-${args.max || "?"}`);
|
||||
const playlist = playlists[i];
|
||||
const playlistId = playlist.id;
|
||||
console.log(`${i + 1}/${playlists.length} | playlist: ${playlistId} | limit: ${limit}, page: ${page}`);
|
||||
try {
|
||||
await fetch({ songId: songId });
|
||||
await oldPlaylistUtils.fetch({ playlistId: playlist.id })
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
await sleepUtils.sleep(global.sleepTime);
|
||||
// await sleepUtils.sleep(global.sleepTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ async function fetch({ songIdArray, debug = false }) {
|
||||
albumIds.push(song.al.id || 0);
|
||||
songAlbumRel.push([song.id, song.al.id || 0])
|
||||
return {
|
||||
title: song.name, // 歌曲标题
|
||||
title: song.name || "", // 歌曲标题
|
||||
id: song.id, // 歌曲ID
|
||||
type: song.t, // 0: 一般类型 1: 通过云盘上传的音乐,网易云不存在公开对应 2: 通过云盘上传的音乐,网易云存在公开对应
|
||||
alias: JSON.stringify(song.alia), // 别名列表,第一个别名会被显示作副标题
|
||||
@ -69,7 +69,7 @@ async function fetch({ songIdArray, debug = false }) {
|
||||
duration: song.dt, // 歌曲时长
|
||||
quality: JSON.stringify({ h: song.h, m: song.m, l: song.l, sq: song.sq }), // 高/中/低/无损质量文件信息
|
||||
version: song.version, // 歌曲版本信息
|
||||
cd: song.cd, // None或如"04", "1/2", "3", "null"的字符串,表示歌曲属于专辑中第几张CD,对应音频文件的Tag
|
||||
cd: song.cd || "", // None或如"04", "1/2", "3", "null"的字符串,表示歌曲属于专辑中第几张CD,对应音频文件的Tag
|
||||
no: song.no, // 表示歌曲属于CD中第几曲,0表示没有这个字段,对应音频文件的Tag
|
||||
djId: song.djId, // 0: 不是DJ节目 其他:是DJ节目,表示DJ ID
|
||||
sId: song.s_id, // 对于t == 2的歌曲,表示匹配到的公开版本歌曲ID
|
||||
|
@ -83,7 +83,7 @@ async function main(args) {
|
||||
await sleepUtils.sleep(30 * 1000);
|
||||
break;
|
||||
case 'playlist':
|
||||
await playlistUtils.fetchAll({ args: args });
|
||||
await playlistUtils.fetchTop({ args: args });
|
||||
process.exit(0);
|
||||
break;
|
||||
|
||||
|
@ -56,3 +56,19 @@ SQL文件说明
|
||||
sql/structure.sql 中的SQL为最简,不包含字段的编码集
|
||||
sql/neteasemusic.sql 中的SQL为数据库导出,包含字段的编码集
|
||||
项目数据库 CHARACTER SET 统一使用 'utf8mb4',COLLATE 统一使用 'utf8mb4_general_ci'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# # 查看列表
|
||||
# screen -ls
|
||||
|
||||
# # 创建一个screen
|
||||
# screen + <Enter>
|
||||
|
||||
# # 切换到指定屏幕
|
||||
# screen -r <screen_id>
|
||||
|
||||
# # 切出屏幕
|
||||
# Ctrl + A D
|
Loading…
Reference in New Issue
Block a user