aboutsummaryrefslogtreecommitdiff
path: root/bridges/OglafBridge.php
blob: 1f4bc1aff9ee2ce54e5660a93df07ea59852ab69 (plain) (blame)
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
<?php

class OglafBridge extends FeedExpander
{
    const NAME = 'Oglaf';
    const URI = 'https://www.oglaf.com/';
    const DESCRIPTION = 'Fetch the entire comic image';
    const MAINTAINER = 'tillcash';
    const PARAMETERS = [
        [
            'limit' => [
                'name' => 'limit (max 20)',
                'type' => 'number',
                'defaultValue' => 10,
                'required' => true,
            ]
        ]
    ];

    public function collectData()
    {
        $url = self::URI . 'feeds/rss/';
        $limit = min(20, $this->getInput('limit'));
        $this->collectExpandableDatas($url, $limit);
    }

    protected function parseItem($item)
    {
        $html = getSimpleHTMLDOMCached($item['uri']);
        $comicImage = $html->find('img[id="strip"]', 0);
        $item['content'] = $comicImage;

        return $item;
    }
}