mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-03-14 20:21:14 +03:00
feat: add new bridge for picarto.tv (#3220)
This commit is contained in:
parent
04090bd84a
commit
c06e471ae9
1 changed files with 41 additions and 0 deletions
41
bridges/PicartoBridge.php
Normal file
41
bridges/PicartoBridge.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
class PicartoBridge extends BridgeAbstract
|
||||
{
|
||||
const NAME = 'Picarto';
|
||||
const URI = 'https://picarto.tv';
|
||||
const DESCRIPTION = 'Produces a new feed item each time a channel goes live';
|
||||
const CACHE_TIMEOUT = 300;
|
||||
const PARAMETERS = [[
|
||||
'channel' => [
|
||||
'name' => 'Channel name',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'title' => 'Channel name',
|
||||
'exampleValue' => 'Wysdrem',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$channel = $this->getInput('channel');
|
||||
$data = json_decode(getContents('https://api.picarto.tv/api/v1/channel/name/' . $channel), true);
|
||||
if (!$data['online']) {
|
||||
return;
|
||||
}
|
||||
$lastLive = new \DateTime($data['last_live']);
|
||||
$this->items[] = [
|
||||
'uri' => 'https://picarto.tv/' . $channel,
|
||||
'title' => $data['name'] . ' is now online',
|
||||
'content' => sprintf('<img src="%s"/>', $data['thumbnails']['tablet']),
|
||||
'timestamp' => $lastLive->getTimestamp(),
|
||||
'uid' => 'https://picarto.tv/' . $channel . $lastLive->getTimestamp(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Picarto - ' . $this->getInput('channel');
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue