mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-20 23:31:37 +02:00
refactor: drop usage of Debug::log (#4202)
* refactor: drop usage of Debug::log * lint
This commit is contained in:
@@ -45,7 +45,6 @@ class AsahiShimbunAJWBridge extends BridgeAbstract
|
||||
|
||||
foreach ($html->find('#MainInner li a') as $element) {
|
||||
if ($element->parent()->class == 'HeadlineTopImage-S') {
|
||||
Debug::log('Skip Headline, it is repeated below');
|
||||
continue;
|
||||
}
|
||||
$item = [];
|
||||
|
@@ -27,11 +27,6 @@ class DagensNyheterDirektBridge extends BridgeAbstract
|
||||
$url = self::BASEURL . $link;
|
||||
$title = $element->find('h2', 0)->plaintext;
|
||||
$author = $element->find('div.ds-byline__titles', 0)->plaintext;
|
||||
// Debug::log($link);
|
||||
// Debug::log($datetime);
|
||||
// Debug::log($title);
|
||||
// Debug::log($url);
|
||||
// Debug::log($author);
|
||||
|
||||
$article_content = $element->find('div.direkt-post__content', 0);
|
||||
$article_html = '';
|
||||
|
@@ -187,7 +187,6 @@ class FicbookBridge extends BridgeAbstract
|
||||
$fixed_date = str_replace(' г.', '', $fixed_date);
|
||||
|
||||
if ($fixed_date === $date) {
|
||||
Debug::log('Unable to fix date: ' . $date);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -44,8 +44,6 @@ class FolhaDeSaoPauloBridge extends FeedExpander
|
||||
$item['content'] = $text;
|
||||
$item['uri'] = explode('*', $item['uri'])[1];
|
||||
}
|
||||
} else {
|
||||
Debug::log('???: ' . $item['uri']);
|
||||
}
|
||||
} else {
|
||||
$item['uri'] = explode('*', $item['uri'])[1];
|
||||
@@ -58,13 +56,11 @@ class FolhaDeSaoPauloBridge extends FeedExpander
|
||||
{
|
||||
$feed_input = $this->getInput('feed');
|
||||
if (substr($feed_input, 0, strlen(self::URI)) === self::URI) {
|
||||
Debug::log('Input:: ' . $feed_input);
|
||||
$feed_url = $feed_input;
|
||||
} else {
|
||||
/* TODO: prepend `/` if missing */
|
||||
$feed_url = self::URI . '/' . $this->getInput('feed');
|
||||
}
|
||||
Debug::log('URL: ' . $feed_url);
|
||||
$limit = $this->getInput('amount');
|
||||
$this->collectExpandableDatas($feed_url, $limit);
|
||||
}
|
||||
|
@@ -21,8 +21,6 @@ class HackerNewsUserThreadsBridge extends BridgeAbstract
|
||||
{
|
||||
$url = 'https://news.ycombinator.com/threads?id=' . $this->getInput('user');
|
||||
$html = getSimpleHTMLDOM($url);
|
||||
Debug::log('queried ' . $url);
|
||||
Debug::log('found ' . $html);
|
||||
|
||||
$item = [];
|
||||
$articles = $html->find('tr[class*="comtr"]');
|
||||
|
@@ -522,7 +522,7 @@ class ItakuBridge extends BridgeAbstract
|
||||
{
|
||||
$url = self::URI . '/api/commissions/' . $id . '/?format=json';
|
||||
$uri = self::URI . '/commissions/' . $id;
|
||||
// Debug::log(var_dump($metadata));
|
||||
|
||||
$data = $metadata ?? $this->getData($url, true, true)
|
||||
or returnServerError("Could not load $url");
|
||||
|
||||
@@ -664,7 +664,6 @@ class ItakuBridge extends BridgeAbstract
|
||||
|
||||
private function getData(string $url, bool $cache = false, bool $getJSON = false, array $httpHeaders = [], array $curlOptions = [])
|
||||
{
|
||||
// Debug::log($url);
|
||||
if ($getJSON) { //get JSON object
|
||||
if ($cache) {
|
||||
$data = $this->loadCacheValue($url);
|
||||
|
@@ -138,8 +138,6 @@ class JustETFBridge extends BridgeAbstract
|
||||
|
||||
date_time_set($df, 0, 0);
|
||||
|
||||
// Debug::log(date_format($df, 'U'));
|
||||
|
||||
return date_format($df, 'U');
|
||||
}
|
||||
|
||||
@@ -216,8 +214,6 @@ class JustETFBridge extends BridgeAbstract
|
||||
$element = $article->find('div.subheadline', 0)
|
||||
or returnServerError('Date not found!');
|
||||
|
||||
// Debug::log($element->plaintext);
|
||||
|
||||
$date = trim(explode('|', $element->plaintext)[0]);
|
||||
|
||||
return $this->fixDate($date);
|
||||
@@ -230,8 +226,6 @@ class JustETFBridge extends BridgeAbstract
|
||||
|
||||
$element->find('a', 0)->onclick = '';
|
||||
|
||||
// Debug::log($element->innertext);
|
||||
|
||||
return $element->innertext;
|
||||
}
|
||||
|
||||
@@ -300,8 +294,6 @@ class JustETFBridge extends BridgeAbstract
|
||||
$element = $html->find('div.infobox div.vallabel', 0)
|
||||
or returnServerError('Date not found!');
|
||||
|
||||
// Debug::log($element->plaintext);
|
||||
|
||||
$date = trim(explode("\r\n", $element->plaintext)[1]);
|
||||
|
||||
return $this->fixDate($date);
|
||||
|
@@ -275,11 +275,13 @@ class MastodonBridge extends BridgeAbstract
|
||||
$toSign = '(request-target): get ' . $matches[2] . "\nhost: " . $matches[1] . "\ndate: " . $date;
|
||||
$result = openssl_sign($toSign, $signature, $pkey, 'RSA-SHA256');
|
||||
if ($result) {
|
||||
Debug::log($toSign);
|
||||
$sig = 'Signature: keyId="' . $keyId . '",headers="(request-target) host date",signature="' .
|
||||
base64_encode($signature) . '"';
|
||||
Debug::log($sig);
|
||||
array_push($headers, $sig);
|
||||
$sig = sprintf(
|
||||
'Signature: keyId="%s",headers="(request-target) host date",signature="%s"',
|
||||
$keyId,
|
||||
base64_encode($signature)
|
||||
);
|
||||
|
||||
$headers[] = $sig;
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
@@ -38,7 +38,7 @@ class PanacheDigitalGamesBridge extends BridgeAbstract
|
||||
$image_html = $element->find('.news-item-thumbnail-image', 0);
|
||||
if ($image_html) {
|
||||
$image_strings = explode('\'', $image_html);
|
||||
/* Debug::log('S: ' . count($image_strings) . '||' . implode('_ _', $image_strings)); */
|
||||
|
||||
if (count($image_strings) == 4) {
|
||||
$item['content'] = '<img src="' . $image_strings[1] . '" />';
|
||||
}
|
||||
|
@@ -55,7 +55,6 @@ class PresidenciaPTBridge extends BridgeAbstract
|
||||
$contexts = $this->getParameters();
|
||||
|
||||
foreach (array_keys($contexts['Section']) as $k) {
|
||||
Debug::log('Key: ' . var_export($k, true));
|
||||
if ($this->getInput($k)) {
|
||||
$html = getSimpleHTMLDOMCached($this->getURI() . $k);
|
||||
|
||||
|
@@ -118,13 +118,8 @@ class SlusheBridge extends BridgeAbstract
|
||||
|
||||
$html = getSimpleHTMLDOM($uri, $headers);
|
||||
|
||||
//Debug::log($html);
|
||||
//Debug::log($html->find('div.blog-item')[0]);
|
||||
|
||||
//Loop on each entry
|
||||
foreach ($html->find('div.blog-item') as $element) {
|
||||
//Debug::log($element);
|
||||
|
||||
$title = $element->find('h3.title', 0)->first_child()->innertext;
|
||||
$article_uri = $element->find('h3.title', 0)->first_child()->href;
|
||||
$timestamp = $element->find('div.publication-date', 0)->innertext;
|
||||
@@ -153,7 +148,6 @@ class SlusheBridge extends BridgeAbstract
|
||||
// Add image thumbnail(s)
|
||||
foreach ($media_uris->find('img') as $media_uri) {
|
||||
$media_html .= '<a href="' . $article_uri . '">' . $media_uri . '</a>';
|
||||
//Debug::log('Adding to enclosures: ' . str_replace(' ', '%20', $media_uri->src));
|
||||
$item['enclosures'][] = str_replace(' ', '%20', $media_uri->src);
|
||||
}
|
||||
}
|
||||
@@ -165,7 +159,7 @@ class SlusheBridge extends BridgeAbstract
|
||||
foreach ($media_uris->find('img') as $media_uri) {
|
||||
$media_html .= '<p>Video:</p><a href="' .
|
||||
$article_uri . '">' . $media_uri . '</a>';
|
||||
//Debug::log('Adding to enclosures: ' . $media_uri->src);
|
||||
|
||||
$item['enclosures'][] = $media_uri->src;
|
||||
}
|
||||
}
|
||||
|
@@ -70,9 +70,9 @@ class ThreadsBridge extends BridgeAbstract
|
||||
public function collectData()
|
||||
{
|
||||
$html = getSimpleHTMLDOMCached($this->getURI(), static::CACHE_TIMEOUT);
|
||||
Debug::log(sprintf('Fetched: %s', $this->getURI()));
|
||||
|
||||
$jsonBlobs = $html->find('script[type="application/json"]');
|
||||
Debug::log(sprintf('%d JSON blobs found.', count($jsonBlobs)));
|
||||
|
||||
$gatheredCodes = [];
|
||||
$limit = $this->getInput('limit');
|
||||
foreach ($jsonBlobs as $jsonBlob) {
|
||||
@@ -87,7 +87,6 @@ class ThreadsBridge extends BridgeAbstract
|
||||
}
|
||||
}
|
||||
}
|
||||
Debug::log(sprintf('Candidate codes found in JSON in script tags: %s', print_r($gatheredCodes, true)));
|
||||
|
||||
$this->feedName = html_entity_decode($html->find('meta[property=og:title]', 0)->content);
|
||||
// todo: meta[property=og:description] could populate the feed description
|
||||
|
@@ -541,7 +541,7 @@ EOD;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug::log('Missing support for media type: ' . $media->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -192,7 +192,6 @@ EOD
|
||||
. $this->getInput('u'), $authHeaders, $params);
|
||||
|
||||
if (isset($user->errors)) {
|
||||
Debug::log('User JSON: ' . json_encode($user));
|
||||
returnServerError('Requested username can\'t be found.');
|
||||
}
|
||||
|
||||
@@ -266,7 +265,6 @@ EOD
|
||||
(isset($data->errors) && !isset($data->data)) ||
|
||||
(isset($data->meta) && $data->meta->result_count === 0)
|
||||
) {
|
||||
Debug::log('Data JSON: ' . json_encode($data));
|
||||
switch ($this->queriedContext) {
|
||||
case 'By keyword or hashtag':
|
||||
returnServerError('No results for this query.');
|
||||
@@ -311,7 +309,6 @@ EOD
|
||||
foreach ($includesTweets as $includesTweet) {
|
||||
$includesTweetsIds[] = $includesTweet->id;
|
||||
}
|
||||
Debug::log('includesTweetsIds: ' . join(',', $includesTweetsIds));
|
||||
|
||||
// Set default params for API query
|
||||
$params = [
|
||||
@@ -336,8 +333,6 @@ EOD
|
||||
|
||||
// Create output array with all required elements for each tweet
|
||||
foreach ($tweets as $tweet) {
|
||||
//Debug::log('Tweet JSON: ' . json_encode($tweet));
|
||||
|
||||
// Skip pinned tweet (if selected)
|
||||
if ($hidePinned && $tweet->id === $pinnedTweetId) {
|
||||
continue;
|
||||
@@ -376,12 +371,10 @@ EOD
|
||||
$cleanedQuotedTweet = null;
|
||||
$quotedUser = null;
|
||||
if ($isQuote) {
|
||||
Debug::log('Tweet is quote');
|
||||
foreach ($includesTweets as $includesTweet) {
|
||||
if ($includesTweet->id === $tweet->referenced_tweets[0]->id) {
|
||||
$quotedTweet = $includesTweet;
|
||||
$cleanedQuotedTweet = nl2br($quotedTweet->text);
|
||||
//Debug::log('Found quoted tweet');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -389,7 +382,6 @@ EOD
|
||||
$quotedUser = $this->getTweetUser($quotedTweet, $retweetedUsers, $includesUsers);
|
||||
}
|
||||
if ($isRetweet || is_null($user)) {
|
||||
Debug::log('Tweet is retweet, or $user is null');
|
||||
// Replace tweet object with original retweeted object
|
||||
if ($isRetweet) {
|
||||
foreach ($includesTweets as $includesTweet) {
|
||||
@@ -430,7 +422,6 @@ EOD
|
||||
. $this->item['username'] . ')';
|
||||
|
||||
$cleanedTweet = nl2br($tweet->text);
|
||||
//Debug::log('cleanedTweet: ' . $cleanedTweet);
|
||||
|
||||
// Perform optional keyword filtering (only keep tweet if keyword is found)
|
||||
if (! empty($tweetFilter)) {
|
||||
@@ -452,7 +443,6 @@ EOD
|
||||
// Search for and replace URLs in Tweet text
|
||||
$cleanedTweet = $this->replaceTweetURLs($tweet, $cleanedTweet);
|
||||
if (isset($cleanedQuotedTweet)) {
|
||||
Debug::log('Replacing URLs in Quoted Tweet text');
|
||||
$cleanedQuotedTweet = $this->replaceTweetURLs($quotedTweet, $cleanedQuotedTweet);
|
||||
}
|
||||
|
||||
@@ -478,9 +468,7 @@ EOD
|
||||
// Get external link info
|
||||
$extURL = null;
|
||||
if (isset($tweet->entities->urls) && strpos($tweet->entities->urls[0]->expanded_url, 'twitter.com') === false) {
|
||||
Debug::log('Found an external link!');
|
||||
$extURL = $tweet->entities->urls[0]->expanded_url;
|
||||
Debug::log($extURL);
|
||||
$extDisplayURL = $tweet->entities->urls[0]->display_url;
|
||||
$extTitle = $tweet->entities->urls[0]->title;
|
||||
$extDesc = $tweet->entities->urls[0]->description;
|
||||
@@ -513,15 +501,12 @@ EOD;
|
||||
$ext_media_html = '';
|
||||
if (!$hideImages) {
|
||||
if (isset($tweet->attachments->media_keys)) {
|
||||
Debug::log('Generating HTML for tweet media');
|
||||
$media_html = $this->createTweetMediaHTML($tweet, $includesMedia, $retweetedMedia);
|
||||
}
|
||||
if (isset($quotedTweet->attachments->media_keys)) {
|
||||
Debug::log('Generating HTML for quoted tweet media');
|
||||
$quoted_media_html = $this->createTweetMediaHTML($quotedTweet, $includesMedia, $retweetedMedia);
|
||||
}
|
||||
if (isset($extURL)) {
|
||||
Debug::log('Generating HTML for external link media');
|
||||
if ($this->getInput('noimgscaling')) {
|
||||
$extMediaURL = $extMediaOrig;
|
||||
} else {
|
||||
@@ -562,7 +547,6 @@ QUOTE;
|
||||
|
||||
// Add External Link HTML, if relevant
|
||||
if (isset($extURL) && !$this->getInput('noexternallink')) {
|
||||
Debug::log('Adding HTML for external link');
|
||||
$ext_html = <<<EXTERNAL
|
||||
<div style="display: table; border-style: solid; border-width: 1px; border-radius: 5px; padding: 5px;">
|
||||
$ext_media_html<br>
|
||||
@@ -653,21 +637,18 @@ EXTERNAL;
|
||||
{
|
||||
$originalUser = new stdClass(); // make the linters stop complaining
|
||||
if (isset($retweetedUsers)) {
|
||||
Debug::log('Searching for tweet author_id in $retweetedUsers');
|
||||
foreach ($retweetedUsers as $retweetedUser) {
|
||||
if ($retweetedUser->id === $tweetObject->author_id) {
|
||||
$matchedUser = $retweetedUser;
|
||||
Debug::log('Found author_id match in $retweetedUsers');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($matchedUser->username) && isset($includesUsers)) {
|
||||
Debug::log('Searching for tweet author_id in $includesUsers');
|
||||
foreach ($includesUsers as $includesUser) {
|
||||
if ($includesUser->id === $tweetObject->author_id) {
|
||||
$matchedUser = $includesUser;
|
||||
Debug::log('Found author_id match in $includesUsers');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -689,7 +670,6 @@ EXTERNAL;
|
||||
$tweetMedia = [];
|
||||
// Start by checking the original list of tweet Media includes
|
||||
if (isset($includesMedia)) {
|
||||
Debug::log('Searching for media_key in $includesMedia');
|
||||
foreach ($includesMedia as $includesMedium) {
|
||||
if (
|
||||
in_array(
|
||||
@@ -697,14 +677,12 @@ EXTERNAL;
|
||||
$tweetObject->attachments->media_keys
|
||||
)
|
||||
) {
|
||||
Debug::log('Found media_key in $includesMedia');
|
||||
$tweetMedia[] = $includesMedium;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If no matches found, check the retweet Media includes
|
||||
if (empty($tweetMedia) && isset($retweetedMedia)) {
|
||||
Debug::log('Searching for media_key in $retweetedMedia');
|
||||
foreach ($retweetedMedia as $retweetedMedium) {
|
||||
if (
|
||||
in_array(
|
||||
@@ -712,7 +690,6 @@ EXTERNAL;
|
||||
$tweetObject->attachments->media_keys
|
||||
)
|
||||
) {
|
||||
Debug::log('Found media_key in $retweetedMedia');
|
||||
$tweetMedia[] = $retweetedMedium;
|
||||
}
|
||||
}
|
||||
@@ -760,8 +737,7 @@ EOD;
|
||||
EOD;
|
||||
break;
|
||||
default:
|
||||
Debug::log('Missing support for media type: '
|
||||
. $media->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,14 +14,12 @@ class UnraidCommunityApplicationsBridge extends BridgeAbstract
|
||||
|
||||
private function fetchApps()
|
||||
{
|
||||
Debug::log('Fetching all applications/plugins');
|
||||
$this->apps = getContents(self::APPSURI);
|
||||
$this->apps = json_decode($this->apps, true)['applist'];
|
||||
}
|
||||
|
||||
private function sortApps()
|
||||
{
|
||||
Debug::log('Sorting applications/plugins');
|
||||
usort($this->apps, function ($app1, $app2) {
|
||||
return $app1['FirstSeen'] < $app2['FirstSeen'] ? 1 : -1;
|
||||
});
|
||||
|
@@ -436,8 +436,6 @@ class XenForoBridge extends BridgeAbstract
|
||||
break;
|
||||
}
|
||||
|
||||
// Debug::log(date_format($df, 'U'));
|
||||
|
||||
return date_format($df, 'U');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user