aboutsummaryrefslogtreecommitdiff
path: root/lib/Videolist/Platform/Gisstv.php
blob: b7989844996016e980c91e230c957c8018ace524 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php

class Videolist_Platform_Gisstv implements Videolist_PlatformInterface
{
    public function getType()
    {
        return "gisstv";
    }

    public function parseUrl($url)
    {
        $parsed = parse_url($url);
        $path = explode('/', $parsed['path']);

        if ($parsed['host'] != 'giss.tv' || $path[1] != 'dmmdb') {
            return false;
        }

        if($path[2] == 'contents' && isset($path[3])) {
            $video_id = $path[3];
        } elseif($path[3] == 'contents' && isset($path[4])) {
            $video_id = $path[4];
        } else {
            return false;
        }

        return array(
            'video_id' => $video_id,
        );
    }

    public function getData($parsed)
    {
        $video_id = $parsed['video_id'];

        $buffer = file_get_contents('http://giss.tv/dmmdb//rss.php');
        $xml = new SimpleXMLElement($buffer);

        $data = array();
        foreach($xml->xpath('/rss/channel/item') as $item){
            if ($item->link === 'http://giss.tv/dmmdb//contents/'.$video_id) {
                $data['title'] = $item->title;
                $data['description'] = strip_tags($item->description);
                $data['thumbnail'] = $item->thumbnail;
                break;
            }
        }
        return $data;
    }
}