fluncle 0.283.0 → 0.285.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/bin/fluncle.mjs +955 -13
- package/package.json +1 -1
package/bin/fluncle.mjs
CHANGED
|
@@ -704,7 +704,7 @@ function parseVersion(version) {
|
|
|
704
704
|
var currentVersion;
|
|
705
705
|
var init_version = __esm(() => {
|
|
706
706
|
init_output();
|
|
707
|
-
currentVersion = "0.
|
|
707
|
+
currentVersion = "0.285.0".trim() ? "0.285.0".trim() : "0.1.0";
|
|
708
708
|
});
|
|
709
709
|
|
|
710
710
|
// src/update-notifier.ts
|
|
@@ -11145,7 +11145,7 @@ function parseVersion2(version) {
|
|
|
11145
11145
|
var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
|
|
11146
11146
|
var init_version2 = __esm(() => {
|
|
11147
11147
|
init_output();
|
|
11148
|
-
currentVersion2 = "0.
|
|
11148
|
+
currentVersion2 = "0.285.0".trim() ? "0.285.0".trim() : "0.1.0";
|
|
11149
11149
|
});
|
|
11150
11150
|
|
|
11151
11151
|
// ../../packages/registry/src/index.ts
|
|
@@ -14159,6 +14159,18 @@ function prefixIssues(path, issues) {
|
|
|
14159
14159
|
function unwrapMessage(message) {
|
|
14160
14160
|
return typeof message === "string" ? message : message?.message;
|
|
14161
14161
|
}
|
|
14162
|
+
function sizeCaps(defChecks) {
|
|
14163
|
+
const caps = [];
|
|
14164
|
+
for (const ch of defChecks ?? []) {
|
|
14165
|
+
const d = ch._zod.def;
|
|
14166
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
14167
|
+
break;
|
|
14168
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
14169
|
+
if (max >= 0)
|
|
14170
|
+
caps.push([max, ch]);
|
|
14171
|
+
}
|
|
14172
|
+
return caps;
|
|
14173
|
+
}
|
|
14162
14174
|
function attachSchema(issues, start, inst) {
|
|
14163
14175
|
var _a;
|
|
14164
14176
|
for (let i = start;i < issues.length; i++) {
|
|
@@ -15204,7 +15216,7 @@ var init_versions = __esm(() => {
|
|
|
15204
15216
|
version = {
|
|
15205
15217
|
major: 4,
|
|
15206
15218
|
minor: 6,
|
|
15207
|
-
patch:
|
|
15219
|
+
patch: 7
|
|
15208
15220
|
};
|
|
15209
15221
|
});
|
|
15210
15222
|
|
|
@@ -15330,6 +15342,28 @@ function isValidJWT(token, algorithm = null) {
|
|
|
15330
15342
|
return false;
|
|
15331
15343
|
}
|
|
15332
15344
|
}
|
|
15345
|
+
function capSize(inst, size) {
|
|
15346
|
+
const caps = sizeCaps(inst._zod.def.checks);
|
|
15347
|
+
if (!caps.length)
|
|
15348
|
+
return;
|
|
15349
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
15350
|
+
const parse = inst._zod.parse;
|
|
15351
|
+
inst._zod.parse = (payload, ctx) => {
|
|
15352
|
+
const n = size(payload.value);
|
|
15353
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
15354
|
+
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
15355
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
15356
|
+
const start = payload.issues.length;
|
|
15357
|
+
ch._zod.check(payload);
|
|
15358
|
+
payload.issues[start].continue = false;
|
|
15359
|
+
attachSchema(payload.issues, start, inst);
|
|
15360
|
+
return payload;
|
|
15361
|
+
}
|
|
15362
|
+
}
|
|
15363
|
+
}
|
|
15364
|
+
return parse(payload, ctx);
|
|
15365
|
+
};
|
|
15366
|
+
}
|
|
15333
15367
|
function handleArrayResult(result, final, index) {
|
|
15334
15368
|
if (result.issues.length) {
|
|
15335
15369
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -15721,7 +15755,7 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
15721
15755
|
payload.issues.push(issue(_iss));
|
|
15722
15756
|
}
|
|
15723
15757
|
}
|
|
15724
|
-
var $ZodType, toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config3())) } : { value: r.value }, $ZodString, $ZodStringFormat, $ZodGUID, $ZodUUID, $ZodEmail, URL_BAD_FORMAT = 1, URL_UNPARSEABLE = 2, asciiTabOrNewline, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodISODateTime, $ZodISODate, $ZodISOTime, $ZodISODuration, $ZodIPv4, ipv6Alphabet, $ZodIPv6, $ZodCIDRv4, $ZodCIDRv6, base64Charset, $ZodBase64, base64urlCharset, $ZodBase64URL, $ZodE164, $ZodJWT, $ZodNumber, $ZodNumberFormat, $ZodBoolean, $ZodNull, $ZodUnknown, $ZodNever, $ZodArray, NO_SYMBOL_KEYS, $ZodObject, $ZodObjectJIT, $ZodUnion, $ZodDiscriminatedUnion, $ZodIntersection, $ZodTuple, $ZodRecord, $ZodEnum, $ZodLiteral, $ZodTransform, $ZodOptional, $ZodExactOptional, $ZodNullable, $ZodDefault, $ZodPrefault, $ZodNonOptional, $ZodCatch, $ZodPipe, $ZodReadonly, $ZodTemplateLiteral, $ZodLazy, $ZodCustom;
|
|
15758
|
+
var $ZodType, toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config3())) } : { value: r.value }, $ZodString, $ZodStringFormat, $ZodGUID, $ZodUUID, $ZodEmail, URL_BAD_FORMAT = 1, URL_UNPARSEABLE = 2, asciiTabOrNewline, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodISODateTime, $ZodISODate, $ZodISOTime, $ZodISODuration, $ZodIPv4, ipv6Alphabet, $ZodIPv6, $ZodCIDRv4, $ZodCIDRv6, base64Charset, $ZodBase64, base64urlCharset, $ZodBase64URL, $ZodE164, $ZodJWT, $ZodNumber, $ZodNumberFormat, $ZodBoolean, $ZodNull, $ZodUnknown, $ZodNever, arraySize = (input) => Array.isArray(input) ? input.length : -1, $ZodArray, NO_SYMBOL_KEYS, $ZodObject, $ZodObjectJIT, $ZodUnion, $ZodDiscriminatedUnion, $ZodIntersection, $ZodTuple, $ZodRecord, $ZodEnum, $ZodLiteral, $ZodTransform, $ZodOptional, $ZodExactOptional, $ZodNullable, $ZodDefault, $ZodPrefault, $ZodNonOptional, $ZodCatch, $ZodPipe, $ZodReadonly, $ZodTemplateLiteral, $ZodLazy, $ZodCustom;
|
|
15725
15759
|
var init_schemas = __esm(() => {
|
|
15726
15760
|
init_checks();
|
|
15727
15761
|
init_core2();
|
|
@@ -16207,6 +16241,7 @@ var init_schemas = __esm(() => {
|
|
|
16207
16241
|
}
|
|
16208
16242
|
return payload;
|
|
16209
16243
|
};
|
|
16244
|
+
capSize(inst, arraySize);
|
|
16210
16245
|
});
|
|
16211
16246
|
NO_SYMBOL_KEYS = [];
|
|
16212
16247
|
$ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
@@ -31453,6 +31488,7 @@ async function resolveTarget(input, deps) {
|
|
|
31453
31488
|
};
|
|
31454
31489
|
}
|
|
31455
31490
|
async function gatherLabelEvidence(input, options, deps) {
|
|
31491
|
+
const before = { cacheHits: deps.http.stats.cacheHits, network: deps.http.stats.requests };
|
|
31456
31492
|
const label = await resolveTarget(input, deps);
|
|
31457
31493
|
const wants = (source) => options.sources.includes(source);
|
|
31458
31494
|
const needsMb = wants("musicbrainz") || wants("discogs") || wants("beatport") || wants("apple");
|
|
@@ -31474,7 +31510,10 @@ async function gatherLabelEvidence(input, options, deps) {
|
|
|
31474
31510
|
label: { ...label, name: label.name ?? mb.label?.name },
|
|
31475
31511
|
ok: answered.length > 0,
|
|
31476
31512
|
partial: answered.length < requested.length || errors.length > 0,
|
|
31477
|
-
requests: {
|
|
31513
|
+
requests: {
|
|
31514
|
+
cacheHits: deps.http.stats.cacheHits - before.cacheHits,
|
|
31515
|
+
network: deps.http.stats.requests - before.network
|
|
31516
|
+
},
|
|
31478
31517
|
sources
|
|
31479
31518
|
};
|
|
31480
31519
|
}
|
|
@@ -31529,17 +31568,17 @@ function defaultBeatportScraper(env, http) {
|
|
|
31529
31568
|
}
|
|
31530
31569
|
return env.firecrawlBinary ? firecrawlCliScraper(env.firecrawlBinary) : null;
|
|
31531
31570
|
}
|
|
31532
|
-
async function
|
|
31571
|
+
async function createLabelEvidenceDeps(refresh) {
|
|
31533
31572
|
const [{ readOptionalEnv }, { resolveLabel }] = await Promise.all([
|
|
31534
31573
|
Promise.resolve().then(() => (init_env(), exports_env)),
|
|
31535
31574
|
Promise.resolve().then(() => (init_admin_labels3(), exports_admin_labels))
|
|
31536
31575
|
]);
|
|
31537
|
-
const http = createEvidenceHttp({ deadline: deadlineAt(), refresh
|
|
31576
|
+
const http = createEvidenceHttp({ deadline: deadlineAt(), refresh });
|
|
31538
31577
|
const discogsToken = readOptionalEnv("DISCOGS_USER_TOKEN");
|
|
31539
31578
|
if (discogsToken) {
|
|
31540
31579
|
http.policies = { ...http.policies, discogs: { ...http.policies.discogs, intervalMs: 1100 } };
|
|
31541
31580
|
}
|
|
31542
|
-
return
|
|
31581
|
+
return {
|
|
31543
31582
|
discogsToken,
|
|
31544
31583
|
http,
|
|
31545
31584
|
resolveLabel,
|
|
@@ -31547,11 +31586,60 @@ async function labelEvidenceCommand(input, options) {
|
|
|
31547
31586
|
firecrawlApiKey: readOptionalEnv("FIRECRAWL_API_KEY"),
|
|
31548
31587
|
firecrawlBinary: Bun.which("firecrawl")
|
|
31549
31588
|
}, http)
|
|
31550
|
-
}
|
|
31589
|
+
};
|
|
31590
|
+
}
|
|
31591
|
+
async function labelEvidenceCommand(input, options) {
|
|
31592
|
+
return gatherLabelEvidence(input, options, await createLabelEvidenceDeps(options.refresh));
|
|
31551
31593
|
}
|
|
31552
31594
|
function countLine(counts, limit) {
|
|
31553
31595
|
return counts.slice(0, limit).map((entry) => `${entry.name} ${entry.count}`).join(", ");
|
|
31554
31596
|
}
|
|
31597
|
+
function musicbrainzDetailLines(mb) {
|
|
31598
|
+
const lines = [];
|
|
31599
|
+
if (mb?.label?.labelRelations.length) {
|
|
31600
|
+
lines.push(` label relations: ${mb.label.labelRelations.map((relation) => `${relation.type}: ${relation.name} (${relation.mbid})`).join("; ")}`);
|
|
31601
|
+
}
|
|
31602
|
+
if (mb?.census) {
|
|
31603
|
+
lines.push(` first credits: ${mb.census.firstCredits.map((credit) => `${credit.artistName} (${credit.artistMbid}) ${credit.recordings}`).join("; ")}; uncredited ${mb.census.uncreditedRecordings}`);
|
|
31604
|
+
}
|
|
31605
|
+
for (const release of mb?.releases?.releases ?? []) {
|
|
31606
|
+
lines.push(` release: ${release.artist} — ${release.title}; catno ${release.catno ?? "none"}; ${release.date ?? "undated"}; format ${release.format ?? "unknown"}; status ${release.status ?? "unknown"}; barcode ${release.barcode ?? "none"}`);
|
|
31607
|
+
}
|
|
31608
|
+
return lines;
|
|
31609
|
+
}
|
|
31610
|
+
function discogsDetailLines(discogs) {
|
|
31611
|
+
const lines = [];
|
|
31612
|
+
if (discogs?.label) {
|
|
31613
|
+
lines.push(` profile: ${discogs.label.profile || "none"}`);
|
|
31614
|
+
lines.push(` parent: ${discogs.label.parentLabel ? `${discogs.label.parentLabel.name} (${discogs.label.parentLabel.id})` : "none"}; sublabels: ${discogs.label.sublabels.join(", ") || "none"}`);
|
|
31615
|
+
}
|
|
31616
|
+
if (discogs?.releases) {
|
|
31617
|
+
lines.push(` ${discogs.releases.releaseCount} releases; top artists: ${discogs.releases.topArtists.map((artist) => `${artist.name} ${artist.releases}`).join(", ") || "none"}`);
|
|
31618
|
+
for (const release of discogs.releases.sample) {
|
|
31619
|
+
lines.push(` release: ${release.artist} — ${release.title}; catno ${release.catno ?? "none"}; year ${release.year ?? "unknown"}; format ${release.format ?? "unknown"}`);
|
|
31620
|
+
}
|
|
31621
|
+
}
|
|
31622
|
+
if (discogs?.styles) {
|
|
31623
|
+
lines.push(` genres: ${countLine(discogs.styles.genres, discogs.styles.genres.length) || "none"}`);
|
|
31624
|
+
lines.push(` all styles: ${countLine(discogs.styles.styles, discogs.styles.styles.length) || "none"}`);
|
|
31625
|
+
}
|
|
31626
|
+
return lines;
|
|
31627
|
+
}
|
|
31628
|
+
function beatportDetailLines(beatport) {
|
|
31629
|
+
const lines = [];
|
|
31630
|
+
if (beatport) {
|
|
31631
|
+
lines.push(` subgenres: ${countLine(beatport.subGenres, beatport.subGenres.length) || "none"}`);
|
|
31632
|
+
lines.push(` top artists: ${countLine(beatport.topArtists, beatport.topArtists.length) || "none"}`);
|
|
31633
|
+
}
|
|
31634
|
+
return lines;
|
|
31635
|
+
}
|
|
31636
|
+
function appleDetailLines(apple) {
|
|
31637
|
+
const lines = [];
|
|
31638
|
+
for (const release of apple?.releases ?? []) {
|
|
31639
|
+
lines.push(release.found ? ` Apple match: ${release.mbTitle}; barcode ${release.barcode}; genre ${release.primaryGenreName ?? "unknown"}; artist ${release.artistName ?? "unknown"}; title ${release.collectionName ?? "unknown"}; copyright ${release.copyright ?? "unknown"}` : ` Apple unmatched: ${release.mbTitle}; barcode ${release.barcode}`);
|
|
31640
|
+
}
|
|
31641
|
+
return lines;
|
|
31642
|
+
}
|
|
31555
31643
|
function labelEvidenceLines(evidence) {
|
|
31556
31644
|
const { apple, beatport, discogs, musicbrainz } = evidence.sources;
|
|
31557
31645
|
const mb = musicbrainz.data;
|
|
@@ -31562,22 +31650,26 @@ function labelEvidenceLines(evidence) {
|
|
|
31562
31650
|
mbParts.push([mb.label.type, mb.label.area, mb.label.lifeSpan.begin].filter(Boolean).join(", "));
|
|
31563
31651
|
}
|
|
31564
31652
|
if (mb?.releases) {
|
|
31565
|
-
const top = mb.releases.firstCreditArtists.slice(0,
|
|
31653
|
+
const top = mb.releases.firstCreditArtists.slice(0, FIRST_CREDIT_ARTISTS).map((artist) => `${artist.name} ${artist.releases}`).join(", ");
|
|
31566
31654
|
mbParts.push(`${mb.releases.releaseCount} releases; first credits: ${top || "none"}`);
|
|
31567
31655
|
}
|
|
31568
31656
|
if (mb?.census) {
|
|
31569
31657
|
mbParts.push(`census ${mb.census.recordingsCounted} recordings over ${mb.census.releasesRead} releases${mb.census.caveat ? ` (${mb.census.caveat})` : ""}`);
|
|
31570
31658
|
}
|
|
31571
31659
|
lines.push(` musicbrainz: ${musicbrainz.status}${mbParts.length ? ` — ${mbParts.join("; ")}` : ""}`);
|
|
31660
|
+
lines.push(...musicbrainzDetailLines(mb));
|
|
31572
31661
|
const dg = discogs.data;
|
|
31573
31662
|
const dgDetail = dg?.styles ? `styles: ${countLine(dg.styles.styles, 6)} (${dg.styles.releasesRead} releases)` : dg?.candidates ? `unverified candidates: ${dg.candidates.map((c) => c.title).join(", ") || "none"}` : discogs.note;
|
|
31574
31663
|
lines.push(` discogs: ${discogs.status}${dgDetail ? ` — ${dgDetail}` : ""}`);
|
|
31664
|
+
lines.push(...discogsDetailLines(dg));
|
|
31575
31665
|
const bp = beatport.data;
|
|
31576
31666
|
const bpDetail = bp ? `${bp.trackCount} tracks; genres: ${bp.genres.slice(0, 5).map((genre) => `${genre.name} ${Math.round(genre.share * 100)}%`).join(", ")}` : beatport.note;
|
|
31577
31667
|
lines.push(` beatport: ${beatport.status}${bpDetail ? ` — ${bpDetail}` : ""}`);
|
|
31668
|
+
lines.push(...beatportDetailLines(bp));
|
|
31578
31669
|
const ap = apple.data;
|
|
31579
31670
|
const apDetail = ap ? `${ap.found}/${ap.looked} found; genres: ${countLine(ap.genres, 4) || "none"}` : apple.note;
|
|
31580
31671
|
lines.push(` apple: ${apple.status}${apDetail ? ` — ${apDetail}` : ""}`);
|
|
31672
|
+
lines.push(...appleDetailLines(ap));
|
|
31581
31673
|
for (const failure of evidence.errors) {
|
|
31582
31674
|
lines.push(` ! ${failure.source}: ${failure.message}`);
|
|
31583
31675
|
}
|
|
@@ -31591,6 +31683,833 @@ var init_admin_label_evidence = __esm(() => {
|
|
|
31591
31683
|
EVIDENCE_SOURCES = ["musicbrainz", "discogs", "beatport", "apple"];
|
|
31592
31684
|
});
|
|
31593
31685
|
|
|
31686
|
+
// src/commands/admin-label-evidence.ts
|
|
31687
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
31688
|
+
function failureOf2(error, request) {
|
|
31689
|
+
if (error instanceof EvidenceFetchError) {
|
|
31690
|
+
return {
|
|
31691
|
+
attempts: error.attempts,
|
|
31692
|
+
kind: error.kind,
|
|
31693
|
+
message: error.message,
|
|
31694
|
+
request,
|
|
31695
|
+
...error.status === undefined ? {} : { status: error.status }
|
|
31696
|
+
};
|
|
31697
|
+
}
|
|
31698
|
+
return {
|
|
31699
|
+
kind: "parse",
|
|
31700
|
+
message: error instanceof Error ? error.message : String(error),
|
|
31701
|
+
request
|
|
31702
|
+
};
|
|
31703
|
+
}
|
|
31704
|
+
function statusFrom2(parts, failures) {
|
|
31705
|
+
if (failures === 0) {
|
|
31706
|
+
return "ok";
|
|
31707
|
+
}
|
|
31708
|
+
return failures < parts ? "partial" : "error";
|
|
31709
|
+
}
|
|
31710
|
+
function tally2(names) {
|
|
31711
|
+
const counts = new Map;
|
|
31712
|
+
for (const name of names) {
|
|
31713
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
31714
|
+
}
|
|
31715
|
+
return [...counts.entries()].map(([name, count]) => ({ count, name })).sort((a, b) => b.count - a.count || a.name.localeCompare(b.name));
|
|
31716
|
+
}
|
|
31717
|
+
function firstCredit2(credit) {
|
|
31718
|
+
const head = credit?.[0];
|
|
31719
|
+
const mbid = head?.artist?.id;
|
|
31720
|
+
if (!mbid) {
|
|
31721
|
+
return null;
|
|
31722
|
+
}
|
|
31723
|
+
return { mbid, name: head?.artist?.name ?? head?.name ?? mbid };
|
|
31724
|
+
}
|
|
31725
|
+
function crawlRuleCredit2(credit) {
|
|
31726
|
+
for (const entry of credit ?? []) {
|
|
31727
|
+
const name = entry.artist?.name ?? entry.name;
|
|
31728
|
+
const mbid = entry.artist?.id;
|
|
31729
|
+
if (name && mbid && mbid !== VARIOUS_ARTISTS_MBID2) {
|
|
31730
|
+
return { mbid, name };
|
|
31731
|
+
}
|
|
31732
|
+
}
|
|
31733
|
+
return null;
|
|
31734
|
+
}
|
|
31735
|
+
function creditString2(credit) {
|
|
31736
|
+
return (credit ?? []).map((entry) => entry.name ?? entry.artist?.name ?? "").join(" / ");
|
|
31737
|
+
}
|
|
31738
|
+
function linkOf2(links, host) {
|
|
31739
|
+
return links.find((link) => link.url.includes(host))?.url ?? null;
|
|
31740
|
+
}
|
|
31741
|
+
function toLabelFacts2(payload, mbid) {
|
|
31742
|
+
const relations = payload.relations ?? [];
|
|
31743
|
+
return {
|
|
31744
|
+
area: payload.area?.name ?? null,
|
|
31745
|
+
country: payload.country ?? null,
|
|
31746
|
+
disambiguation: payload.disambiguation || null,
|
|
31747
|
+
genres: (payload.genres ?? []).flatMap((genre) => genre.name ? [genre.name] : []),
|
|
31748
|
+
labelCode: payload["label-code"] ?? null,
|
|
31749
|
+
labelRelations: relations.flatMap((relation) => relation.label?.id ? [
|
|
31750
|
+
{
|
|
31751
|
+
direction: relation.direction ?? "forward",
|
|
31752
|
+
mbid: relation.label.id,
|
|
31753
|
+
name: relation.label.name ?? relation.label.id,
|
|
31754
|
+
type: relation.type ?? "unknown"
|
|
31755
|
+
}
|
|
31756
|
+
] : []),
|
|
31757
|
+
lifeSpan: {
|
|
31758
|
+
begin: payload["life-span"]?.begin ?? null,
|
|
31759
|
+
end: payload["life-span"]?.end ?? null,
|
|
31760
|
+
ended: payload["life-span"]?.ended === true
|
|
31761
|
+
},
|
|
31762
|
+
links: relations.flatMap((relation) => relation.url?.resource ? [{ type: relation.type ?? "unknown", url: relation.url.resource }] : []),
|
|
31763
|
+
mbid: payload.id ?? mbid,
|
|
31764
|
+
name: payload.name ?? mbid,
|
|
31765
|
+
tags: (payload.tags ?? []).flatMap((tag) => tag.name ? [tag.name] : []),
|
|
31766
|
+
type: payload.type ?? null
|
|
31767
|
+
};
|
|
31768
|
+
}
|
|
31769
|
+
function toReleaseFacts2(browse, mbid) {
|
|
31770
|
+
const releases = browse.releases ?? [];
|
|
31771
|
+
const byArtist = new Map;
|
|
31772
|
+
let variousArtistsReleases = 0;
|
|
31773
|
+
const samples = releases.map((release) => {
|
|
31774
|
+
const head = firstCredit2(release["artist-credit"]);
|
|
31775
|
+
if (head?.mbid === VARIOUS_ARTISTS_MBID2) {
|
|
31776
|
+
variousArtistsReleases += 1;
|
|
31777
|
+
} else if (head) {
|
|
31778
|
+
const entry = byArtist.get(head.mbid) ?? { mbid: head.mbid, name: head.name, releases: 0 };
|
|
31779
|
+
entry.releases += 1;
|
|
31780
|
+
byArtist.set(head.mbid, entry);
|
|
31781
|
+
}
|
|
31782
|
+
const info = release["label-info"]?.find((entry) => entry.label?.id === mbid);
|
|
31783
|
+
const formats = [
|
|
31784
|
+
...new Set((release.media ?? []).flatMap((m) => m.format ? [m.format] : []))
|
|
31785
|
+
];
|
|
31786
|
+
return {
|
|
31787
|
+
artist: creditString2(release["artist-credit"]),
|
|
31788
|
+
barcode: release.barcode || null,
|
|
31789
|
+
catno: info?.["catalog-number"] ?? null,
|
|
31790
|
+
date: release.date || null,
|
|
31791
|
+
format: formats.length > 0 ? formats.join(" + ") : null,
|
|
31792
|
+
mbid: release.id,
|
|
31793
|
+
status: release.status ?? null,
|
|
31794
|
+
title: release.title ?? ""
|
|
31795
|
+
};
|
|
31796
|
+
});
|
|
31797
|
+
return {
|
|
31798
|
+
firstCreditArtists: [...byArtist.values()].sort((a, b) => b.releases - a.releases || a.name.localeCompare(b.name)).slice(0, FIRST_CREDIT_ARTISTS2),
|
|
31799
|
+
releaseCount: browse["release-count"] ?? releases.length,
|
|
31800
|
+
releases: samples.sort((a, b) => (b.date ?? "").localeCompare(a.date ?? "")).slice(0, RELEASE_SAMPLE2),
|
|
31801
|
+
releasesRead: releases.length,
|
|
31802
|
+
variousArtistsReleases
|
|
31803
|
+
};
|
|
31804
|
+
}
|
|
31805
|
+
async function runCensus2(deps, mbid, maxPages) {
|
|
31806
|
+
const credits = new Map;
|
|
31807
|
+
const seen = new Set;
|
|
31808
|
+
let offset = 0;
|
|
31809
|
+
let pagesFetched = 0;
|
|
31810
|
+
let releaseCount = 0;
|
|
31811
|
+
let allCached = true;
|
|
31812
|
+
let failure;
|
|
31813
|
+
let uncredited = 0;
|
|
31814
|
+
while (pagesFetched < maxPages) {
|
|
31815
|
+
const url = `${MB_ROOT2}/release?label=${mbid}&inc=artist-credits+recordings&limit=100&offset=${offset}&fmt=json`;
|
|
31816
|
+
let page;
|
|
31817
|
+
try {
|
|
31818
|
+
page = await fetchEvidenceJson(deps.http, "musicbrainz", url);
|
|
31819
|
+
} catch (error) {
|
|
31820
|
+
if (pagesFetched === 0) {
|
|
31821
|
+
throw error;
|
|
31822
|
+
}
|
|
31823
|
+
failure = failureOf2(error, url);
|
|
31824
|
+
break;
|
|
31825
|
+
}
|
|
31826
|
+
const { cached, data } = page;
|
|
31827
|
+
const releases = data.releases ?? [];
|
|
31828
|
+
allCached &&= cached;
|
|
31829
|
+
pagesFetched += 1;
|
|
31830
|
+
releaseCount = data["release-count"] ?? releaseCount;
|
|
31831
|
+
for (const release of releases) {
|
|
31832
|
+
for (const medium of release.media ?? []) {
|
|
31833
|
+
for (const track of medium.tracks ?? []) {
|
|
31834
|
+
const recordingId = track.recording?.id;
|
|
31835
|
+
if (!recordingId || seen.has(recordingId)) {
|
|
31836
|
+
continue;
|
|
31837
|
+
}
|
|
31838
|
+
seen.add(recordingId);
|
|
31839
|
+
const head = crawlRuleCredit2(track.recording?.["artist-credit"] ?? release["artist-credit"]);
|
|
31840
|
+
if (!head) {
|
|
31841
|
+
uncredited += 1;
|
|
31842
|
+
continue;
|
|
31843
|
+
}
|
|
31844
|
+
const entry = credits.get(head.mbid) ?? {
|
|
31845
|
+
artistMbid: head.mbid,
|
|
31846
|
+
artistName: head.name,
|
|
31847
|
+
recordings: 0
|
|
31848
|
+
};
|
|
31849
|
+
entry.recordings += 1;
|
|
31850
|
+
credits.set(head.mbid, entry);
|
|
31851
|
+
}
|
|
31852
|
+
}
|
|
31853
|
+
}
|
|
31854
|
+
offset += releases.length;
|
|
31855
|
+
if (releases.length === 0 || offset >= releaseCount) {
|
|
31856
|
+
break;
|
|
31857
|
+
}
|
|
31858
|
+
}
|
|
31859
|
+
const sampled = offset < releaseCount;
|
|
31860
|
+
const firstCredits = [...credits.values()].sort((a, b) => b.recordings - a.recordings || a.artistName.localeCompare(b.artistName));
|
|
31861
|
+
return {
|
|
31862
|
+
cached: allCached,
|
|
31863
|
+
...failure ? { failure } : {},
|
|
31864
|
+
census: {
|
|
31865
|
+
caveat: sampled ? `sampled: first ${offset} of ${releaseCount} releases${failure ? " (a later page failed)" : ""}` : null,
|
|
31866
|
+
firstCredits,
|
|
31867
|
+
pagesFetched,
|
|
31868
|
+
recordingsCounted: firstCredits.reduce((sum, entry) => sum + entry.recordings, uncredited),
|
|
31869
|
+
releaseCount,
|
|
31870
|
+
releasesRead: offset,
|
|
31871
|
+
sampled,
|
|
31872
|
+
uncreditedRecordings: uncredited
|
|
31873
|
+
}
|
|
31874
|
+
};
|
|
31875
|
+
}
|
|
31876
|
+
async function gatherMusicBrainz2(deps, mbid, options) {
|
|
31877
|
+
const data = {};
|
|
31878
|
+
const errors = [];
|
|
31879
|
+
let parts = 2;
|
|
31880
|
+
let allCached = true;
|
|
31881
|
+
const labelUrl = `${MB_ROOT2}/label/${mbid}?inc=aliases+label-rels+url-rels+tags+genres&fmt=json`;
|
|
31882
|
+
try {
|
|
31883
|
+
const { cached, data: payload } = await fetchEvidenceJson(deps.http, "musicbrainz", labelUrl);
|
|
31884
|
+
allCached &&= cached;
|
|
31885
|
+
data.label = toLabelFacts2(payload, mbid);
|
|
31886
|
+
} catch (error) {
|
|
31887
|
+
errors.push(failureOf2(error, labelUrl));
|
|
31888
|
+
}
|
|
31889
|
+
const releasesUrl = `${MB_ROOT2}/release?label=${mbid}&inc=artist-credits+labels+media&limit=100&fmt=json`;
|
|
31890
|
+
try {
|
|
31891
|
+
const { cached, data: browse } = await fetchEvidenceJson(deps.http, "musicbrainz", releasesUrl);
|
|
31892
|
+
allCached &&= cached;
|
|
31893
|
+
data.releases = toReleaseFacts2(browse, mbid);
|
|
31894
|
+
} catch (error) {
|
|
31895
|
+
errors.push(failureOf2(error, releasesUrl));
|
|
31896
|
+
}
|
|
31897
|
+
if (options.census) {
|
|
31898
|
+
parts += 1;
|
|
31899
|
+
try {
|
|
31900
|
+
const { cached, census, failure } = await runCensus2(deps, mbid, options.censusPages);
|
|
31901
|
+
allCached &&= cached;
|
|
31902
|
+
data.census = census;
|
|
31903
|
+
if (failure) {
|
|
31904
|
+
errors.push(failure);
|
|
31905
|
+
}
|
|
31906
|
+
} catch (error) {
|
|
31907
|
+
errors.push(failureOf2(error, `${MB_ROOT2}/release?label=${mbid}&inc=recordings (census)`));
|
|
31908
|
+
}
|
|
31909
|
+
}
|
|
31910
|
+
return {
|
|
31911
|
+
cached: allCached,
|
|
31912
|
+
data,
|
|
31913
|
+
...errors.length > 0 ? { errors } : {},
|
|
31914
|
+
status: statusFrom2(parts, errors.length)
|
|
31915
|
+
};
|
|
31916
|
+
}
|
|
31917
|
+
function discogsLabelIdFrom2(url) {
|
|
31918
|
+
const match = url ? /discogs\.com\/(?:[a-z]{2}\/)?label\/(\d+)/i.exec(url) : null;
|
|
31919
|
+
return match?.[1] ? Number(match[1]) : null;
|
|
31920
|
+
}
|
|
31921
|
+
function beatportLabelUrlFrom2(url) {
|
|
31922
|
+
const match = url ? /beatport\.com\/label\/([^/?#]+)\/(\d+)/i.exec(url) : null;
|
|
31923
|
+
return match?.[1] && match[2] ? `https://www.beatport.com/label/${match[1]}/${match[2]}` : null;
|
|
31924
|
+
}
|
|
31925
|
+
function discogsHeaders2(deps) {
|
|
31926
|
+
return deps.discogsToken ? { Authorization: `Discogs token=${deps.discogsToken}` } : {};
|
|
31927
|
+
}
|
|
31928
|
+
async function discogsCandidates2(deps, name) {
|
|
31929
|
+
const searchUrl = `${DISCOGS_ROOT2}/database/search?type=label&q=${encodeURIComponent(name)}&per_page=5`;
|
|
31930
|
+
try {
|
|
31931
|
+
const { cached, data } = await fetchEvidenceJson(deps.http, "discogs", searchUrl, discogsHeaders2(deps));
|
|
31932
|
+
const candidates = (data.results ?? []).flatMap((result) => result.id ? [
|
|
31933
|
+
{
|
|
31934
|
+
id: result.id,
|
|
31935
|
+
title: result.title ?? "",
|
|
31936
|
+
url: `https://www.discogs.com${result.uri ?? `/label/${result.id}`}`
|
|
31937
|
+
}
|
|
31938
|
+
] : []);
|
|
31939
|
+
return {
|
|
31940
|
+
cached,
|
|
31941
|
+
data: { candidates },
|
|
31942
|
+
note: "The MusicBrainz label has no Discogs link. Candidates are unverified name matches: confirm the identity before citing any of them.",
|
|
31943
|
+
status: "no_link"
|
|
31944
|
+
};
|
|
31945
|
+
} catch (error) {
|
|
31946
|
+
return {
|
|
31947
|
+
errors: [failureOf2(error, searchUrl)],
|
|
31948
|
+
note: "The MusicBrainz label has no Discogs link.",
|
|
31949
|
+
status: "no_link"
|
|
31950
|
+
};
|
|
31951
|
+
}
|
|
31952
|
+
}
|
|
31953
|
+
function toDiscogsLabel2(payload, labelId, fallbackName) {
|
|
31954
|
+
const sublabels = (payload.sublabels ?? []).flatMap((entry) => entry.name ? [entry.name] : []);
|
|
31955
|
+
const parent = payload.parent_label;
|
|
31956
|
+
return {
|
|
31957
|
+
id: payload.id ?? labelId,
|
|
31958
|
+
name: payload.name ?? fallbackName,
|
|
31959
|
+
parentLabel: parent?.id === undefined ? null : { id: parent.id, name: parent.name ?? "" },
|
|
31960
|
+
profile: (payload.profile ?? "").slice(0, PROFILE_CHARS2),
|
|
31961
|
+
sublabelCount: sublabels.length,
|
|
31962
|
+
sublabels: sublabels.slice(0, 30),
|
|
31963
|
+
url: payload.uri ?? `https://www.discogs.com/label/${labelId}`,
|
|
31964
|
+
urls: payload.urls ?? []
|
|
31965
|
+
};
|
|
31966
|
+
}
|
|
31967
|
+
function toDiscogsReleases2(payload) {
|
|
31968
|
+
const releases = payload.releases ?? [];
|
|
31969
|
+
const ids = releases.flatMap((release) => {
|
|
31970
|
+
const id = release.type === "master" ? release.main_release : release.id;
|
|
31971
|
+
return typeof id === "number" ? [id] : [];
|
|
31972
|
+
});
|
|
31973
|
+
return {
|
|
31974
|
+
facts: {
|
|
31975
|
+
releaseCount: payload.pagination?.items ?? releases.length,
|
|
31976
|
+
sample: releases.slice(0, DISCOGS_RELEASE_SAMPLE2).map((release) => ({
|
|
31977
|
+
artist: release.artist ?? "",
|
|
31978
|
+
catno: release.catno ?? null,
|
|
31979
|
+
format: release.format ?? null,
|
|
31980
|
+
title: release.title ?? "",
|
|
31981
|
+
year: release.year || null
|
|
31982
|
+
})),
|
|
31983
|
+
topArtists: tally2(releases.map((release) => release.artist ?? "")).filter((entry) => entry.name !== "").slice(0, 15).map((entry) => ({ name: entry.name, releases: entry.count }))
|
|
31984
|
+
},
|
|
31985
|
+
ids
|
|
31986
|
+
};
|
|
31987
|
+
}
|
|
31988
|
+
async function gatherDiscogs2(deps, mb) {
|
|
31989
|
+
const labelFacts = mb.label;
|
|
31990
|
+
if (!labelFacts) {
|
|
31991
|
+
return {
|
|
31992
|
+
note: "MusicBrainz label unavailable, so no Discogs link to follow",
|
|
31993
|
+
status: "skipped"
|
|
31994
|
+
};
|
|
31995
|
+
}
|
|
31996
|
+
const labelId = discogsLabelIdFrom2(linkOf2(labelFacts.links, "discogs.com"));
|
|
31997
|
+
if (labelId === null) {
|
|
31998
|
+
return discogsCandidates2(deps, labelFacts.name);
|
|
31999
|
+
}
|
|
32000
|
+
const headers = discogsHeaders2(deps);
|
|
32001
|
+
const data = {};
|
|
32002
|
+
const errors = [];
|
|
32003
|
+
const releaseIds = new Set;
|
|
32004
|
+
let allCached = true;
|
|
32005
|
+
const labelUrl = `${DISCOGS_ROOT2}/labels/${labelId}`;
|
|
32006
|
+
try {
|
|
32007
|
+
const { cached, data: payload } = await fetchEvidenceJson(deps.http, "discogs", labelUrl, headers);
|
|
32008
|
+
allCached &&= cached;
|
|
32009
|
+
data.label = toDiscogsLabel2(payload, labelId, labelFacts.name);
|
|
32010
|
+
} catch (error) {
|
|
32011
|
+
errors.push(failureOf2(error, labelUrl));
|
|
32012
|
+
}
|
|
32013
|
+
const releasesUrl = `${DISCOGS_ROOT2}/labels/${labelId}/releases?per_page=100&page=1`;
|
|
32014
|
+
try {
|
|
32015
|
+
const { cached, data: payload } = await fetchEvidenceJson(deps.http, "discogs", releasesUrl, headers);
|
|
32016
|
+
allCached &&= cached;
|
|
32017
|
+
const { facts, ids } = toDiscogsReleases2(payload);
|
|
32018
|
+
data.releases = facts;
|
|
32019
|
+
for (const id of ids) {
|
|
32020
|
+
releaseIds.add(id);
|
|
32021
|
+
}
|
|
32022
|
+
} catch (error) {
|
|
32023
|
+
errors.push(failureOf2(error, releasesUrl));
|
|
32024
|
+
}
|
|
32025
|
+
if (releaseIds.size > 0) {
|
|
32026
|
+
const styled = await readDiscogsStyles2(deps, releaseIds, data.label?.name ?? labelFacts.name);
|
|
32027
|
+
allCached &&= styled.cached;
|
|
32028
|
+
errors.push(...styled.errors);
|
|
32029
|
+
data.styles = styled.styles;
|
|
32030
|
+
}
|
|
32031
|
+
return {
|
|
32032
|
+
cached: allCached,
|
|
32033
|
+
data,
|
|
32034
|
+
...errors.length > 0 ? { errors } : {},
|
|
32035
|
+
status: discogsStatus2(data, errors)
|
|
32036
|
+
};
|
|
32037
|
+
}
|
|
32038
|
+
function discogsStatus2(data, errors) {
|
|
32039
|
+
if (Object.keys(data).length === 0) {
|
|
32040
|
+
return "error";
|
|
32041
|
+
}
|
|
32042
|
+
return errors.length > 0 ? "partial" : "ok";
|
|
32043
|
+
}
|
|
32044
|
+
function discogsSearchName2(name) {
|
|
32045
|
+
return name.replace(/\s*\(\d+\)$/, "").replace(/^[^\p{L}\p{N}]+/u, "");
|
|
32046
|
+
}
|
|
32047
|
+
async function readDiscogsStyles2(deps, releaseIds, labelName) {
|
|
32048
|
+
const headers = discogsHeaders2(deps);
|
|
32049
|
+
const styled = new Map;
|
|
32050
|
+
const errors = [];
|
|
32051
|
+
let allCached = true;
|
|
32052
|
+
let viaSearch = 0;
|
|
32053
|
+
const searchUrl = `${DISCOGS_ROOT2}/database/search?type=release&label=${encodeURIComponent(discogsSearchName2(labelName))}&per_page=100`;
|
|
32054
|
+
try {
|
|
32055
|
+
const { cached, data } = await fetchEvidenceJson(deps.http, "discogs", searchUrl, headers);
|
|
32056
|
+
allCached &&= cached;
|
|
32057
|
+
for (const result of data.results ?? []) {
|
|
32058
|
+
if (typeof result.id === "number" && releaseIds.has(result.id) && !styled.has(result.id)) {
|
|
32059
|
+
styled.set(result.id, { genres: result.genre ?? [], styles: result.style ?? [] });
|
|
32060
|
+
}
|
|
32061
|
+
}
|
|
32062
|
+
viaSearch = styled.size;
|
|
32063
|
+
} catch (error) {
|
|
32064
|
+
errors.push(failureOf2(error, searchUrl));
|
|
32065
|
+
}
|
|
32066
|
+
const target = Math.min(DISCOGS_STYLE_TARGET2, releaseIds.size);
|
|
32067
|
+
const unread = [...releaseIds].filter((id) => !styled.has(id));
|
|
32068
|
+
let reads = 0;
|
|
32069
|
+
for (const id of unread) {
|
|
32070
|
+
if (styled.size >= target || reads >= DISCOGS_RELEASE_READS2) {
|
|
32071
|
+
break;
|
|
32072
|
+
}
|
|
32073
|
+
reads += 1;
|
|
32074
|
+
const releaseUrl = `${DISCOGS_ROOT2}/releases/${id}`;
|
|
32075
|
+
try {
|
|
32076
|
+
const { cached, data } = await fetchEvidenceJson(deps.http, "discogs", releaseUrl, headers);
|
|
32077
|
+
allCached &&= cached;
|
|
32078
|
+
styled.set(id, { genres: data.genres ?? [], styles: data.styles ?? [] });
|
|
32079
|
+
} catch (error) {
|
|
32080
|
+
errors.push(failureOf2(error, releaseUrl));
|
|
32081
|
+
}
|
|
32082
|
+
}
|
|
32083
|
+
const rows = [...styled.values()];
|
|
32084
|
+
return {
|
|
32085
|
+
cached: allCached,
|
|
32086
|
+
errors,
|
|
32087
|
+
styles: {
|
|
32088
|
+
genres: tally2(rows.flatMap((row) => row.genres)),
|
|
32089
|
+
labelReleasesListed: releaseIds.size,
|
|
32090
|
+
releasesRead: rows.length,
|
|
32091
|
+
styles: tally2(rows.flatMap((row) => row.styles)).slice(0, 25),
|
|
32092
|
+
viaRelease: rows.length - viaSearch,
|
|
32093
|
+
viaSearch
|
|
32094
|
+
}
|
|
32095
|
+
};
|
|
32096
|
+
}
|
|
32097
|
+
function facetCounts2(rows) {
|
|
32098
|
+
return (rows ?? []).flatMap((row) => row.name && typeof row.count === "number" ? [{ count: row.count, name: row.name }] : []).sort((a, b) => b.count - a.count || a.name.localeCompare(b.name));
|
|
32099
|
+
}
|
|
32100
|
+
function parseBeatportTracksPage2(html) {
|
|
32101
|
+
const island = /<script id="__NEXT_DATA__"[^>]*>([\s\S]*?)<\/script>/.exec(html);
|
|
32102
|
+
if (!island?.[1]) {
|
|
32103
|
+
return null;
|
|
32104
|
+
}
|
|
32105
|
+
let queries;
|
|
32106
|
+
try {
|
|
32107
|
+
const parsed = JSON.parse(island[1]);
|
|
32108
|
+
queries = parsed.props?.pageProps?.dehydratedState?.queries ?? [];
|
|
32109
|
+
} catch {
|
|
32110
|
+
return null;
|
|
32111
|
+
}
|
|
32112
|
+
const tracks = queries.find((query) => query.queryKey?.[0] === "tracks" && query.state?.data?.facets?.fields)?.state?.data;
|
|
32113
|
+
if (!tracks) {
|
|
32114
|
+
return null;
|
|
32115
|
+
}
|
|
32116
|
+
const fields = tracks.facets?.fields;
|
|
32117
|
+
const genres = facetCounts2(fields?.genre);
|
|
32118
|
+
const total = genres.reduce((sum, genre) => sum + genre.count, 0);
|
|
32119
|
+
return {
|
|
32120
|
+
genres: genres.map((genre) => ({
|
|
32121
|
+
...genre,
|
|
32122
|
+
share: total > 0 ? Math.round(genre.count / total * 1000) / 1000 : 0
|
|
32123
|
+
})),
|
|
32124
|
+
subGenres: facetCounts2(fields?.sub_genre),
|
|
32125
|
+
topArtists: facetCounts2(fields?.artists).slice(0, 15),
|
|
32126
|
+
trackCount: tracks.count ?? total
|
|
32127
|
+
};
|
|
32128
|
+
}
|
|
32129
|
+
async function gatherBeatport2(deps, mb) {
|
|
32130
|
+
if (!mb.label) {
|
|
32131
|
+
return {
|
|
32132
|
+
note: "MusicBrainz label unavailable, so no Beatport link to follow",
|
|
32133
|
+
status: "skipped"
|
|
32134
|
+
};
|
|
32135
|
+
}
|
|
32136
|
+
const labelUrl = beatportLabelUrlFrom2(linkOf2(mb.label.links, "beatport.com"));
|
|
32137
|
+
if (labelUrl === null) {
|
|
32138
|
+
return { note: "The MusicBrainz label has no Beatport link.", status: "no_link" };
|
|
32139
|
+
}
|
|
32140
|
+
if (deps.scraper === null) {
|
|
32141
|
+
return {
|
|
32142
|
+
note: "Beatport needs Firecrawl: set FIRECRAWL_API_KEY or install the firecrawl CLI.",
|
|
32143
|
+
status: "not_configured"
|
|
32144
|
+
};
|
|
32145
|
+
}
|
|
32146
|
+
const scraper = deps.scraper;
|
|
32147
|
+
const tracksUrl = `${labelUrl}/tracks`;
|
|
32148
|
+
try {
|
|
32149
|
+
const { cached, text } = await fetchEvidenceText(deps.http, "beatport", `SCRAPE ${tracksUrl}`, (signal) => scraper(tracksUrl, signal), (html) => parseBeatportTracksPage2(html) !== null);
|
|
32150
|
+
const facts = parseBeatportTracksPage2(text);
|
|
32151
|
+
if (facts === null) {
|
|
32152
|
+
return {
|
|
32153
|
+
errors: [
|
|
32154
|
+
{
|
|
32155
|
+
kind: "parse",
|
|
32156
|
+
message: "The Beatport page carried no tracks facet (a missing label or a layout change)",
|
|
32157
|
+
request: tracksUrl
|
|
32158
|
+
}
|
|
32159
|
+
],
|
|
32160
|
+
status: "error"
|
|
32161
|
+
};
|
|
32162
|
+
}
|
|
32163
|
+
return { cached, data: { ...facts, labelUrl, tracksUrl }, status: "ok" };
|
|
32164
|
+
} catch (error) {
|
|
32165
|
+
return { errors: [failureOf2(error, tracksUrl)], status: "error" };
|
|
32166
|
+
}
|
|
32167
|
+
}
|
|
32168
|
+
async function gatherApple2(deps, mb) {
|
|
32169
|
+
if (!mb.releases) {
|
|
32170
|
+
return {
|
|
32171
|
+
note: "MusicBrainz releases unavailable, so no barcodes to look up",
|
|
32172
|
+
status: "skipped"
|
|
32173
|
+
};
|
|
32174
|
+
}
|
|
32175
|
+
const seen = new Set;
|
|
32176
|
+
const targets = mb.releases.releases.filter((release) => {
|
|
32177
|
+
if (!release.barcode || seen.has(release.barcode)) {
|
|
32178
|
+
return false;
|
|
32179
|
+
}
|
|
32180
|
+
seen.add(release.barcode);
|
|
32181
|
+
return true;
|
|
32182
|
+
});
|
|
32183
|
+
if (targets.length === 0) {
|
|
32184
|
+
return { note: "No sampled MusicBrainz release carries a barcode.", status: "no_link" };
|
|
32185
|
+
}
|
|
32186
|
+
const releases = [];
|
|
32187
|
+
const errors = [];
|
|
32188
|
+
let allCached = true;
|
|
32189
|
+
for (const target of targets.slice(0, APPLE_LOOKUPS2)) {
|
|
32190
|
+
const barcode = target.barcode ?? "";
|
|
32191
|
+
const url = `https://itunes.apple.com/lookup?upc=${encodeURIComponent(barcode)}&entity=album`;
|
|
32192
|
+
try {
|
|
32193
|
+
const { cached, data } = await fetchEvidenceJson(deps.http, "apple", url);
|
|
32194
|
+
allCached &&= cached;
|
|
32195
|
+
const hit = (data.results ?? []).find((result) => result.wrapperType === "collection");
|
|
32196
|
+
releases.push(hit ? {
|
|
32197
|
+
artistName: hit.artistName,
|
|
32198
|
+
barcode,
|
|
32199
|
+
collectionName: hit.collectionName,
|
|
32200
|
+
copyright: hit.copyright,
|
|
32201
|
+
found: true,
|
|
32202
|
+
mbTitle: target.title,
|
|
32203
|
+
primaryGenreName: hit.primaryGenreName
|
|
32204
|
+
} : { barcode, found: false, mbTitle: target.title });
|
|
32205
|
+
} catch (error) {
|
|
32206
|
+
errors.push(failureOf2(error, url));
|
|
32207
|
+
}
|
|
32208
|
+
}
|
|
32209
|
+
const looked = Math.min(targets.length, APPLE_LOOKUPS2);
|
|
32210
|
+
return {
|
|
32211
|
+
cached: allCached,
|
|
32212
|
+
data: {
|
|
32213
|
+
found: releases.filter((release) => release.found).length,
|
|
32214
|
+
genres: tally2(releases.flatMap((release) => release.primaryGenreName ?? [])),
|
|
32215
|
+
looked,
|
|
32216
|
+
releases
|
|
32217
|
+
},
|
|
32218
|
+
...errors.length > 0 ? { errors } : {},
|
|
32219
|
+
status: statusFrom2(looked, errors.length)
|
|
32220
|
+
};
|
|
32221
|
+
}
|
|
32222
|
+
function skipped2() {
|
|
32223
|
+
return { note: "Not requested (--sources).", status: "skipped" };
|
|
32224
|
+
}
|
|
32225
|
+
async function resolveTarget2(input, deps) {
|
|
32226
|
+
const trimmed = input.trim();
|
|
32227
|
+
if (MBID_PATTERN4.test(trimmed)) {
|
|
32228
|
+
return { input: trimmed, mbLabelId: trimmed.toLowerCase() };
|
|
32229
|
+
}
|
|
32230
|
+
const label = await deps.resolveLabel(trimmed);
|
|
32231
|
+
if (!label.mbLabelId) {
|
|
32232
|
+
throw new Error(`Label '${label.slug}' has no MusicBrainz identity (mb_label_id), so nothing says which same-named label to research. Resolve it by hand first (docs/label-entity.md).`);
|
|
32233
|
+
}
|
|
32234
|
+
return {
|
|
32235
|
+
id: label.id,
|
|
32236
|
+
input: trimmed,
|
|
32237
|
+
mbLabelId: label.mbLabelId.toLowerCase(),
|
|
32238
|
+
name: label.name,
|
|
32239
|
+
seedState: label.seedState,
|
|
32240
|
+
slug: label.slug
|
|
32241
|
+
};
|
|
32242
|
+
}
|
|
32243
|
+
async function gatherLabelEvidence2(input, options, deps) {
|
|
32244
|
+
const before = { cacheHits: deps.http.stats.cacheHits, network: deps.http.stats.requests };
|
|
32245
|
+
const label = await resolveTarget2(input, deps);
|
|
32246
|
+
const wants = (source) => options.sources.includes(source);
|
|
32247
|
+
const needsMb = wants("musicbrainz") || wants("discogs") || wants("beatport") || wants("apple");
|
|
32248
|
+
const musicbrainz = needsMb ? await gatherMusicBrainz2(deps, label.mbLabelId, options) : skipped2();
|
|
32249
|
+
const mb = musicbrainz.data ?? {};
|
|
32250
|
+
const [discogs, beatport, apple] = await Promise.all([
|
|
32251
|
+
wants("discogs") ? gatherDiscogs2(deps, mb) : Promise.resolve(skipped2()),
|
|
32252
|
+
wants("beatport") ? gatherBeatport2(deps, mb) : Promise.resolve(skipped2()),
|
|
32253
|
+
wants("apple") ? gatherApple2(deps, mb) : Promise.resolve(skipped2())
|
|
32254
|
+
]);
|
|
32255
|
+
const sources = { apple, beatport, discogs, musicbrainz };
|
|
32256
|
+
const reports = Object.entries(sources);
|
|
32257
|
+
const errors = reports.flatMap(([source, report]) => (report.errors ?? []).map((failure) => ({ ...failure, source })));
|
|
32258
|
+
const requested = reports.filter(([source]) => wants(source));
|
|
32259
|
+
const answered = requested.filter(([, report]) => ["no_link", "ok", "partial"].includes(report.status));
|
|
32260
|
+
return {
|
|
32261
|
+
errors,
|
|
32262
|
+
fetchedAt: new Date(deps.http.now()).toISOString(),
|
|
32263
|
+
label: { ...label, name: label.name ?? mb.label?.name },
|
|
32264
|
+
ok: answered.length > 0,
|
|
32265
|
+
partial: answered.length < requested.length || errors.length > 0,
|
|
32266
|
+
requests: {
|
|
32267
|
+
cacheHits: deps.http.stats.cacheHits - before.cacheHits,
|
|
32268
|
+
network: deps.http.stats.requests - before.network
|
|
32269
|
+
},
|
|
32270
|
+
sources
|
|
32271
|
+
};
|
|
32272
|
+
}
|
|
32273
|
+
function firecrawlApiScraper2(apiKey, http) {
|
|
32274
|
+
return async (url, signal) => {
|
|
32275
|
+
const response = await http.fetch(FIRECRAWL_SCRAPE_URL2, {
|
|
32276
|
+
body: JSON.stringify({ formats: ["rawHtml"], url }),
|
|
32277
|
+
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
32278
|
+
method: "POST",
|
|
32279
|
+
signal
|
|
32280
|
+
});
|
|
32281
|
+
if (!response.ok) {
|
|
32282
|
+
return { headers: response.headers, status: response.status, text: await response.text() };
|
|
32283
|
+
}
|
|
32284
|
+
const payload = await response.json();
|
|
32285
|
+
return {
|
|
32286
|
+
headers: response.headers,
|
|
32287
|
+
status: payload.data?.metadata?.statusCode ?? 200,
|
|
32288
|
+
text: payload.data?.rawHtml ?? ""
|
|
32289
|
+
};
|
|
32290
|
+
};
|
|
32291
|
+
}
|
|
32292
|
+
function firecrawlCliScraper2(binary) {
|
|
32293
|
+
return (url, signal) => new Promise((resolve, reject) => {
|
|
32294
|
+
const child = spawn2(binary, ["scrape", "-f", "rawHtml", url], {
|
|
32295
|
+
signal,
|
|
32296
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
32297
|
+
});
|
|
32298
|
+
const out = [];
|
|
32299
|
+
const err = [];
|
|
32300
|
+
child.stdout.on("data", (chunk) => out.push(chunk));
|
|
32301
|
+
child.stderr.on("data", (chunk) => err.push(chunk));
|
|
32302
|
+
child.on("error", reject);
|
|
32303
|
+
child.on("close", (code) => {
|
|
32304
|
+
if (code === 0) {
|
|
32305
|
+
resolve({
|
|
32306
|
+
headers: { get: () => null },
|
|
32307
|
+
status: 200,
|
|
32308
|
+
text: Buffer.concat(out).toString("utf8")
|
|
32309
|
+
});
|
|
32310
|
+
return;
|
|
32311
|
+
}
|
|
32312
|
+
const tail = Buffer.concat(err).toString("utf8").trim().split(`
|
|
32313
|
+
`).slice(-2).join(" ");
|
|
32314
|
+
reject(new Error(`firecrawl CLI exited ${code}: ${tail}`));
|
|
32315
|
+
});
|
|
32316
|
+
});
|
|
32317
|
+
}
|
|
32318
|
+
function defaultBeatportScraper2(env, http) {
|
|
32319
|
+
if (env.firecrawlApiKey) {
|
|
32320
|
+
return firecrawlApiScraper2(env.firecrawlApiKey, http);
|
|
32321
|
+
}
|
|
32322
|
+
return env.firecrawlBinary ? firecrawlCliScraper2(env.firecrawlBinary) : null;
|
|
32323
|
+
}
|
|
32324
|
+
async function createLabelEvidenceDeps2(refresh) {
|
|
32325
|
+
const [{ readOptionalEnv }, { resolveLabel }] = await Promise.all([
|
|
32326
|
+
Promise.resolve().then(() => (init_env(), exports_env)),
|
|
32327
|
+
Promise.resolve().then(() => (init_admin_labels3(), exports_admin_labels))
|
|
32328
|
+
]);
|
|
32329
|
+
const http = createEvidenceHttp({ deadline: deadlineAt(), refresh });
|
|
32330
|
+
const discogsToken = readOptionalEnv("DISCOGS_USER_TOKEN");
|
|
32331
|
+
if (discogsToken) {
|
|
32332
|
+
http.policies = { ...http.policies, discogs: { ...http.policies.discogs, intervalMs: 1100 } };
|
|
32333
|
+
}
|
|
32334
|
+
return {
|
|
32335
|
+
discogsToken,
|
|
32336
|
+
http,
|
|
32337
|
+
resolveLabel,
|
|
32338
|
+
scraper: defaultBeatportScraper2({
|
|
32339
|
+
firecrawlApiKey: readOptionalEnv("FIRECRAWL_API_KEY"),
|
|
32340
|
+
firecrawlBinary: Bun.which("firecrawl")
|
|
32341
|
+
}, http)
|
|
32342
|
+
};
|
|
32343
|
+
}
|
|
32344
|
+
function countLine2(counts, limit) {
|
|
32345
|
+
return counts.slice(0, limit).map((entry) => `${entry.name} ${entry.count}`).join(", ");
|
|
32346
|
+
}
|
|
32347
|
+
function musicbrainzDetailLines2(mb) {
|
|
32348
|
+
const lines = [];
|
|
32349
|
+
if (mb?.label?.labelRelations.length) {
|
|
32350
|
+
lines.push(` label relations: ${mb.label.labelRelations.map((relation) => `${relation.type}: ${relation.name} (${relation.mbid})`).join("; ")}`);
|
|
32351
|
+
}
|
|
32352
|
+
if (mb?.census) {
|
|
32353
|
+
lines.push(` first credits: ${mb.census.firstCredits.map((credit) => `${credit.artistName} (${credit.artistMbid}) ${credit.recordings}`).join("; ")}; uncredited ${mb.census.uncreditedRecordings}`);
|
|
32354
|
+
}
|
|
32355
|
+
for (const release of mb?.releases?.releases ?? []) {
|
|
32356
|
+
lines.push(` release: ${release.artist} — ${release.title}; catno ${release.catno ?? "none"}; ${release.date ?? "undated"}; format ${release.format ?? "unknown"}; status ${release.status ?? "unknown"}; barcode ${release.barcode ?? "none"}`);
|
|
32357
|
+
}
|
|
32358
|
+
return lines;
|
|
32359
|
+
}
|
|
32360
|
+
function discogsDetailLines2(discogs) {
|
|
32361
|
+
const lines = [];
|
|
32362
|
+
if (discogs?.label) {
|
|
32363
|
+
lines.push(` profile: ${discogs.label.profile || "none"}`);
|
|
32364
|
+
lines.push(` parent: ${discogs.label.parentLabel ? `${discogs.label.parentLabel.name} (${discogs.label.parentLabel.id})` : "none"}; sublabels: ${discogs.label.sublabels.join(", ") || "none"}`);
|
|
32365
|
+
}
|
|
32366
|
+
if (discogs?.releases) {
|
|
32367
|
+
lines.push(` ${discogs.releases.releaseCount} releases; top artists: ${discogs.releases.topArtists.map((artist) => `${artist.name} ${artist.releases}`).join(", ") || "none"}`);
|
|
32368
|
+
for (const release of discogs.releases.sample) {
|
|
32369
|
+
lines.push(` release: ${release.artist} — ${release.title}; catno ${release.catno ?? "none"}; year ${release.year ?? "unknown"}; format ${release.format ?? "unknown"}`);
|
|
32370
|
+
}
|
|
32371
|
+
}
|
|
32372
|
+
if (discogs?.styles) {
|
|
32373
|
+
lines.push(` genres: ${countLine2(discogs.styles.genres, discogs.styles.genres.length) || "none"}`);
|
|
32374
|
+
lines.push(` all styles: ${countLine2(discogs.styles.styles, discogs.styles.styles.length) || "none"}`);
|
|
32375
|
+
}
|
|
32376
|
+
return lines;
|
|
32377
|
+
}
|
|
32378
|
+
function beatportDetailLines2(beatport) {
|
|
32379
|
+
const lines = [];
|
|
32380
|
+
if (beatport) {
|
|
32381
|
+
lines.push(` subgenres: ${countLine2(beatport.subGenres, beatport.subGenres.length) || "none"}`);
|
|
32382
|
+
lines.push(` top artists: ${countLine2(beatport.topArtists, beatport.topArtists.length) || "none"}`);
|
|
32383
|
+
}
|
|
32384
|
+
return lines;
|
|
32385
|
+
}
|
|
32386
|
+
function appleDetailLines2(apple) {
|
|
32387
|
+
const lines = [];
|
|
32388
|
+
for (const release of apple?.releases ?? []) {
|
|
32389
|
+
lines.push(release.found ? ` Apple match: ${release.mbTitle}; barcode ${release.barcode}; genre ${release.primaryGenreName ?? "unknown"}; artist ${release.artistName ?? "unknown"}; title ${release.collectionName ?? "unknown"}; copyright ${release.copyright ?? "unknown"}` : ` Apple unmatched: ${release.mbTitle}; barcode ${release.barcode}`);
|
|
32390
|
+
}
|
|
32391
|
+
return lines;
|
|
32392
|
+
}
|
|
32393
|
+
function labelEvidenceLines2(evidence) {
|
|
32394
|
+
const { apple, beatport, discogs, musicbrainz } = evidence.sources;
|
|
32395
|
+
const mb = musicbrainz.data;
|
|
32396
|
+
const name = evidence.label.name ?? evidence.label.mbLabelId;
|
|
32397
|
+
const lines = [`${name} (${evidence.label.mbLabelId})`];
|
|
32398
|
+
const mbParts = [];
|
|
32399
|
+
if (mb?.label) {
|
|
32400
|
+
mbParts.push([mb.label.type, mb.label.area, mb.label.lifeSpan.begin].filter(Boolean).join(", "));
|
|
32401
|
+
}
|
|
32402
|
+
if (mb?.releases) {
|
|
32403
|
+
const top = mb.releases.firstCreditArtists.slice(0, FIRST_CREDIT_ARTISTS2).map((artist) => `${artist.name} ${artist.releases}`).join(", ");
|
|
32404
|
+
mbParts.push(`${mb.releases.releaseCount} releases; first credits: ${top || "none"}`);
|
|
32405
|
+
}
|
|
32406
|
+
if (mb?.census) {
|
|
32407
|
+
mbParts.push(`census ${mb.census.recordingsCounted} recordings over ${mb.census.releasesRead} releases${mb.census.caveat ? ` (${mb.census.caveat})` : ""}`);
|
|
32408
|
+
}
|
|
32409
|
+
lines.push(` musicbrainz: ${musicbrainz.status}${mbParts.length ? ` — ${mbParts.join("; ")}` : ""}`);
|
|
32410
|
+
lines.push(...musicbrainzDetailLines2(mb));
|
|
32411
|
+
const dg = discogs.data;
|
|
32412
|
+
const dgDetail = dg?.styles ? `styles: ${countLine2(dg.styles.styles, 6)} (${dg.styles.releasesRead} releases)` : dg?.candidates ? `unverified candidates: ${dg.candidates.map((c) => c.title).join(", ") || "none"}` : discogs.note;
|
|
32413
|
+
lines.push(` discogs: ${discogs.status}${dgDetail ? ` — ${dgDetail}` : ""}`);
|
|
32414
|
+
lines.push(...discogsDetailLines2(dg));
|
|
32415
|
+
const bp = beatport.data;
|
|
32416
|
+
const bpDetail = bp ? `${bp.trackCount} tracks; genres: ${bp.genres.slice(0, 5).map((genre) => `${genre.name} ${Math.round(genre.share * 100)}%`).join(", ")}` : beatport.note;
|
|
32417
|
+
lines.push(` beatport: ${beatport.status}${bpDetail ? ` — ${bpDetail}` : ""}`);
|
|
32418
|
+
lines.push(...beatportDetailLines2(bp));
|
|
32419
|
+
const ap = apple.data;
|
|
32420
|
+
const apDetail = ap ? `${ap.found}/${ap.looked} found; genres: ${countLine2(ap.genres, 4) || "none"}` : apple.note;
|
|
32421
|
+
lines.push(` apple: ${apple.status}${apDetail ? ` — ${apDetail}` : ""}`);
|
|
32422
|
+
lines.push(...appleDetailLines2(ap));
|
|
32423
|
+
for (const failure of evidence.errors) {
|
|
32424
|
+
lines.push(` ! ${failure.source}: ${failure.message}`);
|
|
32425
|
+
}
|
|
32426
|
+
return lines;
|
|
32427
|
+
}
|
|
32428
|
+
var MBID_PATTERN4, MB_ROOT2 = "https://musicbrainz.org/ws/2", DISCOGS_ROOT2 = "https://api.discogs.com", FIRECRAWL_SCRAPE_URL2 = "https://api.firecrawl.dev/v2/scrape", VARIOUS_ARTISTS_MBID2 = "89ad4ac3-39f7-470e-963a-56509c546377", RELEASE_SAMPLE2 = 12, FIRST_CREDIT_ARTISTS2 = 25, APPLE_LOOKUPS2 = 5, DISCOGS_RELEASE_SAMPLE2 = 8, DISCOGS_STYLE_TARGET2 = 10, DISCOGS_RELEASE_READS2 = 8, PROFILE_CHARS2 = 800, EVIDENCE_SOURCES2;
|
|
32429
|
+
var init_admin_label_evidence2 = __esm(() => {
|
|
32430
|
+
init_deadline();
|
|
32431
|
+
init_evidence_http();
|
|
32432
|
+
MBID_PATTERN4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
32433
|
+
EVIDENCE_SOURCES2 = ["musicbrainz", "discogs", "beatport", "apple"];
|
|
32434
|
+
});
|
|
32435
|
+
|
|
32436
|
+
// src/commands/admin-label-evidence-batch.ts
|
|
32437
|
+
import { appendFileSync, mkdirSync as mkdirSync2, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
32438
|
+
import { basename as basename2, dirname as dirname3, join as join7, resolve as resolve4 } from "node:path";
|
|
32439
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
32440
|
+
function atomicWrite(path, text) {
|
|
32441
|
+
const temporary = `${path}.${randomUUID3()}.tmp`;
|
|
32442
|
+
writeFileSync2(temporary, text, { mode: 384 });
|
|
32443
|
+
renameSync(temporary, path);
|
|
32444
|
+
}
|
|
32445
|
+
async function gatherLabelEvidenceBatch(inputs, options, deps) {
|
|
32446
|
+
const out = resolve4(options.out);
|
|
32447
|
+
const manifest = resolve4(options.manifest ?? join7(out, "manifest.jsonl"));
|
|
32448
|
+
mkdirSync2(out, { recursive: true });
|
|
32449
|
+
mkdirSync2(dirname3(manifest), { recursive: true });
|
|
32450
|
+
const runId = basename2(dirname3(manifest));
|
|
32451
|
+
const slice = out;
|
|
32452
|
+
const attempt = randomUUID3();
|
|
32453
|
+
const record = (event) => appendFileSync(manifest, `${JSON.stringify({ at: new Date().toISOString(), attempt, runId, slice, ...event })}
|
|
32454
|
+
`, { mode: 384 });
|
|
32455
|
+
const labels = [...new Set(inputs)];
|
|
32456
|
+
const lines = [];
|
|
32457
|
+
let ok = true;
|
|
32458
|
+
record({ labels, state: "started" });
|
|
32459
|
+
for (const input of labels) {
|
|
32460
|
+
record({ input, state: "pending" });
|
|
32461
|
+
}
|
|
32462
|
+
for (const input of labels) {
|
|
32463
|
+
let evidence;
|
|
32464
|
+
try {
|
|
32465
|
+
evidence = await gatherLabelEvidence2(input, options, deps);
|
|
32466
|
+
} catch (error) {
|
|
32467
|
+
ok = false;
|
|
32468
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
32469
|
+
const entry = {
|
|
32470
|
+
id: input,
|
|
32471
|
+
input,
|
|
32472
|
+
message,
|
|
32473
|
+
path: null,
|
|
32474
|
+
sources: Object.fromEntries(EVIDENCE_SOURCES2.map((source) => [source, "skipped"])),
|
|
32475
|
+
state: "failed"
|
|
32476
|
+
};
|
|
32477
|
+
record(entry);
|
|
32478
|
+
lines.push(`manifest ${JSON.stringify(entry)}`);
|
|
32479
|
+
continue;
|
|
32480
|
+
}
|
|
32481
|
+
const key = encodeURIComponent(evidence.label.mbLabelId);
|
|
32482
|
+
const path = join7(out, `${key}.json`);
|
|
32483
|
+
const summaryPath = join7(out, `${key}.txt`);
|
|
32484
|
+
const summary = labelEvidenceLines2(evidence);
|
|
32485
|
+
atomicWrite(path, `${JSON.stringify(evidence, null, 2)}
|
|
32486
|
+
`);
|
|
32487
|
+
atomicWrite(summaryPath, `${summary.join(`
|
|
32488
|
+
`)}
|
|
32489
|
+
`);
|
|
32490
|
+
const entry = {
|
|
32491
|
+
id: evidence.label.mbLabelId,
|
|
32492
|
+
input,
|
|
32493
|
+
path,
|
|
32494
|
+
sources: Object.fromEntries(Object.entries(evidence.sources).map(([name, source]) => [name, source.status])),
|
|
32495
|
+
state: evidence.ok ? "ready" : "failed",
|
|
32496
|
+
summaryPath
|
|
32497
|
+
};
|
|
32498
|
+
record(entry);
|
|
32499
|
+
lines.push(...summary, `manifest ${JSON.stringify(entry)}`);
|
|
32500
|
+
ok &&= evidence.ok;
|
|
32501
|
+
}
|
|
32502
|
+
record({ labels, ok, state: "completed" });
|
|
32503
|
+
lines.push(`round manifest: ${manifest}`);
|
|
32504
|
+
return { lines, ok };
|
|
32505
|
+
}
|
|
32506
|
+
async function labelEvidenceBatchCommand(inputs, options) {
|
|
32507
|
+
return gatherLabelEvidenceBatch(inputs, options, await createLabelEvidenceDeps2(options.refresh));
|
|
32508
|
+
}
|
|
32509
|
+
var init_admin_label_evidence_batch = __esm(() => {
|
|
32510
|
+
init_admin_label_evidence2();
|
|
32511
|
+
});
|
|
32512
|
+
|
|
31594
32513
|
// src/commands/admin-albums.ts
|
|
31595
32514
|
async function describeAlbumCommand(slug, options) {
|
|
31596
32515
|
return adminApiPost(`/api/v1/admin/albums/${encodeURIComponent(slug)}/bio`, buildBioBody2(options));
|
|
@@ -35601,15 +36520,36 @@ JSON field reference:
|
|
|
35601
36520
|
console.log(`${label.slug} ${label.seedState} ${looked ?? ""}${rules}`.trimEnd());
|
|
35602
36521
|
}
|
|
35603
36522
|
});
|
|
35604
|
-
labels.command("evidence").description("Gather a label's MusicBrainz, Discogs, Beatport and Apple evidence for triage (cached, rate-limited)").argument("<
|
|
36523
|
+
labels.command("evidence").description("Gather a label's MusicBrainz, Discogs, Beatport and Apple evidence for triage (cached, rate-limited)").argument("<labels...>", "MusicBrainz MBIDs, slugs, or lbl_\u2026 ids (several require --out)").option("--census", "Also count FIRST credits per recording over the label's releases", false).option("--census-pages <n>", "MusicBrainz pages the census may read, 1-5", "5").option("--sources <list>", "Comma list of musicbrainz,discogs,beatport,apple (default all)").option("--refresh", "Ignore cached responses and fetch fresh", false).option("--out <directory>", "Write each label JSON and summary atomically; print summaries").option("--manifest <file>", "Append slice states to a shared round JSONL manifest").option("--json", "Print JSON (single label without --out)", false).action(async (inputs, options) => {
|
|
35605
36524
|
await Promise.resolve().then(() => init_admin_label_evidence());
|
|
35606
36525
|
const censusPages = parseCensusPages(options.censusPages);
|
|
35607
|
-
const
|
|
36526
|
+
const evidenceOptions = {
|
|
35608
36527
|
census: options.census,
|
|
35609
36528
|
censusPages,
|
|
35610
36529
|
refresh: options.refresh,
|
|
35611
36530
|
sources: parseEvidenceSources(options.sources)
|
|
35612
|
-
}
|
|
36531
|
+
};
|
|
36532
|
+
if (options.out) {
|
|
36533
|
+
if (options.json) {
|
|
36534
|
+
throw new Error("Use --out for batch summaries and saved JSON; omit --json");
|
|
36535
|
+
}
|
|
36536
|
+
await Promise.resolve().then(() => init_admin_label_evidence_batch());
|
|
36537
|
+
const result = await labelEvidenceBatchCommand(inputs, {
|
|
36538
|
+
...evidenceOptions,
|
|
36539
|
+
manifest: options.manifest,
|
|
36540
|
+
out: options.out
|
|
36541
|
+
});
|
|
36542
|
+
if (!result.ok) {
|
|
36543
|
+
process.exitCode = 1;
|
|
36544
|
+
}
|
|
36545
|
+
console.log(result.lines.join(`
|
|
36546
|
+
`));
|
|
36547
|
+
return;
|
|
36548
|
+
}
|
|
36549
|
+
if (inputs.length !== 1 || options.manifest) {
|
|
36550
|
+
throw new Error("Several labels or --manifest require --out <directory>");
|
|
36551
|
+
}
|
|
36552
|
+
const evidence = await labelEvidenceCommand(inputs[0] ?? "", evidenceOptions);
|
|
35613
36553
|
if (!evidence.ok) {
|
|
35614
36554
|
process.exitCode = 1;
|
|
35615
36555
|
}
|
|
@@ -38596,6 +39536,8 @@ function normalizeCommanderError(error) {
|
|
|
38596
39536
|
return new Error(message);
|
|
38597
39537
|
}
|
|
38598
39538
|
var stringOptions = new Set([
|
|
39539
|
+
"--manifest",
|
|
39540
|
+
"--out",
|
|
38599
39541
|
"--timeout",
|
|
38600
39542
|
"--isrc-refresh-limit",
|
|
38601
39543
|
"--action",
|
package/package.json
CHANGED