@koda-sl/baker-cli 0.200.0-dev.0a9adf6f7 → 0.201.0-dev.0a9adf6f7
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/dist/cli.js
CHANGED
|
@@ -51,8 +51,9 @@ import {
|
|
|
51
51
|
supportsReferenceToVideo,
|
|
52
52
|
toModelSafeImage,
|
|
53
53
|
ulid,
|
|
54
|
-
validateCanvasDeep
|
|
55
|
-
|
|
54
|
+
validateCanvasDeep,
|
|
55
|
+
ytDlpBlockSignal
|
|
56
|
+
} from "./chunk-CAWFJ5X3.js";
|
|
56
57
|
import {
|
|
57
58
|
csvOrJson,
|
|
58
59
|
daysAgoIso,
|
|
@@ -42480,6 +42481,10 @@ function isToolingOrBlockFailure(detail) {
|
|
|
42480
42481
|
const haystack = detail.toLowerCase();
|
|
42481
42482
|
return TOOLING_OR_BLOCK_SIGNATURES.some((signature) => haystack.includes(signature));
|
|
42482
42483
|
}
|
|
42484
|
+
var NOT_ABOUT_THE_URL = ["UNAUTHORIZED", "FORBIDDEN", "RATE_LIMITED", "INTERNAL", "VALIDATION_ERROR", "NOT_FOUND"];
|
|
42485
|
+
function worthDownloadingInstead(errorCode) {
|
|
42486
|
+
return !NOT_ABOUT_THE_URL.includes(errorCode);
|
|
42487
|
+
}
|
|
42483
42488
|
function safePathname(rawUrl) {
|
|
42484
42489
|
try {
|
|
42485
42490
|
return new URL(rawUrl).pathname.toLowerCase();
|
|
@@ -42541,6 +42546,18 @@ async function runVideoIngest(opts) {
|
|
|
42541
42546
|
externalId: opts.externalId,
|
|
42542
42547
|
externalUrl: opts.externalUrl ?? (direct ? void 0 : url)
|
|
42543
42548
|
};
|
|
42549
|
+
const validation = videosIngestRequestSchema.safeParse({ ...args, url });
|
|
42550
|
+
if (!validation.success) {
|
|
42551
|
+
const problem = validation.error.issues[0];
|
|
42552
|
+
writeJson({
|
|
42553
|
+
ok: false,
|
|
42554
|
+
error: {
|
|
42555
|
+
code: "VALIDATION_ERROR",
|
|
42556
|
+
message: problem ? `${problem.path.join(".") || "request"}: ${problem.message}` : "Invalid request"
|
|
42557
|
+
}
|
|
42558
|
+
});
|
|
42559
|
+
process.exit(1);
|
|
42560
|
+
}
|
|
42544
42561
|
if (opts.dryRun) {
|
|
42545
42562
|
writeJson({
|
|
42546
42563
|
ok: true,
|
|
@@ -42569,7 +42586,7 @@ async function ingestByRoute(args, direct) {
|
|
|
42569
42586
|
try {
|
|
42570
42587
|
return { ...await ingestUrl(args), via: "direct" };
|
|
42571
42588
|
} catch (err) {
|
|
42572
|
-
if (!(err instanceof ApiError)) throw err;
|
|
42589
|
+
if (!(err instanceof ApiError) || !worthDownloadingInstead(err.code)) throw err;
|
|
42573
42590
|
return { ...await downloadThenIngest(args), via: "download", fallbackFrom: err.message };
|
|
42574
42591
|
}
|
|
42575
42592
|
}
|
|
@@ -42579,7 +42596,19 @@ function reportIngestFailure(err) {
|
|
|
42579
42596
|
process.exit(1);
|
|
42580
42597
|
}
|
|
42581
42598
|
if (err instanceof YtDlpError) {
|
|
42582
|
-
const
|
|
42599
|
+
const detail = `${err.stderrTail} ${err.message}`;
|
|
42600
|
+
if (isProxyFailure(ytDlpBlockSignal(detail))) {
|
|
42601
|
+
writeJson({
|
|
42602
|
+
ok: false,
|
|
42603
|
+
error: {
|
|
42604
|
+
code: "INGEST_FAILED",
|
|
42605
|
+
message: "Couldn't download that video: our connection to the internet was refused.",
|
|
42606
|
+
fix: "This is Baker's egress proxy, not the link \u2014 its credentials look wrong or expired. The link is probably fine. Report it; retrying won't help until the proxy is fixed."
|
|
42607
|
+
}
|
|
42608
|
+
});
|
|
42609
|
+
process.exit(1);
|
|
42610
|
+
}
|
|
42611
|
+
const toolingOrBlock = isToolingOrBlockFailure(detail);
|
|
42583
42612
|
writeJson({
|
|
42584
42613
|
ok: false,
|
|
42585
42614
|
error: {
|
|
@@ -42605,7 +42634,7 @@ function ingestUrl(args) {
|
|
|
42605
42634
|
async function downloadThenIngest(args) {
|
|
42606
42635
|
const workDir = await mkdtemp2(path35.join(tmpdir3(), "videos-ingest-"));
|
|
42607
42636
|
try {
|
|
42608
|
-
const { filePath, info } = await runYtDlp({
|
|
42637
|
+
const { filePath, info, tier } = await runYtDlp({
|
|
42609
42638
|
url: args.url,
|
|
42610
42639
|
audioOnly: false,
|
|
42611
42640
|
workDir,
|
|
@@ -42621,7 +42650,10 @@ async function downloadThenIngest(args) {
|
|
|
42621
42650
|
const bytes = await readFile24(filePath);
|
|
42622
42651
|
const publicUrl = await uploadToAssetStore(bytes);
|
|
42623
42652
|
const externalId = args.externalId ?? (typeof info.id === "string" ? `${args.source}:${info.id}` : void 0);
|
|
42624
|
-
return
|
|
42653
|
+
return {
|
|
42654
|
+
...await ingestUrl({ ...args, url: publicUrl, externalId, externalUrl: args.externalUrl ?? args.url }),
|
|
42655
|
+
egress: tier
|
|
42656
|
+
};
|
|
42625
42657
|
} finally {
|
|
42626
42658
|
await rm7(workDir, { recursive: true, force: true }).catch(() => {
|
|
42627
42659
|
});
|