diff --git a/app/Models/parserSkripte/Allesklar.php b/app/Models/parserSkripte/Allesklar.php index 8e43b26ddb4e783a6d3f29646d394e636ee3d754..045ff22dab63a7193d30659d46e680b6e1547257 100644 --- a/app/Models/parserSkripte/Allesklar.php +++ b/app/Models/parserSkripte/Allesklar.php @@ -49,7 +49,6 @@ class Allesklar extends Searchengine } catch (\InvalidArgumentException $e) { } - }); } diff --git a/app/Models/parserSkripte/Bing.php b/app/Models/parserSkripte/Bing.php index 8cf01e0e74855af821eb97b9dfbbe83035749e51..5c4253a142d86f2edc91deb55635a8d599c94541 100644 --- a/app/Models/parserSkripte/Bing.php +++ b/app/Models/parserSkripte/Bing.php @@ -16,9 +16,7 @@ class Bing extends Searchengine public function loadResults($result) { - - try - { + try { $crawler = new Crawler($result); $crawler->filter('ol#b_results > li.b_algo')->each(function (Crawler $node, $i) { $title = $node->filter('li h2 > a')->text(); diff --git a/app/Models/parserSkripte/Europeana.php b/app/Models/parserSkripte/Europeana.php index 9ea0a4ea70e149742364bfea0e81e67f24bf0383..2f3b80ee3687ebda670dc3a8ce12163760ef05f2 100644 --- a/app/Models/parserSkripte/Europeana.php +++ b/app/Models/parserSkripte/Europeana.php @@ -19,13 +19,12 @@ class Europeana extends Searchengine try { $content = json_decode($result); } catch (\Exception $e) { - abort(500, "$result is not a valid json string"); + Log::error("Results from $this->name are not a valid json string"); + return; } - if (!$content) { return; } - $results = $content->items; foreach ($results as $result) { if (isset($result->edmPreview)) { @@ -56,8 +55,16 @@ class Europeana extends Searchengine public function getNext(\App\MetaGer $metager, $result) { - $start = ($metager->getPage()) * 10 + 1; - $content = json_decode($result); + $start = ($metager->getPage()) * 10 + 1; + try { + $content = json_decode($result); + } catch (\Exception $e) { + Log::error("Results from $this->name are not a valid json string"); + return; + } + if (!$content) { + return; + } if ($start > $content->totalResults) { return; } diff --git a/app/Models/parserSkripte/Flickr.php b/app/Models/parserSkripte/Flickr.php index 73329cb901f1054d27a589b4f1e6e6f752cdf8db..49be5da206166b0deb5e95751adbae7ce9b4578d 100644 --- a/app/Models/parserSkripte/Flickr.php +++ b/app/Models/parserSkripte/Flickr.php @@ -19,9 +19,9 @@ class Flickr extends Searchengine try { $content = simplexml_load_string($result); } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); + Log::error("Results from $this->name are not a valid json string"); + return; } - if (!$content) { return; } @@ -56,7 +56,8 @@ class Flickr extends Searchengine try { $content = simplexml_load_string($result); } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); + Log::error("Results from $this->name are not a valid json string"); + return; } if (!$content) { return; diff --git a/app/Models/parserSkripte/Openclipart.php b/app/Models/parserSkripte/Openclipart.php index ffbf59497762dcfeafc2517f8817ab764531a184..29ac91bc344b563123a0480f5489f7f13d3323c7 100644 --- a/app/Models/parserSkripte/Openclipart.php +++ b/app/Models/parserSkripte/Openclipart.php @@ -19,13 +19,12 @@ class Openclipart extends Searchengine try { $content = json_decode($result); } catch (\Exception $e) { - abort(500, "$result is not a valid json string"); + Log::error("Results from $this->name are not a valid json string"); + return; } - if (!$content) { return; } - $results = $content->payload; foreach ($results as $result) { $title = $result->title; @@ -50,7 +49,15 @@ class Openclipart extends Searchengine public function getNext(\App\MetaGer $metager, $result) { - $content = json_decode($result); + try { + $content = json_decode($result); + } catch (\Exception $e) { + Log::error("Results from $this->name are not a valid json string"); + return; + } + if (!$content) { + return; + } if ($content->info->current_page > $content->info->pages) { return; } diff --git a/app/Models/parserSkripte/Overture.php b/app/Models/parserSkripte/Overture.php index be3c320c48955b745f27c20d47bbc7ef9af99275..c3739b75220ebcb71376e4110802081c5c998dbf 100644 --- a/app/Models/parserSkripte/Overture.php +++ b/app/Models/parserSkripte/Overture.php @@ -19,9 +19,9 @@ class Overture extends Searchengine try { $content = simplexml_load_string($result); } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); + Log::error("Results from $this->name are not a valid json string"); + return; } - if (!$content) { return; } @@ -70,7 +70,11 @@ class Overture extends Searchengine try { $content = simplexml_load_string($result); } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); + Log::error("Results from $this->name are not a valid json string"); + return; + } + if (!$content) { + return; } $nextArgs = $content->xpath('//Results/NextArgs'); if (isset($nextArgs[0])) { diff --git a/app/Models/parserSkripte/Pixabay.php b/app/Models/parserSkripte/Pixabay.php index d5ee4dee913cc0d1dd319209f51b8e8f2d1c96bd..d50dc11aa4f76c54c20ea41ef00bf4b820d5de50 100644 --- a/app/Models/parserSkripte/Pixabay.php +++ b/app/Models/parserSkripte/Pixabay.php @@ -19,7 +19,8 @@ class Pixabay extends Searchengine try { $content = json_decode($result); } catch (\Exception $e) { - abort(500, "$result is not a valid json string"); + Log::error("Results from $this->name are not a valid json string"); + return; } if (!$content) { @@ -50,8 +51,16 @@ class Pixabay extends Searchengine public function getNext(\App\MetaGer $metager, $result) { - $page = $metager->getPage() + 1; - $content = json_decode($result); + $page = $metager->getPage() + 1; + try { + $content = json_decode($result); + } catch (\Exception $e) { + Log::error("Results from $this->name are not a valid json string"); + return; + } + if (!$content) { + return; + } if ($page * 20 > $content->total) { return; } diff --git a/app/Models/parserSkripte/Radiobrowser.php b/app/Models/parserSkripte/Radiobrowser.php index 1fbc12ae26009dc4180fdc78d3ad19b3834fe556..015c6d22bca9cc2f837515b0e679ea5e0e76750b 100644 --- a/app/Models/parserSkripte/Radiobrowser.php +++ b/app/Models/parserSkripte/Radiobrowser.php @@ -19,13 +19,12 @@ class Radiobrowser extends Searchengine try { $content = json_decode($result); } catch (\Exception $e) { - abort(500, "$result is not a valid json string"); + Log::error("Results from $this->name are not a valid json string"); + return; } - if (!$content) { return; } - foreach ($content as $result) { $title = $result->name; $link = $result->homepage; diff --git a/app/Models/parserSkripte/Yandex.php b/app/Models/parserSkripte/Yandex.php index 9a29c72659bc705155a9bcf1afe61a9c95c5e73d..b8dd77138c1ad48c5747f4f2677a6c0e338f788d 100644 --- a/app/Models/parserSkripte/Yandex.php +++ b/app/Models/parserSkripte/Yandex.php @@ -19,12 +19,13 @@ class Yandex extends Searchengine try { $content = simplexml_load_string($result); } catch (\Exception $e) { - abort(500, "$result is not a valid xml string"); + Log::error("Results from $this->name are not a valid json string"); + return; } - if (!$content) { return; } + $results = $content; try { $results = $results->xpath("//yandexsearch/response/results/grouping/group"); @@ -56,13 +57,17 @@ class Yandex extends Searchengine { # Wir müssen herausfinden, ob es überhaupt noch weitere Ergebnisse von Yandex gibt: try { - $content = simplexml_load_string($result); - $resultCount = intval($content->xpath('//yandexsearch/response/results/grouping/found[@priority="all"]')[0]->__toString()); - $pageLast = $content->xpath('//yandexsearch/response/results/grouping/page')[0]; - $pageLast = intval($pageLast["last"]->__toString()); + $content = simplexml_load_string($result); } catch (\Exception $e) { + Log::error("Results from $this->name are not a valid json string"); + return; + } + if (!$content) { return; } + $resultCount = intval($content->xpath('//yandexsearch/response/results/grouping/found[@priority="all"]')[0]->__toString()); + $pageLast = $content->xpath('//yandexsearch/response/results/grouping/page')[0]; + $pageLast = intval($pageLast["last"]->__toString()); if (count($this->results) <= 0 || $pageLast >= $resultCount) { return;