mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-23 08:33:24 +02:00
refactor: logger (#3678)
This commit is contained in:
@@ -48,7 +48,6 @@ class EZTVBridge extends BridgeAbstract
|
||||
public function collectData()
|
||||
{
|
||||
$eztv_uri = $this->getEztvUri();
|
||||
Logger::debug($eztv_uri);
|
||||
$ids = explode(',', trim($this->getInput('ids')));
|
||||
foreach ($ids as $id) {
|
||||
$data = json_decode(getContents(sprintf('%s/api/get-torrents?imdb_id=%s', $eztv_uri, $id)));
|
||||
|
@@ -113,15 +113,14 @@ class ElloBridge extends BridgeAbstract
|
||||
|
||||
private function getAPIKey()
|
||||
{
|
||||
$cache = RssBridge::getCache();
|
||||
$cacheKey = 'ElloBridge_key';
|
||||
$apiKey = $cache->get($cacheKey);
|
||||
$apiKey = $this->cache->get($cacheKey);
|
||||
|
||||
if (!$apiKey) {
|
||||
$keyInfo = getContents(self::URI . 'api/webapp-token') or returnServerError('Unable to get token.');
|
||||
$apiKey = json_decode($keyInfo)->token->access_token;
|
||||
$ttl = 60 * 60 * 20;
|
||||
$cache->set($cacheKey, $apiKey, $ttl);
|
||||
$this->cache->set($cacheKey, $apiKey, $ttl);
|
||||
}
|
||||
|
||||
return $apiKey;
|
||||
|
@@ -63,7 +63,7 @@ TEXT;
|
||||
try {
|
||||
$this->collectExpandableDatas($feed);
|
||||
} catch (HttpException $e) {
|
||||
Logger::warning(sprintf('Exception in FeedMergeBridge: %s', create_sane_exception_message($e)));
|
||||
$this->logger->warning(sprintf('Exception in FeedMergeBridge: %s', create_sane_exception_message($e)));
|
||||
$this->items[] = [
|
||||
'title' => 'RSS-Bridge: ' . $e->getMessage(),
|
||||
// Give current time so it sorts to the top
|
||||
@@ -73,7 +73,7 @@ TEXT;
|
||||
} catch (\Exception $e) {
|
||||
if (str_starts_with($e->getMessage(), 'Unable to parse xml')) {
|
||||
// Allow this particular exception from FeedExpander
|
||||
Logger::warning(sprintf('Exception in FeedMergeBridge: %s', create_sane_exception_message($e)));
|
||||
$this->logger->warning(sprintf('Exception in FeedMergeBridge: %s', create_sane_exception_message($e)));
|
||||
continue;
|
||||
}
|
||||
throw $e;
|
||||
|
@@ -217,7 +217,7 @@ HTML,
|
||||
if ($relativeDate) {
|
||||
date_sub($date, $relativeDate);
|
||||
} else {
|
||||
Logger::info(sprintf('Unable to parse date string: %s', $dateString));
|
||||
$this->logger->info(sprintf('Unable to parse date string: %s', $dateString));
|
||||
}
|
||||
return date_format($date, 'r');
|
||||
}
|
||||
|
@@ -98,9 +98,8 @@ class InstagramBridge extends BridgeAbstract
|
||||
return $username;
|
||||
}
|
||||
|
||||
$cache = RssBridge::getCache();
|
||||
$cacheKey = 'InstagramBridge_' . $username;
|
||||
$pk = $cache->get($cacheKey);
|
||||
$pk = $this->cache->get($cacheKey);
|
||||
|
||||
if (!$pk) {
|
||||
$data = $this->getContents(self::URI . 'web/search/topsearch/?query=' . $username);
|
||||
@@ -112,7 +111,7 @@ class InstagramBridge extends BridgeAbstract
|
||||
if (!$pk) {
|
||||
returnServerError('Unable to find username in search result.');
|
||||
}
|
||||
$cache->set($cacheKey, $pk);
|
||||
$this->cache->set($cacheKey, $pk);
|
||||
}
|
||||
return $pk;
|
||||
}
|
||||
|
@@ -72,12 +72,6 @@ class RedditBridge extends BridgeAbstract
|
||||
]
|
||||
]
|
||||
];
|
||||
private CacheInterface $cache;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->cache = RssBridge::getCache();
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
|
@@ -36,15 +36,12 @@ class SoundCloudBridge extends BridgeAbstract
|
||||
|
||||
private $feedTitle = null;
|
||||
private $feedIcon = null;
|
||||
private CacheInterface $cache;
|
||||
|
||||
private $clientIdRegex = '/client_id.*?"(.+?)"/';
|
||||
private $widgetRegex = '/widget-.+?\.js/';
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$this->cache = RssBridge::getCache();
|
||||
|
||||
$res = $this->getUser($this->getInput('u'));
|
||||
|
||||
$this->feedTitle = $res->username;
|
||||
|
@@ -278,10 +278,9 @@ class SpotifyBridge extends BridgeAbstract
|
||||
|
||||
private function fetchAccessToken()
|
||||
{
|
||||
$cache = RssBridge::getCache();
|
||||
$cacheKey = sprintf('SpotifyBridge:%s:%s', $this->getInput('clientid'), $this->getInput('clientsecret'));
|
||||
|
||||
$token = $cache->get($cacheKey);
|
||||
$token = $this->cache->get($cacheKey);
|
||||
if ($token) {
|
||||
$this->token = $token;
|
||||
} else {
|
||||
@@ -294,7 +293,7 @@ class SpotifyBridge extends BridgeAbstract
|
||||
$data = Json::decode($json);
|
||||
$this->token = $data['access_token'];
|
||||
|
||||
$cache->set($cacheKey, $this->token, 3600);
|
||||
$this->cache->set($cacheKey, $this->token, 3600);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -234,8 +234,7 @@ EOD
|
||||
$tweets = [];
|
||||
|
||||
// Get authentication information
|
||||
$cache = RssBridge::getCache();
|
||||
$api = new TwitterClient($cache);
|
||||
$api = new TwitterClient($this->cache);
|
||||
// Try to get all tweets
|
||||
switch ($this->queriedContext) {
|
||||
case 'By username':
|
||||
|
@@ -77,12 +77,6 @@ class YoutubeBridge extends BridgeAbstract
|
||||
private $channel_name = '';
|
||||
// This took from repo BetterVideoRss of VerifiedJoseph.
|
||||
const URI_REGEX = '/(https?:\/\/(?:www\.)?(?:[a-zA-Z0-9-.]{2,256}\.[a-z]{2,20})(\:[0-9]{2 ,4})?(?:\/[a-zA-Z0-9@:%_\+.,~#"\'!?&\/\/=\-*]+|\/)?)/ims'; //phpcs:ignore
|
||||
private CacheInterface $cache;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->cache = RssBridge::getCache();
|
||||
}
|
||||
|
||||
private function collectDataInternal()
|
||||
{
|
||||
@@ -368,7 +362,7 @@ class YoutubeBridge extends BridgeAbstract
|
||||
$scriptRegex = '/var ytInitialData = (.*?);<\/script>/';
|
||||
$result = preg_match($scriptRegex, $html, $matches);
|
||||
if (! $result) {
|
||||
Logger::debug('Could not find ytInitialData');
|
||||
$this->logger->debug('Could not find ytInitialData');
|
||||
return null;
|
||||
}
|
||||
return json_decode($matches[1]);
|
||||
|
@@ -180,13 +180,13 @@ class ZDNetBridge extends FeedExpander
|
||||
|
||||
$article = getSimpleHTMLDOMCached($item['uri']);
|
||||
if (!$article) {
|
||||
Logger::info('Unable to parse the dom from ' . $item['uri']);
|
||||
$this->logger->info('Unable to parse the dom from ' . $item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
$articleTag = $article->find('article', 0) ?? $article->find('.c-articleContent', 0);
|
||||
if (!$articleTag) {
|
||||
Logger::info('Unable to parse <article> tag in ' . $item['uri']);
|
||||
$this->logger->info('Unable to parse <article> tag in ' . $item['uri']);
|
||||
return $item;
|
||||
}
|
||||
$contents = $articleTag->innertext;
|
||||
|
Reference in New Issue
Block a user