Skip to Content
Mika Scraper 1.1.1 is released ๐ŸŽ‰

Mika Scraper v1.1.2


Mika Scraper / YTDL2

Class: YTDL2

Defined in: src/youtube/ytdl2.ts:19

The YTDL2 class provides methods to download YouTube videos in audio or video format using the flvto.online backend.

Constructors

Constructor

new YTDL2(): YTDL2

Returns

An instance of YTDL2.

Methods

download()

download(url, format): Promise<YTDL2Response>

Defined in: src/youtube/ytdl2.ts:32

Fetches downloadable links and metadata for a video specified by the provided URL.

Parameters

url
  • Type: string
  • Description: The full YouTube video URL.
format
  • Type: "mp3" | "mp4"
  • Default: "mp3"
  • Description: The desired format for the downloaded content.

Returns

  • Type: Promise<YTDL2Response>
  • Description: A promise that resolves to the parsed response including title, duration, and download link.

Throws

  • An error if the request fails or if the API returns a non-OK status.

Example

const result = await new YTDL2().download('https://www.youtube.com/watch?v=0TR3_-Rz7t0'); console.log(result.title, result.link);

extractVideoId()

extractVideoId(videoUrl): string

Defined in: src/youtube/ytdl2.ts:73

Extracts the video ID from a full YouTube URL.

Parameters

videoUrl
  • Type: string
  • Description: Any valid YouTube URL.

Returns

  • Type: string
  • Description: The extracted video ID string (e.g., Ajxn0PKbv7I).

Throws

  • An error if the video ID cannot be extracted.

Example

const id = await new YTDL2().extractVideoId("https://www.youtube.com/watch?v=Ajxn0PKbv7I");

downloadByUrl()

downloadByUrl(videoUrl, format): Promise<YTDL2Response>

Defined in: src/youtube/ytdl2.ts:111

Downloads a YouTube video as MP3 or MP4 using the provided video URL.

Parameters

videoUrl
  • Type: string
  • Description: The full YouTube video URL.
format
  • Type: "mp3" | "mp4"
  • Description: The desired output format for the download.

Returns

  • Type: Promise<YTDL2Response>
  • Description: A promise that resolves to download metadata received from the flvto.online service.

Throws

  • An error if the conversion fails.

Example

const info = await new YTDL2().downloadByUrl('https://youtu.be/Ajxn0PKbv7I', 'mp3');
Last updated on