mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-12-18 00:43:19 +03:00
fix: php errors (notices) (#3115)
This commit is contained in:
parent
8795cb252f
commit
52af2ae34c
9 changed files with 33 additions and 20 deletions
|
@ -313,6 +313,7 @@ class BandcampBridge extends BridgeAbstract
|
|||
private function apiGet($endpoint, $query_data)
|
||||
{
|
||||
$url = self::URI . 'api/' . $endpoint . '?' . http_build_query($query_data);
|
||||
// todo: 429 Too Many Requests happens a lot
|
||||
$data = json_decode(getContents($url));
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class GoogleSearchBridge extends BridgeAbstract
|
|||
|
||||
public function collectData()
|
||||
{
|
||||
// todo: wrap this in try..catch because 429 too many requests happens a lot
|
||||
$dom = getSimpleHTMLDOM($this->getURI(), ['Accept-language: en-US']);
|
||||
if (!$dom) {
|
||||
returnServerError('No results for this query.');
|
||||
|
|
|
@ -40,6 +40,9 @@ class MoebooruBridge extends BridgeAbstract
|
|||
|
||||
foreach ($data as $datai) {
|
||||
$json = json_decode($datai, true);
|
||||
if ($json === null) {
|
||||
continue;
|
||||
}
|
||||
$item = [];
|
||||
$item['uri'] = $this->getURI() . '/post/show/' . $json['id'];
|
||||
$item['postid'] = $json['id'];
|
||||
|
|
|
@ -26,9 +26,10 @@ class NasaApodBridge extends BridgeAbstract
|
|||
//Extract image and explanation
|
||||
$image_wrapper = $picture_html->find('a', 1);
|
||||
$image_path = $image_wrapper->href;
|
||||
// This image is not present when youtube embed
|
||||
$img_placeholder = $image_wrapper->find('img', 0);
|
||||
$img_alt = $img_placeholder->alt;
|
||||
$img_style = $img_placeholder->style;
|
||||
$img_alt = $img_placeholder->alt ?? '';
|
||||
$img_style = $img_placeholder->style ?? '';
|
||||
$image_uri = self::URI . $image_path;
|
||||
$new_img_placeholder = "<img src=\"$image_uri\" alt=\"$img_alt\" style=\"$img_style\">";
|
||||
$media = "<a href=\"$image_uri\">$new_img_placeholder</a>";
|
||||
|
|
|
@ -170,10 +170,8 @@ class NationalGeographicBridge extends BridgeAbstract
|
|||
$image = $story['img'];
|
||||
$item['enclosures'][] = $image['src'];
|
||||
|
||||
$tags = $story['tags'];
|
||||
foreach ($tags as $tag) {
|
||||
$tag_name = $tag['name'];
|
||||
$item['categories'][] = $tag_name;
|
||||
foreach ($story['tags'] as $tag) {
|
||||
$item['categories'][] = $tag['name'] ?? $tag;
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
|
|
|
@ -150,8 +150,6 @@ class RedditBridge extends BridgeAbstract
|
|||
$flair = '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach ($subreddits as $subreddit) {
|
||||
$name = trim($subreddit);
|
||||
$values = getContents(self::URI
|
||||
|
@ -207,14 +205,17 @@ class RedditBridge extends BridgeAbstract
|
|||
|
||||
$item['content']
|
||||
= htmlspecialchars_decode($data->selftext_html);
|
||||
} elseif (isset($data->post_hint) ? $data->post_hint == 'link' : false) {
|
||||
} elseif (isset($data->post_hint) && $data->post_hint == 'link') {
|
||||
// Link with preview
|
||||
|
||||
if (isset($data->media)) {
|
||||
// Reddit embeds content for some sites (e.g. Twitter)
|
||||
$embed = htmlspecialchars_decode(
|
||||
$data->media->oembed->html
|
||||
);
|
||||
// todo: maybe switch on the type
|
||||
if (isset($data->media->oembed->html)) {
|
||||
// Reddit embeds content for some sites (e.g. Twitter)
|
||||
$embed = htmlspecialchars_decode($data->media->oembed->html);
|
||||
} else {
|
||||
$embed = '';
|
||||
}
|
||||
} else {
|
||||
$embed = '';
|
||||
}
|
||||
|
|
|
@ -498,13 +498,15 @@ EOD;
|
|||
break;
|
||||
case 'table':
|
||||
$table = '<table>';
|
||||
$theaders = $content['header'];
|
||||
$tr = '<tr>';
|
||||
foreach ($theaders as $header) {
|
||||
$tr .= '<th>' . $header . '</th>';
|
||||
$theaders = $content['header'] ?? null;
|
||||
if ($theaders) {
|
||||
$tr = '<tr>';
|
||||
foreach ($theaders as $header) {
|
||||
$tr .= '<th>' . $header . '</th>';
|
||||
}
|
||||
$tr .= '</tr>';
|
||||
$table .= $tr;
|
||||
}
|
||||
$tr .= '</tr>';
|
||||
$table .= $tr;
|
||||
$rows = $content['rows'];
|
||||
foreach ($rows as $row) {
|
||||
$tr = '<tr>';
|
||||
|
|
|
@ -60,6 +60,7 @@ class FileCache implements CacheInterface
|
|||
continue;
|
||||
} elseif ($cacheFile->isFile()) {
|
||||
if (filemtime($cacheFile->getPathname()) < time() - $seconds) {
|
||||
// todo: sometimes this file doesn't exists
|
||||
unlink($cacheFile->getPathname());
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +69,7 @@ class FileCache implements CacheInterface
|
|||
|
||||
public function setScope($scope)
|
||||
{
|
||||
if (is_null($scope) || !is_string($scope)) {
|
||||
if (!is_string($scope)) {
|
||||
throw new \Exception('The given scope is invalid!');
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,12 @@ final class Logger
|
|||
'Exception InvalidArgumentException: Format name invalid',
|
||||
'Exception InvalidArgumentException: Unknown format given',
|
||||
'Exception InvalidArgumentException: Bridge name invalid',
|
||||
'Exception Exception: Invalid action',
|
||||
'Exception Exception: twitter: No results for this query',
|
||||
// telegram
|
||||
'Exception Exception: Unable to find channel. The channel is non-existing or non-public',
|
||||
// fb
|
||||
'Exception Exception: This group is not public! RSS-Bridge only supports public groups!',
|
||||
];
|
||||
foreach ($ignoredExceptions as $ignoredException) {
|
||||
if (str_starts_with($context['message'], $ignoredException)) {
|
||||
|
|
Loading…
Reference in a new issue