Skip Suno downloads for existing local tracks

This commit is contained in:
DESKTOP-KSVGT20\shkim
2026-05-02 01:32:49 +09:00
parent 056a08a5c8
commit a60e75b745
+32 -2
View File
@@ -1,7 +1,7 @@
// ==UserScript==
// @name ChatGPT to Suno Prompt Copier
// @namespace local.suno-helper
// @version 0.8.7
// @version 0.8.8
// @description Copy structured ChatGPT song prompt versions into Suno fields.
// @author local
// @match https://chatgpt.com/*
@@ -30,7 +30,7 @@
(function () {
"use strict";
const SCRIPT_VERSION = "0.8.7";
const SCRIPT_VERSION = "0.8.8";
const STORAGE_KEY = "chatgptSunoPromptSlots";
const SLOT_COUNT = 2;
const isChatGPT = location.hostname.includes("chatgpt.com") || location.hostname.includes("chat.openai.com");
@@ -1353,6 +1353,36 @@
}
async function uploadTrackToCompanion(track, statusTarget, format = "mp3") {
const syncManifest = {
pageUrl: location.href,
capturedAt: new Date().toISOString(),
count: 1,
tracks: [track],
};
setStatus(statusTarget, `로컬 보관함 확인 중: ${track.title || track.id}`);
const syncResponse = await fetch("http://127.0.0.1:17873/sync-index", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(syncManifest),
});
const syncText = await syncResponse.text();
if (!syncResponse.ok) throw new Error(syncText || `${syncResponse.status} ${syncResponse.statusText}`);
const syncData = tryParseJson(syncText) || {};
const missingTracks = Array.isArray(syncData.tracks) ? syncData.tracks : [];
if (!missingTracks.length) {
setStatus(statusTarget, `이미 로컬에 있음, SUNO 다운로드 생략: ${track.title || track.id}`);
return {
ok: true,
skipped: true,
localExists: true,
queued: 0,
active: "",
total: 0,
done: 0,
percent: 100,
};
}
track = { ...track, ...missingTracks[0] };
const buffer = format === "wav"
? await downloadSunoWavBuffer(track, statusTarget)
: await downloadSunoMp3Buffer(track, statusTarget);