mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 01:25:28 +03:00
fix: bug in prior refactor (#4179)
* fix: bug in prior refactor * fix deprecation notice
This commit is contained in:
parent
b8a9f34527
commit
8a1f2604aa
2 changed files with 17 additions and 20 deletions
|
@ -112,6 +112,15 @@ class DisplayAction implements ActionInterface
|
||||||
$input = array_diff_key($requestArray, array_fill_keys($remove, ''));
|
$input = array_diff_key($requestArray, array_fill_keys($remove, ''));
|
||||||
$bridge->setInput($input);
|
$bridge->setInput($input);
|
||||||
$bridge->collectData();
|
$bridge->collectData();
|
||||||
|
$items = $bridge->getItems();
|
||||||
|
if (isset($items[0]) && is_array($items[0])) {
|
||||||
|
$feedItems = [];
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$feedItems[] = FeedItem::fromArray($item);
|
||||||
|
}
|
||||||
|
$items = $feedItems;
|
||||||
|
}
|
||||||
|
$feed = $bridge->getFeed();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Probably an exception inside a bridge
|
// Probably an exception inside a bridge
|
||||||
if ($e instanceof HttpException) {
|
if ($e instanceof HttpException) {
|
||||||
|
@ -145,16 +154,6 @@ class DisplayAction implements ActionInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = $bridge->getItems();
|
|
||||||
if (isset($items[0]) && is_array($items[0])) {
|
|
||||||
$feedItems = [];
|
|
||||||
foreach ($items as $item) {
|
|
||||||
$feedItems[] = FeedItem::fromArray($item);
|
|
||||||
}
|
|
||||||
$items = $feedItems;
|
|
||||||
}
|
|
||||||
$feed = $bridge->getFeed();
|
|
||||||
|
|
||||||
$formatFactory = new FormatFactory();
|
$formatFactory = new FormatFactory();
|
||||||
$format = $formatFactory->create($format);
|
$format = $formatFactory->create($format);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class GelbooruBridge extends BridgeAbstract
|
||||||
return $this->getURI()
|
return $this->getURI()
|
||||||
. 'index.php?&page=dapi&s=post&q=index&json=1&pid=' . $this->getInput('p')
|
. 'index.php?&page=dapi&s=post&q=index&json=1&pid=' . $this->getInput('p')
|
||||||
. '&limit=' . $this->getInput('l')
|
. '&limit=' . $this->getInput('l')
|
||||||
. '&tags=' . urlencode($this->getInput('t'));
|
. '&tags=' . urlencode($this->getInput('t') ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -76,18 +76,16 @@ class GelbooruBridge extends BridgeAbstract
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
$content = getContents($this->getFullURI());
|
$url = $this->getFullURI();
|
||||||
// $content is empty string
|
$content = getContents($url);
|
||||||
|
|
||||||
// Most other Gelbooru-based boorus put their content in the root of
|
if ($content === '') {
|
||||||
// the JSON. This check is here for Bridges that inherit from this one
|
return;
|
||||||
$posts = json_decode($content);
|
|
||||||
if (isset($posts->post)) {
|
|
||||||
$posts = $posts->post;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($posts)) {
|
$posts = Json::decode($content, false);
|
||||||
returnServerError('No posts found.');
|
if (isset($posts->post)) {
|
||||||
|
$posts = $posts->post;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
|
|
Loading…
Reference in a new issue