From 216422f50aac7187db0e355276177d5949fad9f3 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 18 Feb 2023 17:14:40 +0000 Subject: [PATCH] api: always return a list of media_ids --- lib/PoorBooru.pm | 4 ++-- lib/PoorBooru/API/V0.pm | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/PoorBooru.pm b/lib/PoorBooru.pm index 187bc47..fafbd30 100644 --- a/lib/PoorBooru.pm +++ b/lib/PoorBooru.pm @@ -63,8 +63,8 @@ get "/tag/:tag_id_or_name" => sub { my $data = decode_json($res->{content}); my @media = map +( { # XXX point to a cache - image_src => $POORBOORU_API . $_->{download_path}, - view_uri => uri_for("/view/" . $_->{id}), + image_src => "$POORBOORU_API/download/$_", + view_uri => uri_for("/view/$_"), } ), @{$data->{media}}; template "gallery" => { diff --git a/lib/PoorBooru/API/V0.pm b/lib/PoorBooru/API/V0.pm index 80381a1..5caae23 100644 --- a/lib/PoorBooru/API/V0.pm +++ b/lib/PoorBooru/API/V0.pm @@ -73,13 +73,7 @@ get "/tag/:tag_id_or_name" => sub { return { id => $tag->tag_id, name => $tag->name, - media => [ - map +( { - id => $_, - path => "/media/$_", - download_path => "/download/$_", - } ), @media, - ], + media => \@media, }; }; @@ -92,7 +86,7 @@ get "/media" => sub { ->page($page); my ($prev, $next) = surrounding_pages($paged_media); - my @media = map { "/media/" . $_->media_id } $paged_media->all; + my @media = map { $_->media_id } $paged_media->all; return { next => ($next and "/media?page=$next"),