mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-22 04:46:07 -08:00
feat(stats): separate YouTube channels in the Library (#253)
This commit is contained in:
1 parent
76e43d7e6d
commit
8097ed27e5
35 files changed
+888
-81
No files matched your search
@@ -1,6 +1,9 @@
|
||||
import type { Hono } from 'hono';
|
||||
import { statsJson } from '../../../types/stats-http-contract.js';
|
||||
import { UNKNOWN_MOVE_TARGET_MESSAGE } from '../immersion-tracker/anime-merge.js';
|
||||
import {
|
||||
MEDIA_KIND_MISMATCH_MESSAGE,
|
||||
UNKNOWN_MOVE_TARGET_MESSAGE,
|
||||
} from '../immersion-tracker/anime-merge.js';
|
||||
import type { ImmersionTrackerService } from '../immersion-tracker-service.js';
|
||||
import {
|
||||
buildSentenceSearchOptions,
|
||||
@@ -245,7 +248,15 @@ export function registerStatsLibraryRoutes(
|
||||
const body = await c.req.json().catch(() => null);
|
||||
const sourceAnimeIds = parsePositiveIdList(body?.sourceAnimeIds).filter((id) => id !== animeId);
|
||||
if (sourceAnimeIds.length === 0) return c.body(null, 400);
|
||||
const summary = await tracker.mergeAnime(animeId, sourceAnimeIds);
|
||||
let summary: Awaited<ReturnType<typeof tracker.mergeAnime>>;
|
||||
try {
|
||||
summary = await tracker.mergeAnime(animeId, sourceAnimeIds);
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message === MEDIA_KIND_MISMATCH_MESSAGE) {
|
||||
return c.text(MEDIA_KIND_MISMATCH_MESSAGE, 409);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
// Nothing folded means the target or every source was already gone, so the
|
||||
// caller should not be told the merge succeeded.
|
||||
if (summary.mergedAnimeIds.length === 0) return c.body(null, 404);
|
||||
@@ -281,6 +292,9 @@ export function registerStatsLibraryRoutes(
|
||||
if (error instanceof Error && error.message === UNKNOWN_MOVE_TARGET_MESSAGE) {
|
||||
return c.body(null, 404);
|
||||
}
|
||||
if (error instanceof Error && error.message === MEDIA_KIND_MISMATCH_MESSAGE) {
|
||||
return c.text(MEDIA_KIND_MISMATCH_MESSAGE, 409);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user