diff --git a/app/Jobs/Search.php b/app/Jobs/Search.php index 6575b54f3649997b6c8fc9c22e1ac77afad29843..62fc6b289a31bca00015f1d3e6a7397b3f9ef57b 100644 --- a/app/Jobs/Search.php +++ b/app/Jobs/Search.php @@ -83,7 +83,7 @@ class Search extends Job implements ShouldQueue break; } if( sizeof(($tmp = explode(": ", $data))) === 2 ) - $headers[trim($tmp[0])] = trim($tmp[1]); + $headers[strtolower(trim($tmp[0]))] = trim($tmp[1]); $c++; } while (true); @@ -91,13 +91,13 @@ class Search extends Job implements ShouldQueue // end of headers if(sizeof($headers) > 1){ $bodySize = 0; - if( isset($headers["Transfer-Encoding"]) && $headers["Transfer-Encoding"] === "chunked" ) + if( isset($headers["transfer-encoding"]) && $headers["transfer-encoding"] === "chunked" ) { $body = $this->readChunked(); - }elseif( isset($headers['Content-Length']) ) + }elseif( isset($headers['content-length']) ) { - $length = trim($headers['Content-Length']); + $length = trim($headers['content-length']); if(is_numeric($length) && $length >= 1) $body = $this->readBody($length); $bodySize = strlen($body); @@ -111,7 +111,7 @@ class Search extends Job implements ShouldQueue } Redis::del($this->host . "." . $this->socketNumber); - if( isset($headers["Content-Encoding"]) && $headers['Content-Encoding'] === "gzip") + if( isset($headers["content-encoding"]) && $headers['content-encoding'] === "gzip") { $body = $this->gunzip($body); } diff --git a/app/Models/parserSkripte/Europeana.php b/app/Models/parserSkripte/Europeana.php new file mode 100644 index 0000000000000000000000000000000000000000..2da2db448e9aac4a4d10999eae634202f8222f77 --- /dev/null +++ b/app/Models/parserSkripte/Europeana.php @@ -0,0 +1,68 @@ +<?php + +namespace app\Models\parserSkripte; +use App\Models\Searchengine; +use Symfony\Component\DomCrawler\Crawler; + +class Europeana extends Searchengine +{ + public $results = []; + + function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults ($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = json_decode($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid json string"); + } + + if(!$content) + { + return; + } + + $results = $content->items; + foreach($results as $result) + { + if(isset($result->edmPreview)) { + $title = $result->title[0]; + + if (preg_match("/(.+)\?.*/si", $result->guid, $match)){ + $link = $match[1]; + } else { + $link = ""; + } + + $anzeigeLink = $link; + $descr = ""; + + /*if (preg_match("/(?:uri=)(.+)/si", urldecode($result->edmPreview[0]), $match)){ + $image = $match[1]; + } else { + $image = ""; + } + echo $image . " +";*/ + $image = urldecode($result->edmPreview[0]); + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } + } +} \ No newline at end of file