WWW::Y...wnload(3pm)
π WWW::YouTube::Download π
okay bestie, so this is the WWW::YouTube::Download page β it's a User Contributed Perl Documentation situation, and it is literally the most low-key way to pull YouTube videos down onto your machine. it's giving "very simple interface" and honestly? it ate. β¨
π VERSION π
version 0.65 β yes queen, we're on 0.65, no cap.
πΈ SYNOPSIS πΈ
use WWW::YouTube::Download;
my $client = WWW::YouTube::Download->new;
$client->download($video_id);
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
like. that's it. that's the whole vibe. π«Ά
π¦ DESCRIPTION π¦
WWW::YouTube::Download is a library that downloads videos from YouTube, periodt. the way it works is it relies entirely on scraping a video's webpage β it does not use YT's /get_video_info URL space. so if you were wondering, that's the whole main character energy of this module: scrape the page, get the goods. π
β¨ METHODS β¨
π new()
$client = WWW::YouTube::Download->new;
makes you a fresh WWW::YouTube::Download instance. iconic. a little baby object. obsessed.
π download($video_id [, \%args])
$client->download($video_id);
$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,
});
this is the one that actually grabs the video file, bestie. the first parameter gets passed to the YouTube video url.
here's everything you're allowed to pass in:
cbβ set a callback subroutine. peepLWP::UserAgentand its:content_cbfor the deets, iykyk.filenameβ set the filename! and you can use placeholders that get filled in with info it gathered about the video. π«
filename supported format placeholders:
{video_id}
{title}
{user}
{fmt}
{suffix}
{resolution}
output filename defaults to {video_id}.{suffix} β that's the default, no cap.
file_nameβ DEPRECATED alternative forfilename. like, she's retired, don't call her. πfmtβ set the format to download. defaults to the best video quality (inferred by the available resolutions). slay.
π playback_url($video_id, [, \%args])
$client->playback_url($video_id);
$client->playback_url($video_id, { fmt => 37 });
returns the playback URL of the video β and bestie, this is a direct link to the movie file. π₯ heads up tho: this function supports only the fmt option. that's it. that's the only one.
π prepare_download($video_id)
gathers data about the video. you get back a hash reference, and these are the keys it comes with:
fmtβ the default, suggested format. it's inferred by selecting the alternative with the highest resolution.fmt_listβ the list of available formats, as an array reference.suffixβ the filename extension associated to the default format (seefmtabove).titleβ the title of the video.userβ the YouTube user owning the video.video_idβ the video identifier.video_urlβ the URL of the video associated to the default format (seefmtabove).video_url_mapβ a hash reference containing details about all available formats.
now, about that video_url_map: it has one key/value pair for each available format. the key is the format identifier (which you can use as the fmt parameter for download, for example), and the value is a hash reference with this data inside:
fmtβ the format specifier, that can be passed todownload.resolutionβ the resolution as widthxheight.suffixβ the suffix, providing a hint about the video format (e.g.webm,flv, ...).urlβ the URL where the video can be found.
π ua([$ua])
$self->ua->agent();
$self->ua($LWP_LIKE_OBJECT);
sets and gets the LWP::UserAgent object. bring your own or grab the one she came with. π§
π video_id($url)
parses the given URL and returns the video ID. cute and useful.
π playlist_id($url)
parses the given URL and returns the playlist ID. π
π user_id($url)
parses the given URL and returns the YouTube username. okay periodt.
π the little getters π
get_video_id($video_id)get_video_url($video_id)get_title($video_id)get_user($video_id)get_fmt($video_id)get_fmt_list($video_id)get_suffix($video_id)
just a whole lineup of little getter besties, standing there, doing their thing. π
π playlist($id,$ref)
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. she's thorough, she doesn't leave anyone behind. π
optionally accepts a second argument β a hashref of options. right now you can pass a limit value to stop downloading of subsequent pages on larger playlists after x-amount of fetches. and listen, important detail: it's 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. and FYI, YouTube currently returns 100 videos at max per page.
this method is used by the youtube-playlists.pl script. so like, if you've used that, you've already met her. π«Ά
π CONTRIBUTORS π
yusukebe
we love you yusukebe, thank you for your service. π
π BUG REPORTING π
please use github issues: <https://github.com/xaicron/p5-www-youtube-download/issues>.
found a bug? do NOT suffer in silence bestie, go file that issue. it's giving responsible. β¨
β SEE ALSO β
WWW::YouTube::InfoandWWW::YouTube::Info::Simple.WWW::NicoVideo::Download<http://rg3.github.io/youtube-dl/>
π AUTHOR π
xaicron <xaicron {@} cpan.org>
π COPYRIGHT AND LICENSE π
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. so like, go off, share the love. π«Ά
and that's the whole page, bestie!! perl v5.32.0, dated 2020-11-23, and yes, the header at the top calls it WWW::Y...wnload(3pm) because apparently we're all about the drama of the ellipsis now π
β anyway ilysm, go download some videos. ππβ¨
π¦ where this page comes from
- debian bookworm: libwww-youtube-download-perl 0.65+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libwww-youtube-download-perl 0.65+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libwww-youtube-download-perl 0.65+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libwww-youtube-download-perl 0.65+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libwww-youtube-download-perl 0.65+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libwww-youtube-download-perl 0.65+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms