diff --git a/module/cloud_import.js b/module/cloud_import.js new file mode 100644 index 0000000..fb9fd86 --- /dev/null +++ b/module/cloud_import.js @@ -0,0 +1,58 @@ +// 云盘导入歌曲 + +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( + 'POST', + `https://interface3.music.163.com/eapi/cloud/upload/check/v2`, + checkData, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + url: '/api/cloud/upload/check/v2', + }, + ) + //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( + 'POST', + `https://interface3.music.163.com/eapi/cloud/user/song/import`, + importData, + { + crypto: 'eapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + url: '/api/cloud/user/song/import', + }, + ) + } + \ No newline at end of file diff --git a/public/docs/home.md b/public/docs/home.md index f2bf373..6677ace 100644 --- a/public/docs/home.md +++ b/public/docs/home.md @@ -298,6 +298,7 @@ 280. 获取专辑歌曲的音质 281. 歌手动态信息 282. 最近听歌列表 +283. 云盘导入歌曲 ## 安装 @@ -4642,6 +4643,48 @@ qrCodeStatus:20,detailReason:0 验证成功qrCodeStatus:21,detailReason:0 二 **接口地址 :** `/recent/listen/list` +### 云盘导入歌曲 + +说明: 登录后调用此接口,使用此接口,可云盘导入歌曲而无需上传文件 + +以下情况可导入成功 + +1.文件已经有用户上传至云盘 + +2.文件是网易云音乐自己的音源 + +**必选参数:** + +`song`: 歌名/文件名 + +`fileType`: 文件后缀 + +`fileSize`: 文件大小 + +`bitrate`: 文件比特率 + +`md5`: 文件MD5 + +**可选参数:** + +`id`: 歌曲ID,情况2时必须正确填写 + +`artist`: 歌手 默认为未知 + +`album`: 专辑 默认为未知 + +**接口地址:** `/cloud/import` + +**调用例子:** `/cloud/import?song=最伟大的作品&artist=周杰伦&album=最伟大的作品&fileType=flac&fileSize=50412168&bitrate=1652&md5=d02b8ab79d91c01167ba31e349fe5275` + +为保证成功,请使用 `获取音乐url` 接口获取各文件属性 + +其中比特率`bitrate`要进行以下转换 +``` +bitrate = Math.floor(br / 1000) +``` +导入后的文件名后缀均为 `.mp3` 。但用 `获取音乐url` 获取到的文件格式仍然是正确的。 + ## 离线访问此文档 此文档同时也是 Progressive Web Apps(PWA), 加入了 serviceWorker, 可离线访问