package LANraragi::Plugin::Download::MyNewDownloader;
# Plugins can freely use all Perl packages already installed on the system
# Try however to restrain yourself to the ones already installed for LRR (see tools/cpanfile) to avoid extra installations by the end-user.
# You can also use LRR packages when fitting.
# All packages are fair game, but only functions explicitly exported by the Utils packages are supported between versions.
# Everything else is considered internal API and can be broken/renamed between versions.
use LANraragi::Model::Plugins;
use LANraragi::Utils::Logging qw(get_logger);
#Meta-information about your plugin.
name => "Example.com Downloader",
description => "This is base boilerplate for writing LRR downloaders. Returns a static URL if you try to download a URL from http://example.com.",
icon => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABZSURBVDhPzY5JCgAhDATzSl+e/2irOUjQSFzQog5hhqIl3uBEHPxIXK7oFXwVE+Hj5IYX4lYVtN6MUW4tGw5jNdjdt5bLkwX1q2rFU0/EIJ9OUEm8xquYOQFEhr9vvu2U8gAAAABJRU5ErkJggg==",
# Downloader-specific metadata
url_regex => "https?:\/\/example.com.*"
## Mandatory function to be implemented by your script
my $lrr_info = shift; # Global info hash
my ($useposts) = @_; # Plugin parameters
my $logger = get_logger( "Dingus Downloader", "plugins" );
my $url = $lrr_info->{url};
$logger->debug("We have been given the following URL: $url" );
# This is the downloadable url we'll give back. It can be completely different from the base domain provided.
my $reply = "https://archive.org/download/quake-essays-sep-15-fin-4-graco-l-cl/QUAKE_essays_SEP15_FIN4_GRACoL_CL.pdf";
# Just for fun, use the provided useragent to see if we've been given a real URL
my $ua = $lrr_info->{user_agent};
my $res = $ua->get($url)->result;
return ( download_url => $reply );
return ( error => "Dingus! ".$res->message );