Skip to content
Snippets Groups Projects
Commit 60c5de00 authored by karl's avatar karl
Browse files

Die Europeana Bildersuche ist jetzt eingebaut. Leider liefert sie meist nur...

Die Europeana Bildersuche ist jetzt eingebaut. Leider liefert sie meist nur Bilder von Antiquitäten und Kunst, sowie ab und zu kein Vorschaubild, die Links funktionieren dann aber immernoch und zeigen auch ein Bild an.
parent f429308a
No related branches found
No related tags found
1 merge request!1365Resolve "Filter Options for MetaGer"
...@@ -83,7 +83,7 @@ class Search extends Job implements ShouldQueue ...@@ -83,7 +83,7 @@ class Search extends Job implements ShouldQueue
break; break;
} }
if( sizeof(($tmp = explode(": ", $data))) === 2 ) if( sizeof(($tmp = explode(": ", $data))) === 2 )
$headers[trim($tmp[0])] = trim($tmp[1]); $headers[strtolower(trim($tmp[0]))] = trim($tmp[1]);
$c++; $c++;
} }
while (true); while (true);
...@@ -91,13 +91,13 @@ class Search extends Job implements ShouldQueue ...@@ -91,13 +91,13 @@ class Search extends Job implements ShouldQueue
// end of headers // end of headers
if(sizeof($headers) > 1){ if(sizeof($headers) > 1){
$bodySize = 0; $bodySize = 0;
if( isset($headers["Transfer-Encoding"]) && $headers["Transfer-Encoding"] === "chunked" ) if( isset($headers["transfer-encoding"]) && $headers["transfer-encoding"] === "chunked" )
{ {
$body = $this->readChunked(); $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) if(is_numeric($length) && $length >= 1)
$body = $this->readBody($length); $body = $this->readBody($length);
$bodySize = strlen($body); $bodySize = strlen($body);
...@@ -111,7 +111,7 @@ class Search extends Job implements ShouldQueue ...@@ -111,7 +111,7 @@ class Search extends Job implements ShouldQueue
} }
Redis::del($this->host . "." . $this->socketNumber); 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); $body = $this->gunzip($body);
} }
......
<?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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment