Radiobrowser.php 1.83 KB
Newer Older
1
2
3
4
5
<?php

namespace app\Models\parserSkripte;

use App\Models\Searchengine;
6
use Log;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

class Radiobrowser extends Searchengine
{
    public $results = [];

    public 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);
22
23
            if (!$content) {
                return;
24
            }
25
26
27
28
29
30
31
32

            foreach ($content as $result) {
                $title       = $result->name;
                $link        = $result->homepage;
                $anzeigeLink = $link;
                $descr       = "";
                if ($result->tags != "") {
                    $descr .= "Tags: " . $result->tags;
33
                }
34
35
36
37
38
39
40
41
42
43
44
                if ($result->tags != "") {
                    if ($descr != "") {
                        $descr .= " - ";
                    }
                    $descr .= "Country: " . $result->country;
                }
                if ($result->tags != "") {
                    if ($descr != "") {
                        $descr .= " - ";
                    }
                    $descr .= "Language: " . $result->language;
45
                }
46
47
48
49
50
51
52
                $this->counter++;
                $this->results[] = new \App\Models\Result(
                    $this->engine,
                    $title,
                    $link,
                    $anzeigeLink,
                    $descr,
53
                    $this->displayName,$this->homepage,
54
                    $this->counter
55
                );
56
            }
57
        } catch (\Exception $e) {
58
59
            Log::error("A problem occurred parsing results from $this->name:");
            Log::error($e->getMessage());
60
            return;
61
62
63
        }
    }
}