2022-03-23 00:42:15 +03:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
class FunkBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'µKöff';
|
|
|
|
const NAME = 'Funk';
|
|
|
|
const URI = 'https://www.funk.net/';
|
|
|
|
const DESCRIPTION = 'Videos per channel of German public video-on-demand service Funk';
|
2022-03-23 00:42:15 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
const PARAMETERS = [
|
|
|
|
'Channel' => [
|
|
|
|
'channel' => [
|
|
|
|
'name' => 'Slug',
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
|
|
|
'exampleValue' => 'game-two-856'
|
|
|
|
],
|
|
|
|
'max' => [
|
|
|
|
'name' => 'Maximum',
|
|
|
|
'type' => 'number',
|
|
|
|
'defaultValue' => '-1'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
2022-03-23 00:42:15 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
switch ($this->queriedContext) {
|
|
|
|
case 'Channel':
|
|
|
|
$url = static::URI . 'data/videos/byChannelAlias/' . $this->getInput('channel') . '/';
|
|
|
|
if (!empty($this->getInput('max')) && $this->getInput('max') >= 0) {
|
|
|
|
$url .= '?size=' . $this->getInput('max');
|
|
|
|
}
|
2022-03-23 00:42:15 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
$jsonString = getContents($url) or returnServerError('No contents received!');
|
|
|
|
$json = json_decode($jsonString, true);
|
2022-03-23 00:42:15 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
foreach ($json['list'] as $element) {
|
|
|
|
$this->items[] = $this->collectArticle($element);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
returnServerError('Unknown context!');
|
|
|
|
}
|
|
|
|
}
|
2022-03-23 00:42:15 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
private function collectArticle($element)
|
|
|
|
{
|
|
|
|
$item = [];
|
|
|
|
$item['uri'] = static::URI . 'channel/' . $element['channelAlias'] . '/' . $element['alias'];
|
|
|
|
$item['title'] = $element['title'];
|
|
|
|
$item['timestamp'] = $element['publicationDate'];
|
|
|
|
$item['author'] = str_replace('-' . $element['channelId'], '', $element['channelAlias']);
|
|
|
|
$item['content'] = $element['shortDescription'];
|
|
|
|
$item['enclosures'] = [
|
|
|
|
'https://www.funk.net/api/v4.0/thumbnails/' . $element['imageLandscape']
|
|
|
|
];
|
|
|
|
$item['uid'] = $element['entityId'];
|
|
|
|
return $item;
|
|
|
|
}
|
2022-03-23 00:42:15 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function detectParameters($url)
|
|
|
|
{
|
|
|
|
$regex = '/^https?:\/\/(?:www\.)?funk\.net\/channel\/([^\/]+).*$/';
|
|
|
|
if (preg_match($regex, $url, $urlMatches) > 0) {
|
|
|
|
return [
|
2023-08-09 23:40:24 +03:00
|
|
|
'context' => 'Channel',
|
2022-07-01 16:10:30 +03:00
|
|
|
'channel' => $urlMatches[1]
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2022-03-23 00:42:15 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getIcon()
|
|
|
|
{
|
|
|
|
return 'https://www.funk.net/img/favicons/favicon-192x192.png';
|
|
|
|
}
|
2022-03-23 00:42:15 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
switch ($this->queriedContext) {
|
|
|
|
case 'Channel':
|
|
|
|
if (!empty($this->getInput('channel'))) {
|
|
|
|
return $this->getInput('channel');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return parent::getName();
|
|
|
|
}
|
2022-03-23 00:42:15 +03:00
|
|
|
}
|