neteasecloudmusicapi/module/cloud_import.js
2024-07-31 08:55:35 +08:00

40 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 云盘导入歌曲
const createOption = require('../util/option.js')
module.exports = async (query, request) => {
query.id = query.id || -2
query.artist = query.artist || '未知'
query.album = query.album || '未知'
const checkData = {
uploadType: 0,
songs: JSON.stringify([
{
md5: query.md5,
songId: query.id,
bitrate: query.bitrate,
fileSize: query.fileSize,
},
]),
}
const res = await request(
`/api/cloud/upload/check/v2`,
checkData,
createOption(query),
)
//res.body.data[0].upload 0:文件可导入,1:文件已在云盘,2:不能导入
//只能用song决定云盘文件名且上传后的文件名后缀固定为mp3
const importData = {
uploadType: 0,
songs: JSON.stringify([
{
songId: res.body.data[0].songId,
bitrate: query.bitrate,
song: query.song,
artist: query.artist,
album: query.album,
fileName: query.song + '.' + query.fileType,
},
]),
}
return request(`/api/cloud/user/song/import`, importData, createOption(query))
}