Skip to content

Commit

Permalink
修复云盘上传接口部分文件名格式上传失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Binaryify committed Mar 20, 2022
1 parent 9cba287 commit ff74170
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions module/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module.exports = async (query, request) => {
if (query.songFile.name.indexOf('flac') > -1) {
ext = 'flac'
}
const filename = query.songFile.name
.replace('.' + ext, '')
.replaceAll(' ', '_')
.replaceAll('.', '_')
query.cookie.os = 'pc'
query.cookie.appver = '2.9.7'
const bitrate = 999000
Expand Down Expand Up @@ -89,7 +93,7 @@ module.exports = async (query, request) => {
{
bucket: '',
ext: ext,
filename: query.songFile.name.replace('.' + ext, ''),
filename: filename,
local: false,
nos_product: 3,
type: 'audio',
Expand All @@ -110,7 +114,7 @@ module.exports = async (query, request) => {
md5: query.songFile.md5,
songid: res.body.songId,
filename: query.songFile.name,
song: songName || query.songFile.name.replace('.mp3', ''),
song: songName || filename,
album: album || '未知专辑',
artist: artist || '未知艺术家',
bitrate: String(bitrate),
Expand Down
6 changes: 5 additions & 1 deletion plugins/songUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ module.exports = async (query, request) => {
if (query.songFile.name.indexOf('flac') > -1) {
ext = 'flac'
}
const filename = query.songFile.name
.replace('.' + ext, '')
.replaceAll(' ', '_')
.replaceAll('.', '_')
// 获取key和token
const tokenRes = await request(
'POST',
`https://music.163.com/weapi/nos/token/alloc`,
{
bucket: 'jd-musicrep-privatecloud-audio-public',
ext: ext,
filename: query.songFile.name.replace('.' + ext, ''),
filename: filename,
local: false,
nos_product: 3,
type: 'audio',
Expand Down

0 comments on commit ff74170

Please sign in to comment.