Skip to content

Commit

Permalink
[danbooru api] ignore star searches
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Jul 3, 2023
1 parent 3c18ebd commit f7f0c11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/danbooru_api/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ private function api_find_posts(): HTMLElement
}

$tags = isset($_GET['tags']) ? Tag::explode($_GET['tags']) : [];
// danbooru API clients often set tags=*
$tags = array_filter($tags, static function ($element) {
return $element !== "*";
});
$count = Image::count_images($tags);
$results = Image::find_images(max($start, 0), min($limit, 100), $tags);
}
Expand Down
1 change: 1 addition & 0 deletions ext/danbooru_api/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function testSearch()
$this->get_page("api/danbooru/find_posts");
$this->get_page("api/danbooru/find_posts", ["id"=>$image_id]);
$this->get_page("api/danbooru/find_posts", ["md5"=>"17fc89f372ed3636e28bd25cc7f3bac1"]);
$this->get_page("api/danbooru/find_posts", ["tags"=>"*"]);

$this->get_page("api/danbooru/find_tags");
$this->get_page("api/danbooru/find_tags", ["id"=>1]);
Expand Down

0 comments on commit f7f0c11

Please sign in to comment.