vot.js - v2.4.12
    Preparing search index...

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    apiToken: undefined | string

    If you don't want to use the classic fetch

    import { ofetch } from "ofetch";

    import VOTClient from "../packages/node/dist/client";
    import { getVideoData } from "../packages/node/dist/utils/videoData";

    // https://github.com/unjs/ofetch
    const client = new VOTClient({
    fetchFn: ofetch.native,
    });

    const videoData = await getVideoData("https://youtu.be/LK6nLR1bzpI", {
    fetchFn: ofetch.native,
    });
    fetchOpts: Record<string, unknown>
    headers: Record<string, string>

    Headers for interacting with Yandex API

    headersVOT: Record<string, string>
    host: string
    hostSchemaRe: RegExp
    hostVOT: string
    paths: {
        streamPing: string;
        streamTranslation: string;
        videoSubtitles: string;
        videoTranslation: string;
        videoTranslationAudio: string;
        videoTranslationCache: string;
        videoTranslationFailAudio: string;
    }
    requestLang:
        | "en"
        | "auto"
        | "ru"
        | "zh"
        | "ko"
        | "lt"
        | "lv"
        | "ar"
        | "fr"
        | "it"
        | "es"
        | "de"
        | "ja"
    responseLang: "en" | "ru" | "kk"
    schema: URLSchema
    schemaVOT: URLSchema
    sessions: VOTSessions
    userAgent: string

    Accessors

    • get apiTokenHeader(): Record<string, string>

      Returns Record<string, string>

    Methods

    • Parameters

      Returns Promise<{ expires: number; secretKey: string; uuid: string }>

    • Parameters

      • body: unknown
      • Optionalheaders: Record<string, string>
      • Optionalmethod: string

      Returns { body: unknown; headers: { [x: string]: string }; method: string }

    • Parameters

      • url: string

      Returns boolean

    • Parameters

      Returns Promise<boolean>

    • The standard method for requesting the Yandex API, if necessary, you can override how it is done in the example

      import { getVideoData } from "../packages/node/dist/utils/videoData";
      import { ClientResponse } from "../packages/core/dist/types/client";

      // https://github.com/axios/axios
      const client = new (class AxiosVOTClient extends VOTClient {
      async request<T = unknown>(
      path: string,
      body: Uint8Array,
      headers: Record<string, string> = {},
      method = "POST",
      ): Promise<ClientResponse<T>> {
      try {
      const res = await axios({
      url: `https://${this.host}${path}`,
      method,
      headers: {
      ...this.headers,
      ...headers,
      },
      data: body,
      responseType: "arraybuffer",
      ...this.fetchOpts,
      });
      return {
      success: res.status === 200,
      data: res.data as T,
      };
      } catch (err) {
      return {
      success: false,
      data: (err as Error)?.message,
      };
      }
      }
      //...
      })();

      const videoData = await getVideoData("https://youtu.be/LK6nLR1bzpI");

      Type Parameters

      • T = ArrayBuffer

      Parameters

      • path: string
      • body: Uint8Array
      • Optionalheaders: Record<string, string>
      • Optionalmethod: string

      Returns Promise<ClientResponse<T>>

    • Type Parameters

      • T = unknown

      Parameters

      • path: string
      • Optionalbody: unknown
      • Optionalheaders: Record<string, string>
      • Optionalmethod: string

      Returns Promise<ClientResponse<T>>

    • Type Parameters

      • T = unknown

      Parameters

      • path: string
      • body: any
      • Optionalheaders: Record<string, string>

      Returns Promise<ClientResponse<T>>