From bf375c435de57d5af9c6cba73b863164c38cf913 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Tue, 13 Jul 2021 13:47:56 +0200 Subject: [PATCH 1/3] added yacy --- app/Models/parserSkripte/Yacy.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/Models/parserSkripte/Yacy.php b/app/Models/parserSkripte/Yacy.php index a335e24a..37c238f7 100644 --- a/app/Models/parserSkripte/Yacy.php +++ b/app/Models/parserSkripte/Yacy.php @@ -39,7 +39,7 @@ class Yacy extends Searchengine $this->engine->{"display-name"}, $this->engine->homepage, $this->counter ); - } + } } } catch (\Exception $e) { @@ -48,4 +48,29 @@ class Yacy extends Searchengine return; } } + + public function getNext(\App\MetaGer $metager, $result) + { + try{ + $resultCount = 0; + $content = json_decode($result, true); + $content = $content["channels"]; + + foreach ($content as $channel) { + $items = $channel["items"]; + $resultCount += sizeof($items); + } + + if($resultCount > 0){ + $next = new Yacy($this->name, $this->engine, $metager); + $next->getString .= "&startRecord=" . (($metager->getPage() + 1) * 10); + $next->hash = md5($next->engine->host . $next->getString . $next->engine->port . $next->name); + $this->next = $next; + } + } catch (\Exception $e) { + Log::error("A problem occurred parsing results from $this->name:"); + Log::error($e->getMessage()); + return; + } + } } -- GitLab From b9ffd9b0efa80ef1d3d9a3b395914fd2cc211fa2 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Wed, 14 Jul 2021 10:15:02 +0200 Subject: [PATCH 2/3] fixed yacy pagination --- app/Models/parserSkripte/Yacy.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Models/parserSkripte/Yacy.php b/app/Models/parserSkripte/Yacy.php index 37c238f7..75505458 100644 --- a/app/Models/parserSkripte/Yacy.php +++ b/app/Models/parserSkripte/Yacy.php @@ -62,9 +62,10 @@ class Yacy extends Searchengine } if($resultCount > 0){ - $next = new Yacy($this->name, $this->engine, $metager); - $next->getString .= "&startRecord=" . (($metager->getPage() + 1) * 10); - $next->hash = md5($next->engine->host . $next->getString . $next->engine->port . $next->name); + $next = clone $this; + $next->engine->{"get-parameter"}["startRecord"] = $this->engine->{"get-parameter"}["startRecord"] + 10; + $next->getString = $this->generateGetString($metager->getQ()); + $next->updateHash(); $this->next = $next; } } catch (\Exception $e) { -- GitLab From 34ab25af6bb923997f7fa92c3eabcf46b39ab43f Mon Sep 17 00:00:00 2001 From: Dominik Hebeler Date: Wed, 14 Jul 2021 10:47:12 +0200 Subject: [PATCH 3/3] fixed yacy pagination --- app/Models/parserSkripte/Yacy.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Models/parserSkripte/Yacy.php b/app/Models/parserSkripte/Yacy.php index 75505458..838a1fa7 100644 --- a/app/Models/parserSkripte/Yacy.php +++ b/app/Models/parserSkripte/Yacy.php @@ -62,10 +62,9 @@ class Yacy extends Searchengine } if($resultCount > 0){ - $next = clone $this; - $next->engine->{"get-parameter"}["startRecord"] = $this->engine->{"get-parameter"}["startRecord"] + 10; - $next->getString = $this->generateGetString($metager->getQ()); - $next->updateHash(); + $engine = clone $this->engine; + $engine->{"get-parameter"}->startRecord += 10; + $next = new Yacy($this->name, $engine, $metager); $this->next = $next; } } catch (\Exception $e) { -- GitLab