diff --git a/bridges/CuriousCatBridge.php b/bridges/CuriousCatBridge.php index 573c776f..3d6e87d0 100644 --- a/bridges/CuriousCatBridge.php +++ b/bridges/CuriousCatBridge.php @@ -23,7 +23,10 @@ class CuriousCatBridge extends BridgeAbstract $apiJson = getContents($url); - $apiData = json_decode($apiJson, true); + $apiData = Json::decode($apiJson); + if (isset($apiData['error'])) { + throw new \Exception($apiData['error_code']); + } foreach ($apiData['posts'] as $post) { $item = []; diff --git a/bridges/EtsyBridge.php b/bridges/EtsyBridge.php index 493dd236..f9e2b4cb 100644 --- a/bridges/EtsyBridge.php +++ b/bridges/EtsyBridge.php @@ -47,7 +47,7 @@ class EtsyBridge extends BridgeAbstract $item['title'] = $result->find('a', 0)->title; $item['uri'] = $result->find('a', 0)->href; - $item['author'] = $result->find('p.wt-text-gray > span', 2)->plaintext; + $item['author'] = $result->find('p.wt-text-gray > span', 2)->plaintext ?? ''; $item['content'] = '
' . ($result->find('span.currency-symbol', 0)->plaintext ?? '') diff --git a/bridges/SoundcloudBridge.php b/bridges/SoundcloudBridge.php index 9fdf74d4..0bd9a2b0 100644 --- a/bridges/SoundcloudBridge.php +++ b/bridges/SoundcloudBridge.php @@ -66,8 +66,7 @@ class SoundCloudBridge extends BridgeAbstract $item['author'] = $apiItem->user->username; $item['title'] = $apiItem->user->username . ' - ' . $apiItem->title; $item['timestamp'] = strtotime($apiItem->created_at); - - $description = nl2br($apiItem->description); + $description = nl2br($apiItem->description ?? ''); $item['content'] = <<{$description}
diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 50acf697..54a38d98 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -233,7 +233,11 @@ class YoutubeBridge extends BridgeAbstract private function getJSONData($html) { $scriptRegex = '/var ytInitialData = (.*?);<\/script>/'; - preg_match($scriptRegex, $html, $matches) or returnServerError('Could not find ytInitialData'); + $result = preg_match($scriptRegex, $html, $matches); + if (! $result) { + Logger::debug('Could not find ytInitialData'); + return null; + } return json_decode($matches[1]); } @@ -292,15 +296,17 @@ class YoutubeBridge extends BridgeAbstract } } - if (preg_match('/([\d]{1,2})\:([\d]{1,2})\:([\d]{2})/', $durationText)) { - $durationText = preg_replace('/([\d]{1,2})\:([\d]{1,2})\:([\d]{2})/', '$1:$2:$3', $durationText); - } else { - $durationText = preg_replace('/([\d]{1,2})\:([\d]{2})/', '00:$1:$2', $durationText); - } - sscanf($durationText, '%d:%d:%d', $hours, $minutes, $seconds); - $duration = $hours * 3600 + $minutes * 60 + $seconds; - if ($duration < $duration_min || $duration > $duration_max) { - continue; + if (is_string($durationText)) { + if (preg_match('/([\d]{1,2})\:([\d]{1,2})\:([\d]{2})/', $durationText)) { + $durationText = preg_replace('/([\d]{1,2})\:([\d]{1,2})\:([\d]{2})/', '$1:$2:$3', $durationText); + } else { + $durationText = preg_replace('/([\d]{1,2})\:([\d]{2})/', '00:$1:$2', $durationText); + } + sscanf($durationText, '%d:%d:%d', $hours, $minutes, $seconds); + $duration = $hours * 3600 + $minutes * 60 + $seconds; + if ($duration < $duration_min || $duration > $duration_max) { + continue; + } } // $vid_list .= $vid . ','; diff --git a/lib/Logger.php b/lib/Logger.php index b97de978..91b8e3c1 100644 --- a/lib/Logger.php +++ b/lib/Logger.php @@ -55,6 +55,8 @@ final class Logger 'Unable to find channel. The channel is non-existing or non-public', // fb 'This group is not public! RSS-Bridge only supports public groups!', + // tiktok 404 + 'https://www.tiktok.com/@', ]; foreach ($ignoredExceptions as $ignoredException) { if (str_starts_with($e->getMessage(), $ignoredException)) {