Fernsehsuche.php 1.65 KB
Newer Older
1
2
3
<?php

namespace app\Models\parserSkripte;
4

5
use App\Models\Searchengine;
6
use Log;
7

8
class Fernsehsuche extends Searchengine
9
{
10
    public $results = [];
11

12
13
14
15
    public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
    {
        parent::__construct($engine, $metager);
    }
16

17
18
19
20
21
    public function loadResults($result)
    {
        $result = preg_replace("/\r\n/si", "", $result);
        try {
            $content = json_decode($result);
22
23
24
            if (!$content) {
                return;
            }
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
            $results = $content->response->docs;
            foreach ($results as $result) {
                try {
                    $title       = $result->show . " : " . $result->title;
                    $link        = urldecode($result->url);
                    $anzeigeLink = $link;
                    $descr       = $result->description;
                    $image       = "http://api-resources.fernsehsuche.de" . $result->thumbnail;
                    $this->counter++;
                    $this->results[] = new \App\Models\Result(
                        $this->engine,
                        $title,
                        $link,
                        $anzeigeLink,
                        $descr,
41
                        $this->displayName,$this->homepage,
42
                        $this->counter,
43
                        ['image' => $image]
44
45
46
47
                    );
                } catch (\ErrorException $e) {

                }
48
            }
49
        } catch (\Exception $e) {
50
51
            Log::error("A problem occurred parsing results from $this->name:");
            Log::error($e->getMessage());
52
            return;
53
54
55
        }
    }
}