fablecut 1.20.0 → 1.22.0
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/CLAUDE.md +140 -6
- package/README.md +9 -2
- package/app.js +564 -96
- package/clips.js +207 -0
- package/import-url.js +10 -3
- package/index.html +13 -5
- package/manifest.json +3 -1
- package/mcp-server.js +177 -20
- package/music.js +253 -0
- package/package.json +1 -1
- package/project-ops.js +12 -2
- package/server.js +3 -1
- package/style.css +52 -0
package/music.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/* FableCut music search — openly licensed music and sound effects from
|
|
2
|
+
Openverse (https://openverse.org), with each track's licence spelled out.
|
|
3
|
+
Zero dependencies; loaded by the editor as a plain script (global
|
|
4
|
+
`FableCutMusic`) and required by the MCP server, so the bin's Music tab and
|
|
5
|
+
`fablecut_music` search the same way and label licences the same way.
|
|
6
|
+
|
|
7
|
+
Openverse indexes Jamendo, Freesound, ccMixter, Wikimedia Commons and more.
|
|
8
|
+
Its API needs no key: anonymous use allows 20 results a page, 240 results
|
|
9
|
+
per search (12 pages) and about 200 searches a day per address. Its terms
|
|
10
|
+
ask apps to say they are made with Openverse (not endorsed by it) and to
|
|
11
|
+
credit the works, which is what `credits` and `creditLine` are for.
|
|
12
|
+
|
|
13
|
+
searchUrl(opts) → the API URL · track(result) → a plain track · licence(code,
|
|
14
|
+
version) → what it allows · mediaLicense(track) → what a media entry keeps
|
|
15
|
+
(m.license) · credits(doc, uses) → the credits the edit needs. */
|
|
16
|
+
(function (root, factory) {
|
|
17
|
+
const api = factory();
|
|
18
|
+
if (typeof module === "object" && module.exports) module.exports = api;
|
|
19
|
+
else root.FableCutMusic = api;
|
|
20
|
+
})(typeof self !== "undefined" ? self : this, function () {
|
|
21
|
+
"use strict";
|
|
22
|
+
|
|
23
|
+
const API = "https://api.openverse.org/v1/audio/";
|
|
24
|
+
const PAGE_SIZE = 20; // the most an anonymous request may ask for
|
|
25
|
+
const MAX_PAGE = 12; // 240 results deep
|
|
26
|
+
const MAX_QUERY = 200;
|
|
27
|
+
// Openverse's length buckets, checked against its results
|
|
28
|
+
const LENGTHS = {
|
|
29
|
+
shortest: "under 30 s", short: "30 s – 2 min", medium: "2 – 10 min", long: "over 10 min",
|
|
30
|
+
};
|
|
31
|
+
// sound effects: Freesound's (Openverse leaves their category empty, so a category filter misses them)
|
|
32
|
+
const KINDS = { music: { category: "music" }, sfx: { source: "freesound" } };
|
|
33
|
+
const MOODS = ["upbeat", "chill", "cinematic", "epic", "lo-fi", "acoustic", "electronic",
|
|
34
|
+
"happy", "sad", "ambient", "piano", "corporate", "hip hop", "rock"];
|
|
35
|
+
const SFX_WORDS = ["whoosh", "impact", "riser", "swoosh", "pop", "click", "ding", "glitch",
|
|
36
|
+
"boom", "camera shutter", "typing", "applause", "footsteps", "crowd"];
|
|
37
|
+
|
|
38
|
+
/* What each licence lets a video editor do. edits: may it be cut, looped and
|
|
39
|
+
put under picture? Creative Commons counts music synced to moving images as
|
|
40
|
+
an adaptation, so ND (no derivatives) music can't go into an edit. */
|
|
41
|
+
const LICENSES = {
|
|
42
|
+
cc0: { label: "CC0", commercial: true, edits: true, credit: false, note: "public domain dedication — use it any way you like" },
|
|
43
|
+
pdm: { label: "Public domain", commercial: true, edits: true, credit: false, note: "public domain — use it any way you like" },
|
|
44
|
+
by: { label: "CC BY", commercial: true, edits: true, credit: true, note: "any use, credit the artist" },
|
|
45
|
+
"by-sa": { label: "CC BY-SA", commercial: true, edits: true, credit: true, note: "any use, credit the artist; the video must be shared under CC BY-SA too" },
|
|
46
|
+
"by-nc": { label: "CC BY-NC", commercial: false, edits: true, credit: true, note: "non-commercial only (no ads, sponsored or monetized videos), credit the artist" },
|
|
47
|
+
"by-nc-sa": { label: "CC BY-NC-SA", commercial: false, edits: true, credit: true, note: "non-commercial only, credit the artist; the video must be shared under CC BY-NC-SA too" },
|
|
48
|
+
"by-nd": { label: "CC BY-ND", commercial: true, edits: false, credit: true, note: "no derivatives: music set to video counts as one, so it can't go into an edit" },
|
|
49
|
+
"by-nc-nd": { label: "CC BY-NC-ND", commercial: false, edits: false, credit: true, note: "non-commercial and no derivatives: music set to video counts as one, so it can't go into an edit" },
|
|
50
|
+
// Sampling licences allow transforming parts of a track, not setting the whole track to video as it is
|
|
51
|
+
"sampling+": { label: "Sampling+", commercial: false, edits: true, sampling: true, credit: true, note: "parts may be sampled and transformed, also commercially (not in ads); the whole track as it is only shared non-commercially, not set to video; credit the artist" },
|
|
52
|
+
"nc-sampling+": { label: "NC Sampling+", commercial: false, edits: true, sampling: true, credit: true, note: "parts may be sampled and transformed, non-commercially only; the whole track as it is can't be set to video; credit the artist" },
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** What a licence allows: {code, label ("CC BY 4.0"), commercial, edits, credit, note, url}. */
|
|
56
|
+
function licence(code, version, url) {
|
|
57
|
+
const c = String(code || "").toLowerCase();
|
|
58
|
+
const base = LICENSES[c] || { label: c ? c.toUpperCase() : "Unknown licence", commercial: false, edits: false, credit: true, note: "unknown licence — check the track's page before using it" };
|
|
59
|
+
const v = version && !/^(cc0|pdm)$/.test(c) ? String(version) : "";
|
|
60
|
+
return { code: c, label: base.label + (v ? " " + v : ""), commercial: base.commercial, edits: base.edits,
|
|
61
|
+
sampling: !!base.sampling, credit: base.credit, note: base.note, url: url || "" };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The words that sum a licence up for a badge: "free to use", "credit", "non-commercial", "no edits", "samples only", "share alike". */
|
|
65
|
+
function flags(lic) {
|
|
66
|
+
const out = [];
|
|
67
|
+
if (!lic.credit && lic.commercial && lic.edits) out.push("free to use");
|
|
68
|
+
if (lic.credit) out.push("credit");
|
|
69
|
+
if (!lic.commercial) out.push("non-commercial");
|
|
70
|
+
if (!lic.edits) out.push("no edits");
|
|
71
|
+
if (lic.sampling) out.push("samples only");
|
|
72
|
+
if (/-sa$/.test(lic.code)) out.push("share alike");
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Why a licence limits a video, one line each (credits and the import reply). */
|
|
77
|
+
function warnings(lic) {
|
|
78
|
+
const out = [];
|
|
79
|
+
if (!lic.edits) out.push(lic.label + " allows no derivatives — music set to video counts as one");
|
|
80
|
+
if (lic.sampling) out.push(lic.label + " allows only sampled, transformed parts — not the whole track under a video");
|
|
81
|
+
if (!lic.commercial) out.push(lic.label + " is non-commercial only");
|
|
82
|
+
if (/-sa$/.test(lic.code)) out.push(lic.label + ": share the video under the same licence");
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Only http(s) links reach a page's href; anything else becomes "". */
|
|
87
|
+
function webUrl(u) {
|
|
88
|
+
try { const x = new URL(String(u || "")); return x.protocol === "https:" || x.protocol === "http:" ? x.href : ""; }
|
|
89
|
+
catch (_) { return ""; }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The Openverse search URL. opts: {query, kind:'music'|'sfx', length:'shortest'|'short'|'medium'|'long',
|
|
93
|
+
* commercial:true (only licences that allow commercial use), edits:true (only ones that allow
|
|
94
|
+
* edits), licenses:[codes], page}. */
|
|
95
|
+
function searchUrl(opts = {}) {
|
|
96
|
+
const q = String(opts.query == null ? "" : opts.query).trim().slice(0, MAX_QUERY);
|
|
97
|
+
const p = new URLSearchParams();
|
|
98
|
+
if (q) p.set("q", q);
|
|
99
|
+
else p.set("unstable__sort_by", "indexed_on"); // nothing typed: the newest
|
|
100
|
+
const kind = KINDS[opts.kind] || KINDS.music;
|
|
101
|
+
for (const k of Object.keys(kind)) p.set(k, kind[k]);
|
|
102
|
+
if (opts.length && LENGTHS[opts.length]) p.set("length", opts.length);
|
|
103
|
+
// commercial / edits pick licence codes by FableCut's own table: Openverse's "commercial" group
|
|
104
|
+
// includes Sampling+, which FableCut labels non-commercial for a whole track. edits means "may
|
|
105
|
+
// go under a video as it is", so it leaves out ND and the Sampling licences.
|
|
106
|
+
let lic = (opts.licenses || []).map((l) => String(l).toLowerCase()).filter((l) => LICENSES[l]);
|
|
107
|
+
if (opts.commercial || opts.edits) {
|
|
108
|
+
const ok = (c) => (!opts.commercial || LICENSES[c].commercial) && (!opts.edits || (LICENSES[c].edits && !LICENSES[c].sampling));
|
|
109
|
+
const picked = (lic.length ? lic : Object.keys(LICENSES)).filter(ok);
|
|
110
|
+
if (!picked.length) throw new Error("none of those licences allow " + [opts.commercial && "commercial use", opts.edits && "edits"].filter(Boolean).join(" and "));
|
|
111
|
+
lic = picked;
|
|
112
|
+
}
|
|
113
|
+
if (lic.length) p.set("license", lic.join(","));
|
|
114
|
+
p.set("mature", "false");
|
|
115
|
+
p.set("page_size", String(PAGE_SIZE));
|
|
116
|
+
const page = Math.max(1, Math.min(MAX_PAGE, Math.floor(+opts.page || 1)));
|
|
117
|
+
if (page > 1) p.set("page", String(page));
|
|
118
|
+
return API + "?" + p.toString();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** One track's details by its Openverse id. */
|
|
122
|
+
function trackUrl(id) {
|
|
123
|
+
if (!/^[0-9a-f-]{36}$/i.test(String(id || ""))) throw new Error("not an Openverse track id: " + id);
|
|
124
|
+
return API + String(id).toLowerCase() + "/";
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// titles and names come HTML-escaped from some sources ("Jaief & Asong")
|
|
128
|
+
const ENT = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", "#39": "'" };
|
|
129
|
+
const unescape = (s) => String(s).replace(/&(amp|lt|gt|quot|apos|#39);/g, (_, e) => ENT[e]).trim();
|
|
130
|
+
|
|
131
|
+
/** An Openverse result as a plain track. */
|
|
132
|
+
function track(r) {
|
|
133
|
+
r = r || {};
|
|
134
|
+
const lic = licence(r.license, r.license_version, webUrl(r.license_url));
|
|
135
|
+
return {
|
|
136
|
+
id: r.id, title: unescape(r.title || "Untitled"), creator: unescape(r.creator || "Unknown artist"),
|
|
137
|
+
creatorUrl: webUrl(r.creator_url), duration: r.duration ? Math.round(r.duration / 100) / 10 : null,
|
|
138
|
+
license: lic, flags: flags(lic),
|
|
139
|
+
url: webUrl(r.url), page: webUrl(r.foreign_landing_url), source: r.source || r.provider || "",
|
|
140
|
+
genres: (r.genres || []).slice(0, 6), tags: (r.tags || []).map((t) => t && t.name).filter(Boolean).slice(0, 10),
|
|
141
|
+
filetype: r.filetype || "", attribution: r.attribution || "",
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** A search answer → {count, pages, page, tracks}. */
|
|
146
|
+
function results(json, page) {
|
|
147
|
+
json = json || {};
|
|
148
|
+
return { count: json.result_count || 0, pages: Math.min(json.page_count || 0, MAX_PAGE), page: page || json.page || 1,
|
|
149
|
+
tracks: (json.results || []).filter((r) => r && r.url).map(track) };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** 125.4 → "2:05"; under 10 s with a tenth (a 0.4 s swipe reads "0.4 s", not "0:00"). */
|
|
153
|
+
function fmtLen(sec) {
|
|
154
|
+
if (+sec < 10) return (Math.round((+sec || 0) * 10) / 10) + " s";
|
|
155
|
+
const s = Math.round(+sec);
|
|
156
|
+
return Math.floor(s / 60) + ":" + String(s % 60).padStart(2, "0");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** A friendly file name for the download: "Title - Artist.mp3". */
|
|
160
|
+
function fileName(t) {
|
|
161
|
+
const ft = String(t.filetype || "mp3").toLowerCase();
|
|
162
|
+
const ext = { mp32: "mp3", mp31: "mp3", oga: "ogg", opus: "ogg", aif: "wav", aiff: "wav" }[ft] || ft;
|
|
163
|
+
return (t.title + " - " + t.creator).replace(/[^\w.\- ()\[\]]+/g, " ").replace(/\s+/g, " ").trim().slice(0, 100) + "." + ext;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** What a media entry keeps about where its file came from (m.license). */
|
|
167
|
+
function mediaLicense(t) {
|
|
168
|
+
return { code: t.license.code, label: t.license.label, url: t.license.url, title: t.title, creator: t.creator,
|
|
169
|
+
page: t.page, source: t.source, openverse: t.id, attribution: t.attribution };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** A media entry's licence as stored: only its text fields, trimmed; null when it isn't one. */
|
|
173
|
+
function cleanLicense(l) {
|
|
174
|
+
if (!l || typeof l !== "object" || Array.isArray(l) || !l.code) return null;
|
|
175
|
+
const out = {};
|
|
176
|
+
for (const k of ["code", "label", "url", "title", "creator", "page", "source", "openverse", "attribution"]) {
|
|
177
|
+
if (typeof l[k] !== "string" || !l[k]) continue;
|
|
178
|
+
// links are kept whole or not at all: a cut URL would point somewhere else
|
|
179
|
+
if (k === "url" || k === "page") { const u = webUrl(l[k]); if (u && u.length <= 2000) out[k] = u; }
|
|
180
|
+
else out[k] = l[k].slice(0, k === "attribution" ? 1000 : 300);
|
|
181
|
+
}
|
|
182
|
+
if (!out.label) out.label = licence(out.code).label;
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** The credit to put in a video's description: "Title" by Artist (source) — CC BY 4.0 — page. */
|
|
187
|
+
function creditLine(l) {
|
|
188
|
+
if (!l) return "";
|
|
189
|
+
return `"${l.title}" by ${l.creator}` + (l.source ? ` (${l.source})` : "") + ` — ${l.label}` +
|
|
190
|
+
(l.url ? ` (${l.url})` : "") + (l.page ? ` — ${l.page}` : "");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** How often each media file is placed in the edit itself: the open sequence's clips and the
|
|
194
|
+
* compositions placed in it (nested ones too) — not other sequences or comps nothing places.
|
|
195
|
+
* A linked group counts once. → Map(media id → placements) for `credits`. */
|
|
196
|
+
function editUsage(doc) {
|
|
197
|
+
const n = new Map(), comps = new Map(((doc && doc.comps) || []).map((c) => [c.id, c]));
|
|
198
|
+
// lo / hi: the stretch of these clips' timeline that is shown (a comp instance shows its comp
|
|
199
|
+
// from `in` for `duration`, as the renderer flattens it); clips outside it aren't in the edit
|
|
200
|
+
const scan = (clips, depth, inComps, lo, hi) => {
|
|
201
|
+
const seen = new Set();
|
|
202
|
+
for (const c of clips || []) {
|
|
203
|
+
const start = +c.start || 0, end = start + (+c.duration || 0);
|
|
204
|
+
if (end <= lo || start >= hi) continue;
|
|
205
|
+
if (c.kind === "comp" && comps.has(c.compId) && depth < 8 && !inComps.has(c.compId)) {
|
|
206
|
+
const off = (+c.in || 0) - start; // parent time → comp time
|
|
207
|
+
scan(comps.get(c.compId).clips, depth + 1, new Set([...inComps, c.compId]), Math.max(lo, start) + off, Math.min(hi, end) + off);
|
|
208
|
+
}
|
|
209
|
+
if (!c.mediaId) continue;
|
|
210
|
+
const key = (c.linkGroup ? "g:" + c.linkGroup : "c:" + c.id) + "|" + c.mediaId;
|
|
211
|
+
if (seen.has(key)) continue;
|
|
212
|
+
seen.add(key);
|
|
213
|
+
n.set(c.mediaId, (n.get(c.mediaId) || 0) + 1);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
scan(doc && doc.clips, 0, new Set(), -Infinity, Infinity);
|
|
217
|
+
return n;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** The credits an edit needs: every licensed file the edit uses (a denoised
|
|
221
|
+
* copy counts as its original, and its credit says the sound was changed).
|
|
222
|
+
* uses: media id → placements (MediaLib.usageCounts).
|
|
223
|
+
* → [{mediaId, name, license, line, needsCredit, changes, warnings}] */
|
|
224
|
+
function credits(doc, uses) {
|
|
225
|
+
const media = (doc && doc.media) || [];
|
|
226
|
+
const byId = new Map(media.map((m) => [m.id, m]));
|
|
227
|
+
const origin = (m) => {
|
|
228
|
+
for (let i = 0; m && !m.license && m.derivedFrom && i < 8; i++) m = byId.get(m.derivedFrom);
|
|
229
|
+
return m && m.license ? m : null;
|
|
230
|
+
};
|
|
231
|
+
const byWork = new Map();
|
|
232
|
+
for (const m of media) {
|
|
233
|
+
if (!(uses && uses.get ? uses.get(m.id) : 0)) continue;
|
|
234
|
+
const o = origin(m);
|
|
235
|
+
if (!o) continue;
|
|
236
|
+
const key = o.license.openverse || o.id;
|
|
237
|
+
if (!byWork.has(key)) byWork.set(key, { o, changes: new Set() });
|
|
238
|
+
// a denoised copy may carry the licence itself (and so be its own origin here)
|
|
239
|
+
if (m.denoise) byWork.get(key).changes.add("noise reduced");
|
|
240
|
+
else if (m !== o) byWork.get(key).changes.add("processed");
|
|
241
|
+
}
|
|
242
|
+
return [...byWork.values()].map(({ o, changes }) => {
|
|
243
|
+
const lic = licence(o.license.code), ch = [...changes];
|
|
244
|
+
return { mediaId: o.id, name: o.name, license: o.license, needsCredit: lic.credit, changes: ch,
|
|
245
|
+
line: creditLine(o.license) + (ch.length ? ` — changed: ${ch.join(", ")}` : ""), warnings: warnings(lic) };
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const ABOUT = "Music from Openverse (openverse.org) — made with Openverse, not endorsed or certified by it. Each track's licence is the artist's: check it before you publish.";
|
|
250
|
+
|
|
251
|
+
return { API, PAGE_SIZE, MAX_PAGE, LENGTHS, KINDS, MOODS, SFX_WORDS, LICENSES, ABOUT,
|
|
252
|
+
licence, flags, warnings, webUrl, searchUrl, trackUrl, track, results, fmtLen, fileName, mediaLicense, cleanLicense, creditLine, editUsage, credits };
|
|
253
|
+
});
|
package/package.json
CHANGED
package/project-ops.js
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
text: "Title", fontSize: 72, color: "#ffffff", color2: "", font: "Segoe UI",
|
|
54
54
|
bold: true, weight: 0, italic: false, uppercase: false, align: "center",
|
|
55
55
|
letterSpacing: 0, lineHeight: 1.2, textShadow: 12, glow: 0, glowColor: "",
|
|
56
|
-
strokeWidth: 0, strokeColor: "#000", bgColor: "#000", bgOpacity: 0,
|
|
56
|
+
strokeWidth: 0, strokeColor: "#000", bgColor: "#000", bgOpacity: 0, bgShape: "lines",
|
|
57
57
|
textAnim: "none", wordRate: 0.15, highlightColor: "#ffd166", direction: "auto", boxW: 0, boxH: 0, boxFit: false, vAlign: "middle",
|
|
58
58
|
anchorX: 0, anchorY: 0, trimStart: 0, trimEnd: 100, trimOffset: 0,
|
|
59
59
|
autoOrient: false, motionBlur: 0, motionBlurSamples: 8, pathOffset: 0, pathAlign: "start",
|
|
@@ -279,6 +279,7 @@
|
|
|
279
279
|
if (p.motionBlurSamples != null && !(Number.isInteger(p.motionBlurSamples) && p.motionBlurSamples >= 2 && p.motionBlurSamples <= 32)) throw new Error(`${label}: props.motionBlurSamples is a whole number 2…32`);
|
|
280
280
|
if (p.autoOrient != null && typeof p.autoOrient !== "boolean") throw new Error(`${label}: props.autoOrient is true or false`);
|
|
281
281
|
if (p.pathAlign != null && !["start", "center", "end"].includes(p.pathAlign)) throw new Error(`${label}: props.pathAlign is start | center | end`);
|
|
282
|
+
if (p.bgShape != null && !["lines", "box"].includes(p.bgShape)) throw new Error(`${label}: props.bgShape is lines | box`);
|
|
282
283
|
if (p.textPath != null) {
|
|
283
284
|
if (c.kind !== "text") throw new Error(`${label}: textPath goes on text clips`);
|
|
284
285
|
try { p.textPath = Motion.normalizeTextPath(p.textPath, true); } catch (err) { throw new Error(`${label}: props.${err.message}`); }
|
|
@@ -449,12 +450,20 @@
|
|
|
449
450
|
const kindOf = MediaLib.kindFromName(src);
|
|
450
451
|
if (kindOf && kindOf !== m.kind && !(m.kind === "audio" && kindOf === "video")) // an audio entry may sit in a video container
|
|
451
452
|
throw new Error(`${name}: ${src} is ${kindOf === "audio" || kindOf === "image" ? "an" : "a"} ${kindOf} file, but ${m.id} is ${m.kind}`);
|
|
452
|
-
const was = { duration: m.duration };
|
|
453
|
+
const was = { duration: m.duration }, sameFile = m.src === src;
|
|
453
454
|
m.src = src;
|
|
454
455
|
for (const k of MediaLib.INFO_KEYS) delete m[k];
|
|
455
456
|
if (name === "replaceMedia") {
|
|
456
457
|
m.name = op.name ? String(op.name).trim().slice(0, 200) : MediaLib.srcName(src);
|
|
457
458
|
delete m.duration; delete m.width; delete m.height;
|
|
459
|
+
// another file: the old track's licence doesn't apply (relinkMedia keeps it); the new
|
|
460
|
+
// file's does, when another entry imported it with one (fablecut_music). The same file
|
|
461
|
+
// keeps its licence. A replaced copy is no longer derived from its old original.
|
|
462
|
+
if (!sameFile) {
|
|
463
|
+
const same = proj.media.find((x) => x !== m && x.license && x.src === src);
|
|
464
|
+
if (same) m.license = { ...same.license }; else delete m.license;
|
|
465
|
+
delete m.derivedFrom; delete m.denoise;
|
|
466
|
+
}
|
|
458
467
|
} else if (op.name) m.name = String(op.name).trim().slice(0, 200);
|
|
459
468
|
if (info) {
|
|
460
469
|
for (const k of MediaLib.INFO_KEYS) if (info[k] != null) m[k] = info[k];
|
|
@@ -1216,6 +1225,7 @@
|
|
|
1216
1225
|
(opts.proxy && m.kind === "video" && opts.proxy(m) ? ` proxy:${opts.proxy(m)}p` : "") +
|
|
1217
1226
|
(m.favorite ? " ★" : "") + (m.tags && m.tags.length ? " " + m.tags.map((t) => "#" + t.replace(/\s+/g, "_")).join(" ") : "") +
|
|
1218
1227
|
(m.folderId ? ` folder:${m.folderId}` : "") + ` uses:${uses.get(m.id) || 0}` +
|
|
1228
|
+
(m.license && m.license.label ? ` licence:"${m.license.label}"` : "") +
|
|
1219
1229
|
(m.derivedFrom ? ` (${m.denoise ? "denoised " + m.denoise : "derived"} from ${m.derivedFrom})` : "");
|
|
1220
1230
|
});
|
|
1221
1231
|
})(),
|
package/server.js
CHANGED
|
@@ -1200,7 +1200,8 @@ const server = http.createServer(async (req, res) => {
|
|
|
1200
1200
|
}
|
|
1201
1201
|
|
|
1202
1202
|
/* API: download an HTTPS URL into ./media (same-origin src after import).
|
|
1203
|
-
Body {url}
|
|
1203
|
+
Body {url, name?} (name: the file name to save as; its extension follows
|
|
1204
|
+
the download). Rejects http/file/local/private targets. Does not register
|
|
1204
1205
|
project media — the client / MCP tool does that, matching /api/upload. */
|
|
1205
1206
|
if (p === "/api/import-url" && req.method === "POST") {
|
|
1206
1207
|
try {
|
|
@@ -1212,6 +1213,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
1212
1213
|
res.on("close", () => { if (!res.writableEnded) ac.abort(); });
|
|
1213
1214
|
const { target, name } = await downloadImportUrl(opts.url, MEDIA_DIR, {
|
|
1214
1215
|
signal: ac.signal,
|
|
1216
|
+
name: typeof opts.name === "string" && opts.name.trim() ? opts.name : undefined,
|
|
1215
1217
|
// test/rest-api.test.js: HTTP to 127.0.0.1 only (loopback fixture).
|
|
1216
1218
|
// Does not disable SSRF for LAN / metadata / other private ranges.
|
|
1217
1219
|
allowLoopback: process.env.FABLECUT_TEST_IMPORT_ALLOW_PRIVATE === "1",
|
package/style.css
CHANGED
|
@@ -486,6 +486,26 @@ body.track-size-s .clip.selected {
|
|
|
486
486
|
border-bottom-color: var(--accent);
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
+
/* the open group's own tabs (Audio: Music, SFX · Graphics: Elements…Templates) */
|
|
490
|
+
.bin-subtabs {
|
|
491
|
+
display: flex;
|
|
492
|
+
gap: 4px;
|
|
493
|
+
padding: 6px 8px 0;
|
|
494
|
+
}
|
|
495
|
+
.bin-subtabs.hidden, .bin-subtabs button.hidden { display: none; }
|
|
496
|
+
.bin-subtabs button {
|
|
497
|
+
background: none;
|
|
498
|
+
border: 1px solid transparent;
|
|
499
|
+
border-radius: 6px;
|
|
500
|
+
color: var(--dim);
|
|
501
|
+
font: 600 11px/1.2 "Segoe UI", sans-serif;
|
|
502
|
+
padding: 4px 10px;
|
|
503
|
+
cursor: pointer;
|
|
504
|
+
white-space: nowrap;
|
|
505
|
+
}
|
|
506
|
+
.bin-subtabs button:hover { color: var(--text); }
|
|
507
|
+
.bin-subtabs button.on { color: #cfc8ff; background: #7b6cff22; border-color: #7b6cff55; }
|
|
508
|
+
|
|
489
509
|
.bin-list {
|
|
490
510
|
flex: 1;
|
|
491
511
|
overflow-y: auto;
|
|
@@ -4825,3 +4845,35 @@ input[type=number]:hover::-webkit-inner-spin-button { opacity: .8; }
|
|
|
4825
4845
|
@media (forced-colors: active) {
|
|
4826
4846
|
.cmdk-item.active { outline: 2px solid Highlight; background: Highlight; color: HighlightText; }
|
|
4827
4847
|
}
|
|
4848
|
+
|
|
4849
|
+
/* Music tab (Openverse search) */
|
|
4850
|
+
.music-search { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
|
|
4851
|
+
.music-search input[type="search"] { width: 100%; box-sizing: border-box; background: var(--panel); border: 1px solid var(--border); border-radius: 5px; color: var(--text); font: 12px "Segoe UI", sans-serif; padding: 4px 8px; outline: none; user-select: text; }
|
|
4852
|
+
.music-search input[type="search"]:focus { border-color: var(--accent); }
|
|
4853
|
+
.music-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; }
|
|
4854
|
+
.music-filters select { flex: 1 1 90px; min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 5px; color: var(--text); font: 11px "Segoe UI", sans-serif; padding: 3px 4px; }
|
|
4855
|
+
.music-commercial { display: flex; align-items: center; gap: 4px; color: var(--dim); white-space: nowrap; cursor: pointer; }
|
|
4856
|
+
.music-moods { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 0 6px; }
|
|
4857
|
+
.music-moods .bin-tag { font-size: 11px; padding: 2px 8px; }
|
|
4858
|
+
.music-status { font-size: 11px; color: var(--dim); padding: 2px 2px 4px; }
|
|
4859
|
+
.music-status.err { color: #f0c14a; }
|
|
4860
|
+
.music-item { align-items: center; }
|
|
4861
|
+
.music-item .bin-meta { min-width: 0; }
|
|
4862
|
+
.music-item .music-play, .music-item .music-get { flex: none; width: 26px; padding: 3px 0; text-align: center; }
|
|
4863
|
+
.music-lic { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 2px; font-size: 10px; color: var(--dim); }
|
|
4864
|
+
.music-badge { padding: 0 5px; border-radius: 6px; background: #4f8cff26; color: #b9d0ff; text-decoration: none; white-space: nowrap; line-height: 1.5; }
|
|
4865
|
+
.music-badge.free { background: #2fbf7126; color: #9be3bc; }
|
|
4866
|
+
.music-badge.nc { background: #f0c14a24; color: #f0c14a; }
|
|
4867
|
+
.music-badge.no { background: #e5484d26; color: #ff9c9f; }
|
|
4868
|
+
.music-page { color: var(--dim); }
|
|
4869
|
+
.music-page:hover, .music-badge:hover { text-decoration: underline; }
|
|
4870
|
+
.music-more { align-self: center; margin: 4px 0; }
|
|
4871
|
+
.music-about { font-size: 10px; line-height: 1.45; color: var(--dim); margin: 8px 2px 2px; }
|
|
4872
|
+
.music-about a { color: inherit; }
|
|
4873
|
+
.music-status.lib-head { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
|
|
4874
|
+
.bin-info .bin-copy-credit { margin: 6px 0 2px; }
|
|
4875
|
+
.export-credits { margin: 0 0 12px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-sub); font-size: 12px; line-height: 1.4; }
|
|
4876
|
+
.export-credits-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
|
|
4877
|
+
.export-credits-head .btn { margin-left: auto; }
|
|
4878
|
+
.export-credit { color: var(--dim); overflow-wrap: anywhere; }
|
|
4879
|
+
.export-credit.warn { color: #f0c14a; }
|