skillfree 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/skillfree.js +32 -5
- package/package.json +1 -1
- package/scripts/commands/pilot.js +1 -1
package/bin/skillfree.js
CHANGED
|
@@ -66,21 +66,48 @@ program
|
|
|
66
66
|
// ── task(查询异步任务状态)────────────────────────────────────────────────────
|
|
67
67
|
program
|
|
68
68
|
.command('task <taskId>')
|
|
69
|
-
.description('
|
|
69
|
+
.description('查询异步任务状态(视频/音乐等)')
|
|
70
70
|
.option('--output <path>', '任务完成后自动下载到本地')
|
|
71
71
|
.action(async (taskId, flags) => {
|
|
72
72
|
const { request } = require('../scripts/lib/client')
|
|
73
|
+
const fs = require('fs')
|
|
74
|
+
|
|
75
|
+
// Suno 任务用 suno:xxx 格式区分
|
|
76
|
+
if (taskId.startsWith('suno:')) {
|
|
77
|
+
const sunoId = taskId.slice(5)
|
|
78
|
+
const poll = await request('/suno/fetch/' + sunoId, { method: 'GET' })
|
|
79
|
+
const result = await poll.json()
|
|
80
|
+
if (result.code !== 'success') throw new Error(result.message || JSON.stringify(result))
|
|
81
|
+
const status = result.data?.status
|
|
82
|
+
const songs = result.data?.data || []
|
|
83
|
+
console.log(`\n📋 Suno 任务 ${sunoId}`)
|
|
84
|
+
console.log(` 状态:${status}`)
|
|
85
|
+
if (status === 'SUCCESS') {
|
|
86
|
+
songs.forEach((s, i) => {
|
|
87
|
+
console.log(` 歌曲${i+1}:${s.title} ${s.audio_url}`)
|
|
88
|
+
})
|
|
89
|
+
if (flags.output && songs[0]?.audio_url) {
|
|
90
|
+
const resp = await fetch(songs[0].audio_url)
|
|
91
|
+
fs.writeFileSync(flags.output, Buffer.from(await resp.arrayBuffer()))
|
|
92
|
+
console.log(`✅ 已下载到 ${flags.output}`)
|
|
93
|
+
} else {
|
|
94
|
+
console.log(`\n💡 下载:skillfree task ${taskId} --output ./music.mp3`)
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
console.log(`\n⏳ 仍在生成中,稍后再查...`)
|
|
98
|
+
}
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 视频任务
|
|
73
103
|
const res = await request(`/v1/tasks/${taskId}`, { method: 'GET' })
|
|
74
104
|
const task = await res.json()
|
|
75
105
|
console.log(`\n📋 任务 ${taskId}`)
|
|
76
106
|
console.log(` 状态:${task.status}`)
|
|
77
107
|
console.log(` 模型:${task.model}`)
|
|
78
108
|
if (task.status === 'completed' && task.output_url) {
|
|
79
|
-
console.log(`
|
|
109
|
+
console.log(` 链接:${task.output_url}`)
|
|
80
110
|
if (flags.output) {
|
|
81
|
-
const { downloadAndSave } = require('../scripts/commands/pilot')
|
|
82
|
-
// 直接 fetch 下载
|
|
83
|
-
const fs = require('fs')
|
|
84
111
|
const resp = await fetch(task.output_url)
|
|
85
112
|
fs.writeFileSync(flags.output, Buffer.from(await resp.arrayBuffer()))
|
|
86
113
|
console.log(`✅ 已下载到 ${flags.output}`)
|
package/package.json
CHANGED
|
@@ -231,7 +231,7 @@ async function pilot(flags) {
|
|
|
231
231
|
}
|
|
232
232
|
if (status === 'FAILED') throw new Error('Suno 任务失败: ' + JSON.stringify(result.data))
|
|
233
233
|
}
|
|
234
|
-
throw new Error(
|
|
234
|
+
throw new Error(`Suno 生成超时(150s),任务仍在后台运行\n📋 稍后手动查询:skillfree task suno:${taskId}`)
|
|
235
235
|
|
|
236
236
|
} else {
|
|
237
237
|
// music-2.5(MiniMax),走 /v1/responses,需要 lyrics
|