update TIDB to v2

This commit is contained in:
Pas 2026-02-20 20:36:19 -07:00
parent 752e8cadb1
commit 10d82dcde1

View file

@ -10,7 +10,7 @@ import { usePreferencesStore } from "@/stores/preferences";
import { getTurnstileToken } from "@/utils/turnstile"; import { getTurnstileToken } from "@/utils/turnstile";
// Thanks Nemo for this API // Thanks Nemo for this API
const THE_INTRO_DB_BASE_URL = "https://api.theintrodb.org/v1"; const THE_INTRO_DB_BASE_URL = "https://api.theintrodb.org/v2";
const FED_SKIPS_BASE_URL = "https://fed-skips.pstream.mov"; const FED_SKIPS_BASE_URL = "https://fed-skips.pstream.mov";
const INTRODB_BASE_URL = "https://api.introdb.app/intro"; const INTRODB_BASE_URL = "https://api.introdb.app/intro";
const MAX_RETRIES = 3; const MAX_RETRIES = 3;
@ -84,49 +84,65 @@ export function useSkipTime() {
const fetchedSegments: SegmentData[] = []; const fetchedSegments: SegmentData[] = [];
// Add intro segment if it has data // Process intro segments (v2: array of segments)
if (data?.intro && data.intro.submission_count > 0) { if (Array.isArray(data?.intro) && data.intro.length > 0) {
for (const segment of data.intro) {
if (segment.submission_count > 0) {
fetchedSegments.push({ fetchedSegments.push({
type: "intro", type: "intro",
start_ms: data.intro.start_ms, start_ms: segment.start_ms,
end_ms: data.intro.end_ms, end_ms: segment.end_ms,
confidence: data.intro.confidence, confidence: segment.confidence,
submission_count: data.intro.submission_count, submission_count: segment.submission_count,
}); });
} }
}
}
// Add recap segment if it has data // Process recap segments (v2: array of segments)
if (data?.recap && data.recap.submission_count > 0) { if (Array.isArray(data?.recap) && data.recap.length > 0) {
for (const segment of data.recap) {
if (segment.submission_count > 0) {
fetchedSegments.push({ fetchedSegments.push({
type: "recap", type: "recap",
start_ms: data.recap.start_ms, start_ms: segment.start_ms,
end_ms: data.recap.end_ms, end_ms: segment.end_ms,
confidence: data.recap.confidence, confidence: segment.confidence,
submission_count: data.recap.submission_count, submission_count: segment.submission_count,
}); });
} }
}
}
// Add credits segment if it has data // Process credits segments (v2: array of segments)
if (data?.credits && data.credits.submission_count > 0) { if (Array.isArray(data?.credits) && data.credits.length > 0) {
for (const segment of data.credits) {
if (segment.submission_count > 0) {
fetchedSegments.push({ fetchedSegments.push({
type: "credits", type: "credits",
start_ms: data.credits.start_ms, start_ms: segment.start_ms,
end_ms: data.credits.end_ms, end_ms: segment.end_ms,
confidence: data.credits.confidence, confidence: segment.confidence,
submission_count: data.credits.submission_count, submission_count: segment.submission_count,
}); });
} }
}
}
// Add preview segment if it has data // Process preview segments (v2: array of segments)
if (data?.preview && data.preview.submission_count > 0) { if (Array.isArray(data?.preview) && data.preview.length > 0) {
for (const segment of data.preview) {
if (segment.submission_count > 0) {
fetchedSegments.push({ fetchedSegments.push({
type: "preview", type: "preview",
start_ms: data.preview.start_ms, start_ms: segment.start_ms,
end_ms: data.preview.end_ms, end_ms: segment.end_ms,
confidence: data.preview.confidence, confidence: segment.confidence,
submission_count: data.preview.submission_count, submission_count: segment.submission_count,
}); });
} }
}
}
// TIDB returned 200 we have segment data for this media (even if no intro) // TIDB returned 200 we have segment data for this media (even if no intro)
return { segments: fetchedSegments, tidbNotFound: false }; return { segments: fetchedSegments, tidbNotFound: false };