mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 14:41:23 +08:00
@@ -0,0 +1,20 @@
|
||||
const { avatar_upload, login_cellphone } = require('../main')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
async function main() {
|
||||
const result = await login_cellphone({
|
||||
phone: '手机号',
|
||||
password: '密码',
|
||||
})
|
||||
const filePath = './test.jpg'
|
||||
await avatar_upload({
|
||||
imgFile: {
|
||||
name: path.basename(filePath),
|
||||
data: fs.readFileSync(filePath),
|
||||
},
|
||||
imgSize: 1012, //图片尺寸,需要正方形图片
|
||||
cookie: result.body.cookie,
|
||||
})
|
||||
}
|
||||
main()
|
||||
@@ -0,0 +1,15 @@
|
||||
const { eapiResDecrypt, eapiReqDecrypt } = require('../util/crypto')
|
||||
|
||||
let reqParamsHex =
|
||||
'6E0B1C712DCB3648589D7C950C296204072A88C3E080C4CFFD0A71A553EC2533BA88E11B1E1C6DF3BE8EFA26177FCB6FCA34EB3FAFAB4671B2BBAFA9781AFDA2BF53A3DC423722493837B9BC6E80CED5BBD2DDC2856920E4D4E3E7F3EB77ECF265217A66AE677BE36F2D6FB203F721CA250E1453EA61A34904E33D5FCB9D483601D744BE0AE979AC911A00F25828538844F4B1C24F6C34880A4AB257F530C7FB10A81FED32B18D09D70C0B1B9D34A2E58A3C3FAD382C6F958077059C4F801AD7B3B248FDB9D7A59B6A9EEFF8C781A84315B33A7AFD48BE9FCFCBE1902CCC27949ACF2BDE3FA34D116E230C3597E8320B8C42BBBF371A00C03EC428E0440EB94C1540F3FD4173D29E310AFE43AB0EF449852904103EF305FC435AD43B7D8673642F74C89CCB2F1A6A79B3BE14F1235D3843C3B241D12C05DBDDF37B68CA8B5D0230AF1FCF2A9705886F4D126B33FFF6948DE1E4046DB6423D687E96C5B65122464D2E71AEC7722935FF2C3796FAE253A16AA3B102FBE7296AB0DB9EA5C46AD12B'.replaceAll(
|
||||
' ',
|
||||
'',
|
||||
)
|
||||
const resHex =
|
||||
`FB A2 DB 80 DF 26 69 F1 AA 14 81 8E 56 93 53 A6 44 9C 10 70 26 65 59 64 AE 09 02 75 56 65 1C 98 E6 DC E7 50 F1 6E 64 78 BC 87 B8 0E 6D 52 B0 23`.replaceAll(
|
||||
' ',
|
||||
'',
|
||||
)
|
||||
console.log(reqParamsHex)
|
||||
console.log(eapiReqDecrypt(reqParamsHex))
|
||||
console.log(eapiResDecrypt(resHex))
|
||||
@@ -0,0 +1,104 @@
|
||||
const { cloud, login_cellphone } = require('../main')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const yargs = require('yargs')
|
||||
|
||||
const MUSIC_FILE_EXTENSIONS = new Set(['.mp3', '.flac'])
|
||||
|
||||
function getAllMusicFiles(dir, arrayOfFiles) {
|
||||
arrayOfFiles = arrayOfFiles || []
|
||||
|
||||
fs.readdirSync(dir).forEach((file) => {
|
||||
let fullPath = path.join(dir, file)
|
||||
if (fs.lstatSync(fullPath).isDirectory()) {
|
||||
getAllMusicFiles(fullPath, arrayOfFiles)
|
||||
} else {
|
||||
if (MUSIC_FILE_EXTENSIONS.has(path.extname(fullPath))) {
|
||||
arrayOfFiles.push(fullPath)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return arrayOfFiles
|
||||
}
|
||||
|
||||
async function uploadArrayOfFile(token, arrayOfFiles) {
|
||||
let failedFiles = []
|
||||
let failed = 0
|
||||
const fileCount = arrayOfFiles.length
|
||||
for (let k in arrayOfFiles) {
|
||||
const file = arrayOfFiles[k]
|
||||
try {
|
||||
await cloud({
|
||||
songFile: {
|
||||
name: path.basename(file),
|
||||
data: fs.readFileSync(file),
|
||||
},
|
||||
cookie: token.body.cookie,
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
failed += 1
|
||||
failedFiles.push(file)
|
||||
}
|
||||
console.log(`Uploaded ${k + 1}/${fileCount} songs`)
|
||||
}
|
||||
return { failedFiles, failed }
|
||||
}
|
||||
|
||||
function getParsedArgs() {
|
||||
return yargs(process.argv.slice(2))
|
||||
.option('country_code', {
|
||||
default: '86',
|
||||
describe: 'The country code of your phone number',
|
||||
type: 'string',
|
||||
})
|
||||
.option('phone_number', {
|
||||
demandOption: true,
|
||||
describe: 'Your phone number',
|
||||
type: 'string',
|
||||
})
|
||||
.option('password', {
|
||||
demandOption: true,
|
||||
describe: 'Your password',
|
||||
type: 'string',
|
||||
})
|
||||
.option('file', {
|
||||
describe: 'The absolute path to the single music file to be uploaded',
|
||||
type: 'string',
|
||||
})
|
||||
.option('dir', {
|
||||
describe: 'The absolute to the directory of music files to be uploaded',
|
||||
type: 'string',
|
||||
})
|
||||
.conflicts('file', 'dir')
|
||||
.help()
|
||||
.alias('help', 'h').argv
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const args = getParsedArgs()
|
||||
const token = await login_cellphone({
|
||||
countrycode: args.country_code,
|
||||
phone: args.phone_number,
|
||||
password: args.password,
|
||||
})
|
||||
const files = args.file ? [args.file] : getAllMusicFiles(args.dir)
|
||||
const fileCount = files.length
|
||||
|
||||
console.log(`Found ${fileCount} files, uploading...`)
|
||||
let res = await uploadArrayOfFile(token, files)
|
||||
if (res.failed) {
|
||||
console.log(`Failed to upload ${res.failed} songs, retrying...`)
|
||||
res = await uploadArrayOfFile(token, res.failedFiles)
|
||||
}
|
||||
|
||||
console.log(`Uploaded ${fileCount - res.failed} songs`)
|
||||
console.log(
|
||||
`Failed to upload ${res.failed} songs, you can reupload the files below`,
|
||||
)
|
||||
for (let k in res.failedFiles) {
|
||||
console.log(res.failedFiles[k])
|
||||
}
|
||||
}
|
||||
main()
|
||||
@@ -0,0 +1,23 @@
|
||||
const { cloud, login_cellphone } = require('../main')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
async function main() {
|
||||
const result = await login_cellphone({
|
||||
phone: '手机号',
|
||||
password: '密码',
|
||||
})
|
||||
const filePath = './test.mp3'
|
||||
try {
|
||||
await cloud({
|
||||
songFile: {
|
||||
name: path.basename(filePath),
|
||||
data: fs.readFileSync(filePath),
|
||||
},
|
||||
cookie: result.body.cookie,
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error, 'error')
|
||||
}
|
||||
}
|
||||
main()
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 125 KiB |
@@ -0,0 +1,31 @@
|
||||
const {
|
||||
login_cellphone,
|
||||
user_cloud,
|
||||
album_sublist,
|
||||
song_url,
|
||||
} = require('../main')
|
||||
async function test() {
|
||||
try {
|
||||
const result = await login_cellphone({
|
||||
phone: '手机号',
|
||||
password: '密码',
|
||||
})
|
||||
console.log(result)
|
||||
const result2 = await user_cloud({
|
||||
cookie: result.body.cookie,
|
||||
})
|
||||
console.log(result2.body)
|
||||
const result3 = await album_sublist({
|
||||
cookie: result.body.cookie,
|
||||
})
|
||||
console.log(result3.body)
|
||||
const result4 = await song_url({
|
||||
cookie: result.body.cookie,
|
||||
id: 33894312,
|
||||
})
|
||||
console.log(result4.body)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
test()
|
||||
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
import { banner, lyric } from 'NeteaseCloudMusicApi'
|
||||
banner({ type: 0 }).then((res) => {
|
||||
console.log(res)
|
||||
})
|
||||
lyric({
|
||||
id: '33894312',
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
})
|
||||
Reference in New Issue
Block a user