diff --git a/lib/PoorBooru/API/V0.pm b/lib/PoorBooru/API/V0.pm index 8105797..311aecf 100644 --- a/lib/PoorBooru/API/V0.pm +++ b/lib/PoorBooru/API/V0.pm @@ -114,6 +114,15 @@ get "/tag/:tag_id_or_name" => sub { }; }; +get "/random/tag" => sub { + my $tag = schema("default")->resultset("Tag") + ->search({}, { order_by => \"random()", limit => 1 })->single; + + send_error("Tag not found", 404) if !defined($tag); + + forward "/tag/" . $tag->tag_id; +}; + get "/media" => sub { my $page = query_parameters->get("page") // 1; send_error("Invalid page number", 400) if !validate_page_number($page); @@ -155,7 +164,7 @@ get "/download/:media_id" => sub { ); }; -get "/random" => sub { +get "/random/media" => sub { my $media = schema("default")->resultset("Media") ->search({}, { order_by => \"random()", limit => 1 })->single;