Skip Suno downloads for existing local tracks
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name ChatGPT to Suno Prompt Copier
|
// @name ChatGPT to Suno Prompt Copier
|
||||||
// @namespace local.suno-helper
|
// @namespace local.suno-helper
|
||||||
// @version 0.8.7
|
// @version 0.8.8
|
||||||
// @description Copy structured ChatGPT song prompt versions into Suno fields.
|
// @description Copy structured ChatGPT song prompt versions into Suno fields.
|
||||||
// @author local
|
// @author local
|
||||||
// @match https://chatgpt.com/*
|
// @match https://chatgpt.com/*
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
(function () {
|
(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const SCRIPT_VERSION = "0.8.7";
|
const SCRIPT_VERSION = "0.8.8";
|
||||||
const STORAGE_KEY = "chatgptSunoPromptSlots";
|
const STORAGE_KEY = "chatgptSunoPromptSlots";
|
||||||
const SLOT_COUNT = 2;
|
const SLOT_COUNT = 2;
|
||||||
const isChatGPT = location.hostname.includes("chatgpt.com") || location.hostname.includes("chat.openai.com");
|
const isChatGPT = location.hostname.includes("chatgpt.com") || location.hostname.includes("chat.openai.com");
|
||||||
@@ -1353,6 +1353,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function uploadTrackToCompanion(track, statusTarget, format = "mp3") {
|
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"
|
const buffer = format === "wav"
|
||||||
? await downloadSunoWavBuffer(track, statusTarget)
|
? await downloadSunoWavBuffer(track, statusTarget)
|
||||||
: await downloadSunoMp3Buffer(track, statusTarget);
|
: await downloadSunoMp3Buffer(track, statusTarget);
|
||||||
|
|||||||
Reference in New Issue
Block a user