feat: display url when --no-progress
parent
a0bf4c53f5
commit
2ae890866c
22
src/app.ts
22
src/app.ts
|
|
@ -247,6 +247,7 @@ class GameFetcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Progress = {
|
type Progress = {
|
||||||
|
currentUrl?: string;
|
||||||
current: number;
|
current: number;
|
||||||
total: number;
|
total: number;
|
||||||
};
|
};
|
||||||
|
|
@ -340,13 +341,17 @@ export class App {
|
||||||
const allProgress: Record<string, Progress> = {};
|
const allProgress: Record<string, Progress> = {};
|
||||||
const redraw = (name: string, progress: Progress) => {
|
const redraw = (name: string, progress: Progress) => {
|
||||||
allProgress[name] = progress;
|
allProgress[name] = progress;
|
||||||
bar?.render(
|
if (bar) {
|
||||||
Object.entries(allProgress).map(([name, progress]) => ({
|
bar.render(
|
||||||
completed: progress.current,
|
Object.entries(allProgress).map(([name, progress]) => ({
|
||||||
total: progress.total,
|
completed: progress.current,
|
||||||
text: name,
|
total: progress.total,
|
||||||
})),
|
text: name,
|
||||||
);
|
})),
|
||||||
|
);
|
||||||
|
} else if (progress.currentUrl) {
|
||||||
|
console.log(`Battle uploaded to ${progress.currentUrl}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const endBar = () => {
|
const endBar = () => {
|
||||||
bar?.end();
|
bar?.end();
|
||||||
|
|
@ -554,9 +559,10 @@ export class App {
|
||||||
|
|
||||||
const step = async (id: string) => {
|
const step = async (id: string) => {
|
||||||
const detail = await fetcher.fetch(type, id);
|
const detail = await fetcher.fetch(type, id);
|
||||||
await exporter.exportGame(detail);
|
const { url } = await exporter.exportGame(detail);
|
||||||
exported += 1;
|
exported += 1;
|
||||||
onStep?.({
|
onStep?.({
|
||||||
|
currentUrl: url,
|
||||||
current: exported,
|
current: exported,
|
||||||
total: workQueue.length,
|
total: workQueue.length,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import type { StatInkPostBody, VsHistoryDetail } from "./types.ts";
|
import type { StatInkPostBody, VsHistoryDetail } from "./types.ts";
|
||||||
|
|
||||||
export const AGENT_NAME = "s3si.ts";
|
export const AGENT_NAME = "s3si.ts";
|
||||||
export const S3SI_VERSION = "0.1.11";
|
export const S3SI_VERSION = "0.1.12";
|
||||||
export const NSOAPP_VERSION = "2.3.1";
|
export const NSOAPP_VERSION = "2.3.1";
|
||||||
export const WEB_VIEW_VERSION = "1.0.0-5644e7a2";
|
export const WEB_VIEW_VERSION = "1.0.0-5644e7a2";
|
||||||
export const S3SI_LINK = "https://github.com/spacemeowx2/s3si.ts";
|
export const S3SI_LINK = "https://github.com/spacemeowx2/s3si.ts";
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,10 @@ export class FileExporter implements GameExporter {
|
||||||
filepath,
|
filepath,
|
||||||
JSON.stringify(body, replacer),
|
JSON.stringify(body, replacer),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: filepath,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
async notExported({ list }: { list: string[] }): Promise<string[]> {
|
async notExported({ list }: { list: string[] }): Promise<string[]> {
|
||||||
const out: string[] = [];
|
const out: string[] = [];
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import {
|
||||||
GameExporter,
|
GameExporter,
|
||||||
StatInkPlayer,
|
StatInkPlayer,
|
||||||
StatInkPostBody,
|
StatInkPostBody,
|
||||||
|
StatInkPostResponse,
|
||||||
StatInkStage,
|
StatInkStage,
|
||||||
VsHistoryDetail,
|
VsHistoryDetail,
|
||||||
VsInfo,
|
VsInfo,
|
||||||
|
|
@ -58,7 +59,7 @@ export class StatInkExporter implements GameExporter {
|
||||||
async exportGame(game: VsInfo | CoopInfo) {
|
async exportGame(game: VsInfo | CoopInfo) {
|
||||||
if (game.type === "CoopInfo") {
|
if (game.type === "CoopInfo") {
|
||||||
// TODO: support coop
|
// TODO: support coop
|
||||||
return;
|
return {};
|
||||||
}
|
}
|
||||||
const body = await this.mapBattle(game);
|
const body = await this.mapBattle(game);
|
||||||
|
|
||||||
|
|
@ -71,9 +72,7 @@ export class StatInkExporter implements GameExporter {
|
||||||
body: msgpack.encode(body),
|
body: msgpack.encode(body),
|
||||||
});
|
});
|
||||||
|
|
||||||
const json: {
|
const json: StatInkPostResponse = await resp.json().catch(() => ({}));
|
||||||
error?: unknown;
|
|
||||||
} = await resp.json().catch(() => ({}));
|
|
||||||
|
|
||||||
if (resp.status !== 200 && resp.status !== 201) {
|
if (resp.status !== 200 && resp.status !== 201) {
|
||||||
throw new APIError({
|
throw new APIError({
|
||||||
|
|
@ -90,6 +89,10 @@ export class StatInkExporter implements GameExporter {
|
||||||
json,
|
json,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: json.url,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
async notExported({ list }: { list: string[] }): Promise<string[]> {
|
async notExported({ list }: { list: string[] }): Promise<string[]> {
|
||||||
const uuid = await (await fetch("https://stat.ink/api/v3/s3s/uuid-list", {
|
const uuid = await (await fetch("https://stat.ink/api/v3/s3s/uuid-list", {
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ export type GameExporter<
|
||||||
notExported: (
|
notExported: (
|
||||||
{ type, list }: { type: T["type"]; list: string[] },
|
{ type, list }: { type: T["type"]; list: string[] },
|
||||||
) => Promise<string[]>;
|
) => Promise<string[]>;
|
||||||
exportGame: (game: T) => Promise<void>;
|
exportGame: (game: T) => Promise<{ url?: string }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RespMap = {
|
export type RespMap = {
|
||||||
|
|
@ -323,3 +323,10 @@ export type StatInkPostBody = {
|
||||||
start_at: number; // the battle starts at e.g. 1599577200
|
start_at: number; // the battle starts at e.g. 1599577200
|
||||||
end_at: number;
|
end_at: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type StatInkPostResponse = {
|
||||||
|
error?: unknown;
|
||||||
|
} & {
|
||||||
|
id: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue