Initial commit
This commit is contained in:
3
config/default.json
Normal file
3
config/default.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"OOBE":false
|
||||||
|
}
|
||||||
3
config/development.json
Normal file
3
config/development.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"OOBE":false
|
||||||
|
}
|
||||||
21
package.json
Normal file
21
package.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "couldmusic",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "export NODE_ENV=development&pnpm run build&node dist/index.js",
|
||||||
|
"build": "tsc"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/prompts": "^8.1.0",
|
||||||
|
"@neteasecloudmusicapienhanced/api": "^4.29.20",
|
||||||
|
"@types/config": "^3.3.5",
|
||||||
|
"NeteaseCloudMusicApi": "^4.28.0",
|
||||||
|
"chalk": "^5.6.2",
|
||||||
|
"config": "^4.1.1",
|
||||||
|
"webpack": "^5.104.1",
|
||||||
|
"webpack-cli": "^6.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
3240
pnpm-lock.yaml
generated
Normal file
3240
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
90
src/backends/163.ts
Normal file
90
src/backends/163.ts
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import neteaseApi from '@neteasecloudmusicapienhanced/api'
|
||||||
|
import { select, input, password } from '@inquirer/prompts'
|
||||||
|
import config from 'config'
|
||||||
|
const { login_cellphone, captcha_sent, captcha_verify } = neteaseApi;
|
||||||
|
|
||||||
|
class CouldMusic {
|
||||||
|
private cookie: string[]
|
||||||
|
private loginMode: string
|
||||||
|
constructor() {
|
||||||
|
this.cookie = [];
|
||||||
|
this.loginMode = ""
|
||||||
|
}
|
||||||
|
public async login() {
|
||||||
|
this.loginMode = await select({
|
||||||
|
message: "选择一个登入方式",
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
name: "手机号登入",
|
||||||
|
value: "phone",
|
||||||
|
description: "使用手机号登入"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "扫码登入",
|
||||||
|
value: "qrCode",
|
||||||
|
description: "使用二维码"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "邮箱登入",
|
||||||
|
value: "email",
|
||||||
|
disabled: true
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
switch (this.loginMode) {
|
||||||
|
case "phone":
|
||||||
|
var authMode = await select({
|
||||||
|
message: "验证码or密码",
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
name: "验证码",
|
||||||
|
value: "captcha",
|
||||||
|
description: "使用验证码登入"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "密码",
|
||||||
|
value: "passwd",
|
||||||
|
description: "使用验证码登入"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
if (authMode == "passwd") {
|
||||||
|
var phoneid = await input({
|
||||||
|
message: "请输入手机号"
|
||||||
|
})
|
||||||
|
var passwd = await password({
|
||||||
|
message: "请输入密码"
|
||||||
|
})
|
||||||
|
var result = await login_cellphone({
|
||||||
|
phone: phoneid,
|
||||||
|
password: encodeURIComponent(passwd)
|
||||||
|
})
|
||||||
|
if (result.body.code == 400) {
|
||||||
|
console.error("❌账号或密码错误!")
|
||||||
|
}
|
||||||
|
}else if(authMode=="captcha"){
|
||||||
|
var phoneid = await input({
|
||||||
|
message: "请输入手机号"
|
||||||
|
})
|
||||||
|
captcha_sent({
|
||||||
|
phone:phoneid
|
||||||
|
})
|
||||||
|
var verifyCode = await input({
|
||||||
|
message: "请输入验证码"
|
||||||
|
})
|
||||||
|
try{
|
||||||
|
var result=await login_cellphone({
|
||||||
|
phone:phoneid,
|
||||||
|
captcha:verifyCode
|
||||||
|
})
|
||||||
|
}finally{
|
||||||
|
console.error("❌验证码错误!")
|
||||||
|
}
|
||||||
|
this.cookie=result.cookie
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default CouldMusic;
|
||||||
9
src/index.ts
Normal file
9
src/index.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import chalk from 'chalk'
|
||||||
|
import config from 'config'
|
||||||
|
import oobe from './oobe.js'
|
||||||
|
console.info(chalk.bgBlueBright("> ChloudMusic b0.1 "))
|
||||||
|
console.info(chalk.bgBlueBright("> Read Configuration"))
|
||||||
|
var isOobe=config.get("OOBE")
|
||||||
|
if(!isOobe){
|
||||||
|
oobe()
|
||||||
|
}
|
||||||
28
src/oobe.ts
Normal file
28
src/oobe.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { select, input } from '@inquirer/prompts'
|
||||||
|
import CloudMusic from './backends/163.js'
|
||||||
|
async function oobe() {
|
||||||
|
const backends = await select({
|
||||||
|
message: "选择一个音乐服务商",
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
name: "163CloudMusic",
|
||||||
|
value: "163",
|
||||||
|
description: "网易云音乐"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "spotify",
|
||||||
|
value: "spotify",
|
||||||
|
description: "Spotify"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
})
|
||||||
|
switch (backends) {
|
||||||
|
case "163":
|
||||||
|
var backend=new CloudMusic()
|
||||||
|
backend.login()
|
||||||
|
break;
|
||||||
|
case "spotify": break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default oobe
|
||||||
44
tsconfig.json
Normal file
44
tsconfig.json
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
// Visit https://aka.ms/tsconfig to read more about this file
|
||||||
|
"compilerOptions": {
|
||||||
|
// File Layout
|
||||||
|
// "rootDir": "./src",
|
||||||
|
"outDir": "./dist",
|
||||||
|
|
||||||
|
// Environment Settings
|
||||||
|
// See also https://aka.ms/tsconfig/module
|
||||||
|
"module": "nodenext",
|
||||||
|
"target": "esnext",
|
||||||
|
"types": [],
|
||||||
|
// For nodejs:
|
||||||
|
// "lib": ["esnext"],
|
||||||
|
// "types": ["node"],
|
||||||
|
// and npm install -D @types/node
|
||||||
|
|
||||||
|
// Other Outputs
|
||||||
|
"sourceMap": true,
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
|
||||||
|
// Stricter Typechecking Options
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
"exactOptionalPropertyTypes": true,
|
||||||
|
|
||||||
|
// Style Options
|
||||||
|
// "noImplicitReturns": true,
|
||||||
|
// "noImplicitOverride": true,
|
||||||
|
// "noUnusedLocals": true,
|
||||||
|
// "noUnusedParameters": true,
|
||||||
|
// "noFallthroughCasesInSwitch": true,
|
||||||
|
// "noPropertyAccessFromIndexSignature": true,
|
||||||
|
|
||||||
|
// Recommended Options
|
||||||
|
"strict": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noUncheckedSideEffectImports": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user