mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-10 17:08:47 +00:00
[RutubeBridge] New option to fetch video from search results (#4162)
This commit is contained in:
parent
a1b3e596fc
commit
bba225dfe8
@ -24,6 +24,13 @@ class RutubeBridge extends BridgeAbstract
|
|||||||
'required' => true
|
'required' => true
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'По результатам поиска' => [
|
||||||
|
's' => [
|
||||||
|
'name' => 'Запрос',
|
||||||
|
'exampleValue' => 'SUREN',
|
||||||
|
'required' => true,
|
||||||
|
]
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $title;
|
protected $title;
|
||||||
@ -34,6 +41,8 @@ class RutubeBridge extends BridgeAbstract
|
|||||||
return self::URI . '/channel/' . strval($this->getInput('c')) . '/videos/';
|
return self::URI . '/channel/' . strval($this->getInput('c')) . '/videos/';
|
||||||
} elseif ($this->getInput('p')) {
|
} elseif ($this->getInput('p')) {
|
||||||
return self::URI . '/plst/' . strval($this->getInput('p')) . '/';
|
return self::URI . '/plst/' . strval($this->getInput('p')) . '/';
|
||||||
|
} elseif ($this->getInput('s')) {
|
||||||
|
return self::URI . '/search/?suggest=1&query=' . strval($this->getInput('s'));
|
||||||
} else {
|
} else {
|
||||||
return parent::getURI();
|
return parent::getURI();
|
||||||
}
|
}
|
||||||
@ -60,7 +69,7 @@ class RutubeBridge extends BridgeAbstract
|
|||||||
return json_decode(str_replace('\x', '\\\x', $matches[1]));
|
return json_decode(str_replace('\x', '\\\x', $matches[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData()
|
private function getVideosFromReduxState()
|
||||||
{
|
{
|
||||||
$link = $this->getURI();
|
$link = $this->getURI();
|
||||||
|
|
||||||
@ -73,6 +82,26 @@ class RutubeBridge extends BridgeAbstract
|
|||||||
} elseif ($this->getInput('p')) {
|
} elseif ($this->getInput('p')) {
|
||||||
$videos = $reduxState->playlist->data->results;
|
$videos = $reduxState->playlist->data->results;
|
||||||
$this->title = $reduxState->playlist->title;
|
$this->title = $reduxState->playlist->title;
|
||||||
|
} elseif ($this->getInput('s')) {
|
||||||
|
$this->title = 'Поиск ' . $this->getInput('s');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $videos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getVideosFromSearchAPI()
|
||||||
|
{
|
||||||
|
$contents = getContents(self::URI . '/api/search/video/?suggest=1&client=wdp&query=' . $this->getInput('s'));
|
||||||
|
$json = json_decode($contents);
|
||||||
|
return $json->results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collectData()
|
||||||
|
{
|
||||||
|
if ($this->getInput('c') || $this->getInput('p')) {
|
||||||
|
$videos = $this->getVideosFromReduxState();
|
||||||
|
} else {
|
||||||
|
$videos = $this->getVideosFromSearchAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($videos as $video) {
|
foreach ($videos as $video) {
|
||||||
|
Loading…
Reference in New Issue
Block a user