diff --git a/bridges/BandcampBridge.php b/bridges/BandcampBridge.php index 20b4ea93..c041b2b3 100644 --- a/bridges/BandcampBridge.php +++ b/bridges/BandcampBridge.php @@ -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; } diff --git a/bridges/GoogleSearchBridge.php b/bridges/GoogleSearchBridge.php index 406cf2a9..59465e89 100644 --- a/bridges/GoogleSearchBridge.php +++ b/bridges/GoogleSearchBridge.php @@ -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.'); diff --git a/bridges/MoebooruBridge.php b/bridges/MoebooruBridge.php index 1af08575..a7793c39 100644 --- a/bridges/MoebooruBridge.php +++ b/bridges/MoebooruBridge.php @@ -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']; diff --git a/bridges/NasaApodBridge.php b/bridges/NasaApodBridge.php index 5aff63aa..1f6d351a 100644 --- a/bridges/NasaApodBridge.php +++ b/bridges/NasaApodBridge.php @@ -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 = ""; $media = "$new_img_placeholder"; diff --git a/bridges/NationalGeographicBridge.php b/bridges/NationalGeographicBridge.php index 146da79c..79a0600b 100644 --- a/bridges/NationalGeographicBridge.php +++ b/bridges/NationalGeographicBridge.php @@ -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; diff --git a/bridges/RedditBridge.php b/bridges/RedditBridge.php index 7350e849..de80f09d 100644 --- a/bridges/RedditBridge.php +++ b/bridges/RedditBridge.php @@ -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 = ''; } diff --git a/bridges/ReutersBridge.php b/bridges/ReutersBridge.php index 17f6a705..77370d65 100644 --- a/bridges/ReutersBridge.php +++ b/bridges/ReutersBridge.php @@ -498,13 +498,15 @@ EOD; break; case 'table': $table = '
' . $header . ' | '; + $theaders = $content['header'] ?? null; + if ($theaders) { + $tr = '
---|
' . $header . ' | '; + } + $tr .= '