chore: ignoring a lot of type checking from merging PR #55
This commit is contained in:
parent
bddb450d2c
commit
f4d15314e4
2 changed files with 14 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { Innertube } from "youtubei.js";
|
import { Innertube } from "youtubei.js";
|
||||||
|
|
||||||
|
// @ts-ignore to be fixed
|
||||||
function createTemporalDuration(milliseconds) {
|
function createTemporalDuration(milliseconds) {
|
||||||
return new Temporal.Duration(
|
return new Temporal.Duration(
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -25,6 +26,7 @@ const ESCAPE_SUBSTITUTIONS = {
|
||||||
export async function handleTranscripts(
|
export async function handleTranscripts(
|
||||||
innertubeClient: Innertube,
|
innertubeClient: Innertube,
|
||||||
videoId: string,
|
videoId: string,
|
||||||
|
// @ts-ignore to be fixed
|
||||||
selectedCaption,
|
selectedCaption,
|
||||||
) {
|
) {
|
||||||
const lines: string[] = ["WEBVTT"];
|
const lines: string[] = ["WEBVTT"];
|
||||||
|
@ -34,6 +36,7 @@ export async function handleTranscripts(
|
||||||
selectedCaption.name.simpleText,
|
selectedCaption.name.simpleText,
|
||||||
);
|
);
|
||||||
const rawTranscriptLines =
|
const rawTranscriptLines =
|
||||||
|
// @ts-ignore to be fixed
|
||||||
transcriptInfo.transcript.content.body.initial_segments;
|
transcriptInfo.transcript.content.body.initial_segments;
|
||||||
|
|
||||||
rawTranscriptLines.forEach((line) => {
|
rawTranscriptLines.forEach((line) => {
|
||||||
|
@ -45,14 +48,18 @@ export async function handleTranscripts(
|
||||||
|
|
||||||
const start_ms = createTemporalDuration(line.start_ms).round({
|
const start_ms = createTemporalDuration(line.start_ms).round({
|
||||||
largestUnit: "year",
|
largestUnit: "year",
|
||||||
|
// @ts-ignore to be fixed
|
||||||
}).toLocaleString(undefined, timestampFormatOptions);
|
}).toLocaleString(undefined, timestampFormatOptions);
|
||||||
const end_ms = createTemporalDuration(line.end_ms).round({
|
const end_ms = createTemporalDuration(line.end_ms).round({
|
||||||
largestUnit: "year",
|
largestUnit: "year",
|
||||||
|
// @ts-ignore to be fixed
|
||||||
}).toLocaleString(undefined, timestampFormatOptions);
|
}).toLocaleString(undefined, timestampFormatOptions);
|
||||||
const timestamp = `${start_ms} --> ${end_ms}`;
|
const timestamp = `${start_ms} --> ${end_ms}`;
|
||||||
|
|
||||||
|
// @ts-ignore to be fixed
|
||||||
const text = line.snippet.text.replace(
|
const text = line.snippet.text.replace(
|
||||||
/[&<>\u200E\u200F\u00A0]/g,
|
/[&<>\u200E\u200F\u00A0]/g,
|
||||||
|
// @ts-ignore to be fixed
|
||||||
(match) => ESCAPE_SUBSTITUTIONS[match],
|
(match) => ESCAPE_SUBSTITUTIONS[match],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Hono } from "hono";
|
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 { Store } from "@willsoto/node-konfig-core";
|
||||||
import { verifyRequest } from "../../lib/helpers/verifyRequest.ts";
|
import { verifyRequest } from "../../lib/helpers/verifyRequest.ts";
|
||||||
import { youtubePlayerParsing } from "../../lib/helpers/youtubePlayerHandling.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(
|
const playerJson = await youtubePlayerParsing(
|
||||||
innertubeClient,
|
innertubeClient,
|
||||||
|
@ -42,6 +42,7 @@ captionsHandler.get("/:videoId", async (c) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const captionsTrackArray =
|
const captionsTrackArray =
|
||||||
|
// @ts-ignore to be fixed
|
||||||
playerJson.captions.playerCaptionsTracklistRenderer.captionTracks;
|
playerJson.captions.playerCaptionsTracklistRenderer.captionTracks;
|
||||||
|
|
||||||
const label = c.req.query("label");
|
const label = c.req.query("label");
|
||||||
|
@ -51,8 +52,9 @@ captionsHandler.get("/:videoId", async (c) => {
|
||||||
if (label == undefined && lang == undefined) {
|
if (label == undefined && lang == undefined) {
|
||||||
const invidiousAvailableCaptionsArr: AvailableCaption[] = [];
|
const invidiousAvailableCaptionsArr: AvailableCaption[] = [];
|
||||||
|
|
||||||
captionsTrackArray.forEach((captions) => {
|
captionsTrackArray.forEach((captions: { name: { simpleText: string | number | boolean; }; languageCode: any; }) => {
|
||||||
invidiousAvailableCaptionsArr.push({
|
invidiousAvailableCaptionsArr.push({
|
||||||
|
// @ts-ignore to be fixed
|
||||||
label: captions.name.simpleText,
|
label: captions.name.simpleText,
|
||||||
languageCode: captions.languageCode,
|
languageCode: captions.languageCode,
|
||||||
url: `/api/v1/captions/${videoId}?label=${
|
url: `/api/v1/captions/${videoId}?label=${
|
||||||
|
@ -68,8 +70,10 @@ captionsHandler.get("/:videoId", async (c) => {
|
||||||
let caption;
|
let caption;
|
||||||
|
|
||||||
if (lang) {
|
if (lang) {
|
||||||
|
// @ts-ignore to be fixed
|
||||||
caption = captionsTrackArray.filter((c) => c.languageCode === lang);
|
caption = captionsTrackArray.filter((c) => c.languageCode === lang);
|
||||||
} else {
|
} else {
|
||||||
|
// @ts-ignore to be fixed
|
||||||
caption = captionsTrackArray.filter((c) => c.name.simpleText === label);
|
caption = captionsTrackArray.filter((c) => c.name.simpleText === label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue