chore: ignoring a lot of type checking from merging PR #55

This commit is contained in:
Emilien 2025-03-08 19:54:38 +01:00
parent bddb450d2c
commit f4d15314e4
2 changed files with 14 additions and 3 deletions

View file

@ -1,5 +1,6 @@
import { Innertube } from "youtubei.js";
// @ts-ignore to be fixed
function createTemporalDuration(milliseconds) {
return new Temporal.Duration(
undefined,
@ -25,6 +26,7 @@ const ESCAPE_SUBSTITUTIONS = {
export async function handleTranscripts(
innertubeClient: Innertube,
videoId: string,
// @ts-ignore to be fixed
selectedCaption,
) {
const lines: string[] = ["WEBVTT"];
@ -34,6 +36,7 @@ export async function handleTranscripts(
selectedCaption.name.simpleText,
);
const rawTranscriptLines =
// @ts-ignore to be fixed
transcriptInfo.transcript.content.body.initial_segments;
rawTranscriptLines.forEach((line) => {
@ -45,14 +48,18 @@ export async function handleTranscripts(
const start_ms = createTemporalDuration(line.start_ms).round({
largestUnit: "year",
// @ts-ignore to be fixed
}).toLocaleString(undefined, timestampFormatOptions);
const end_ms = createTemporalDuration(line.end_ms).round({
largestUnit: "year",
// @ts-ignore to be fixed
}).toLocaleString(undefined, timestampFormatOptions);
const timestamp = `${start_ms} --> ${end_ms}`;
// @ts-ignore to be fixed
const text = line.snippet.text.replace(
/[&<>\u200E\u200F\u00A0]/g,
// @ts-ignore to be fixed
(match) => ESCAPE_SUBSTITUTIONS[match],
);

View file

@ -1,5 +1,5 @@
import { Hono } from "hono";
import { HonoVariables } from "../../lib/types/HonoVariables.ts";
import type { HonoVariables } from "../../lib/types/HonoVariables.ts";
import { Store } from "@willsoto/node-konfig-core";
import { verifyRequest } from "../../lib/helpers/verifyRequest.ts";
import { youtubePlayerParsing } from "../../lib/helpers/youtubePlayerHandling.ts";
@ -33,7 +33,7 @@ captionsHandler.get("/:videoId", async (c) => {
}
}
const innertubeClient = await c.get("innertubeClient") as Innertube;
const innertubeClient = await c.get("innertubeClient");
const playerJson = await youtubePlayerParsing(
innertubeClient,
@ -42,6 +42,7 @@ captionsHandler.get("/:videoId", async (c) => {
);
const captionsTrackArray =
// @ts-ignore to be fixed
playerJson.captions.playerCaptionsTracklistRenderer.captionTracks;
const label = c.req.query("label");
@ -51,8 +52,9 @@ captionsHandler.get("/:videoId", async (c) => {
if (label == undefined && lang == undefined) {
const invidiousAvailableCaptionsArr: AvailableCaption[] = [];
captionsTrackArray.forEach((captions) => {
captionsTrackArray.forEach((captions: { name: { simpleText: string | number | boolean; }; languageCode: any; }) => {
invidiousAvailableCaptionsArr.push({
// @ts-ignore to be fixed
label: captions.name.simpleText,
languageCode: captions.languageCode,
url: `/api/v1/captions/${videoId}?label=${
@ -68,8 +70,10 @@ captionsHandler.get("/:videoId", async (c) => {
let caption;
if (lang) {
// @ts-ignore to be fixed
caption = captionsTrackArray.filter((c) => c.languageCode === lang);
} else {
// @ts-ignore to be fixed
caption = captionsTrackArray.filter((c) => c.name.simpleText === label);
}