package LANraragi::Plugin::Scripts::MyNewPlugin;
# 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 => "Script Boilerplate",
namespace => "dummyscript",
description => "This is base boilerplate for writing LRR scripts. Uses JSONPlaceholder to return bogus data.",
icon => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABZSURBVDhPzY5JCgAhDATzSl+e/2irOUjQSFzQog5hhqIl3uBEHPxIXK7oFXwVE+Hj5IYX4lYVtN6MUW4tGw5jNdjdt5bLkwX1q2rFU0/EIJ9OUEm8xquYOQFEhr9vvu2U8gAAAABJRU5ErkJggg==",
oneshot_arg => "ID argument for https://jsonplaceholder.typicode.com/",
{type => "bool", desc => "Use posts instead of todos (jsonplaceholder)"}
## Mandatory function to be implemented by your script
my $lrr_info = shift; # Global info hash
my ($useposts) = @_; # Plugin parameters
my $logger = get_logger( "Source Finder", "plugins" );
# Get the runtime parameter
my $id = $lrr_info->{oneshot_param};
$logger->debug("useposts = " . $useposts );
$url = "https://jsonplaceholder.typicode.com/posts/$id";
$url = "https://jsonplaceholder.typicode.com/todos/$id";
$logger->debug("Loading " . $url );
return ( error => "No ID specified!");
# Use the provided useragent
my $ua = $lrr_info->{user_agent};
my $res = $ua->get($url)->result;
# Return the response JSON directly.
return ( error => $res->message );