Queue Suno tracks one at a time

This commit is contained in:
DESKTOP-KSVGT20\shkim
2026-05-01 23:15:19 +09:00
parent 1414c38bd1
commit 96a54a3eca
3 changed files with 125 additions and 26 deletions
+21 -24
View File
@@ -1,7 +1,7 @@
// ==UserScript==
// @name ChatGPT to Suno Prompt Copier
// @namespace local.suno-helper
// @version 0.6.0
// @version 0.7.0
// @description Copy structured ChatGPT song prompt versions into Suno fields.
// @author local
// @match https://chatgpt.com/*
@@ -975,34 +975,31 @@
return;
}
const preparedTracks = [];
let enqueued = 0;
for (let index = 0; index < missingTracks.length; index += 1) {
const track = { ...missingTracks[index] };
setStatus(statusTarget, `${index + 1}/${missingTracks.length} 없는 곡 WAV 준비 중: ${track.title || track.id}`);
track.wavUrl = await requestSunoWavUrl(track);
preparedTracks.push(track);
const enqueueManifest = {
pageUrl: location.href,
capturedAt: new Date().toISOString(),
count: 1,
tracks: [track],
};
const response = await fetch("http://127.0.0.1:17873/enqueue", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(enqueueManifest),
});
const text = await response.text();
if (!response.ok) {
throw new Error(text || `${response.status} ${response.statusText}`);
}
enqueued += 1;
const data = tryParseJson(text) || {};
setStatus(statusTarget, `${enqueued}/${missingTracks.length}곡 큐 추가: ${track.title || track.id} / 대기 ${data.queued ?? "?"}`);
}
const manifest = {
pageUrl: location.href,
capturedAt: new Date().toISOString(),
count: preparedTracks.length,
tracks: preparedTracks,
};
const response = await fetch("http://127.0.0.1:17873/process", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(manifest),
});
const text = await response.text();
if (!response.ok) {
throw new Error(text || `${response.status} ${response.statusText}`);
}
const data = tryParseJson(text) || {};
if (data.skipped) {
setStatus(statusTarget, "동기화 완료 상태: 처리할 새 곡 없음");
return;
}
setStatus(statusTarget, `로컬 처리 시작: ${data.jobId || "job"} / 새 곡 ${preparedTracks.length}`);
setStatus(statusTarget, `큐 전송 완료: 새 곡 ${enqueued}개. 로컬 프로그램이 순서대로 처리 중.`);
}
async function testCompanion(statusTarget) {