Scroll to navigation

WWW::YouTube::Download(3pm) User Contributed Perl Documentation WWW::YouTube::Download(3pm)


WWW::YouTube::Download - WWW::YouTube::Download - Very simple YouTube video download interface


version 0.65


  use WWW::YouTube::Download;
  my $client = WWW::YouTube::Download->new;
  my $video_url = $client->get_video_url($video_id);
  my $title     = $client->get_title($video_id);     # maybe encoded utf8 string.
  my $fmt       = $client->get_fmt($video_id);       # maybe highest quality.
  my $suffix    = $client->get_suffix($video_id);    # maybe highest quality file suffix


WWW::YouTube::Download is a library to download videos from YouTube. It relies entirely on scraping a video's webpage and does not use YT's /get_video_info URL space.


  $client = WWW::YouTube::Download->new;

Creates a WWW::YouTube::Download instance.

  $client->download($video_id, {
      fmt      => 37,
      filename => 'sample.mp4', # save file name
  $client->download($video_id, {
      filename => '{title}.{suffix}', # maybe `video_title.mp4`
  $client->download($video_id, {
      cb => \&callback,

Download the video file. The first parameter is passed to YouTube video url.

Allowed arguments:

Set a callback subroutine, SEE LWP::UserAgent ':content_cb' for details.
Set the filename, possibly using placeholders to be filled with information gathered about the video.

"filename" supported format placeholders:


Output filename is set to "{video_id}.{suffix}" by default.

DEPRECATED alternative for "filename".
set the format to download. Defaults to the best video quality (inferred by the available resolutions).
  $client->playback_url($video_id, { fmt => 37 });

Return playback URL of the video. This is direct link to the movie file. Function supports only "fmt" option.

Gather data about the video. A hash reference is returned, with the following keys:
the default, suggested format. It is inferred by selecting the alternative with the highest resolution.
the list of available formats, as an array reference.
the filename extension associated to the default format (see "fmt" above).
the title of the video
the YouTube user owning the video
the video identifier
the URL of the video associated to the default format (see "fmt" above).
an hash reference containing details about all available formats.

The "video_url_map" has one key/value pair for each available format, where the key is the format identifier (can be used as "fmt" parameter for "download", for example) and the value is a hash reference with the following data:

the format specifier, that can be passed to "download"
the resolution as widthxheight
the suffix, providing a hint about the video format (e.g. webm, flv, ...)
the URL where the video can be found

Sets and gets LWP::UserAgent object.

Parses given URL and returns video ID.
Parses given URL and returns playlist ID.
Parses given URL and returns YouTube username.
Fetches a playlist and returns a ref to an array of hashes, where each hash represents a video from the playlist with youtube id, runtime in seconds and title. On playlists with many videos, the method iteratively downloads pages until the playlist is complete.

Optionally accepts a second argument, a hashref of options. Currently, you can pass a "limit" value to stop downloading of subsequent pages on larger playlists after x-amount of fetches (a limit of fetches, not playlist items). For example, pass 1 to only download the first page of videos from a playlist in order to "skim" the "tip" of new videos in a playlist. YouTube currently returns 100 videos at max per page.

This method is used by the script.




Please use github issues: <>.


WWW::YouTube::Info and WWW::YouTube::Info::Simple. WWW::NicoVideo::Download <>


xaicron <xaicron {@}>


This software is copyright (c) 2013 by Yuji Shimada.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2020-11-23 perl v5.32.0