From a60e75b745974aafc651945dd3e6d7ac42e51957 Mon Sep 17 00:00:00 2001 From: "DESKTOP-KSVGT20\\shkim" Date: Sat, 2 May 2026 01:32:49 +0900 Subject: [PATCH] Skip Suno downloads for existing local tracks --- chatgpt-suno-tampermonkey.user.js | 34 +++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/chatgpt-suno-tampermonkey.user.js b/chatgpt-suno-tampermonkey.user.js index 15368c9..113fc6c 100644 --- a/chatgpt-suno-tampermonkey.user.js +++ b/chatgpt-suno-tampermonkey.user.js @@ -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);