From fc0ae42450e9e7bf8bd0b5241396ab14d6cb9b39 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 5 Aug 2017 22:38:22 +0200 Subject: [PATCH] [GelbooruBridge] Fix bridge not getting tags correctly Tags are embedded in the 'title' attribute instead of 'alt' as defined by the ancestor (DanbooruBridge). The 'title' attribute also contains statistics data ('score:...', 'rating:...') that is now filtered by a custom implementation of the 'getTags' function (elements that contain a colon are removed) Closes #560 --- bridges/GelbooruBridge.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bridges/GelbooruBridge.php b/bridges/GelbooruBridge.php index fa4ce11a..4fe30e21 100644 --- a/bridges/GelbooruBridge.php +++ b/bridges/GelbooruBridge.php @@ -10,6 +10,7 @@ class GelbooruBridge extends DanbooruBridge { const PATHTODATA = '.thumb'; const IDATTRIBUTE = 'id'; + const TAGATTRIBUTE = 'title'; const PIDBYPAGE = 63; @@ -19,4 +20,16 @@ class GelbooruBridge extends DanbooruBridge { . ($this->getInput('p') ? ($this->getInput('p') - 1) * static::PIDBYPAGE : '') . '&tags=' . urlencode($this->getInput('t')); } + + protected function getTags($element){ + $tags = parent::getTags($element); + $tags = explode(' ', $tags); + + // Remove statistics from the tags list (identified by colon) + foreach($tags as $key => $tag) { + if(strpos($tag, ':') !== false) unset($tags[$key]); + } + + return implode(' ', $tags); + } }