1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-01-16 21:58:21 +01:00

fix: various small notice fixes (#3474)

* fix(patreon): php notice

* fix(pepperbridge): php notice

* fix(ebay): php notice

* fix(tiktok): php notice

* fix(yandex): fix notice

* fix(justwatch): notice

* lint
This commit is contained in:
Dag 2023-07-02 06:40:25 +02:00 committed by GitHub
parent 372880b5ef
commit 748fc9fd65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 50 additions and 25 deletions

View File

@ -84,7 +84,12 @@ class EBayBridge extends BridgeAbstract
$sellerInfo = $listing->find('.s-item__seller-info-text', 0)->plaintext ?? '';
$item['enclosures'] = [ $listing->find('.s-item__image-wrapper > img', 0)->src . '#.image' ];
$image = $listing->find('.s-item__image-wrapper > img', 0);
if ($image) {
// Not quite sure why append fragment here
$imageUrl = $image->src . '#.image';
$item['enclosures'] = [$imageUrl];
}
$item['content'] = <<<CONTENT
<p>$sellerInfo $location</p>

View File

@ -169,10 +169,17 @@ class JustWatchBridge extends BridgeAbstract
foreach ($titles as $title) {
$item = [];
$item['uri'] = $title->find('a', 0)->href;
$item['title'] = $provider->find('picture > img', 0)->alt . ' - ' . $title->find('.title-poster__image > img', 0)->alt;
$image = $title->find('.title-poster__image > img', 0)->attr['src'];
if (str_starts_with($image, 'data')) {
$image = $title->find('.title-poster__image > img', 0)->attr['data-src'];
$itemTitle = sprintf(
'%s - %s',
$provider->find('picture > img', 0)->alt ?? '',
$title->find('.title-poster__image > img', 0)->alt ?? ''
);
$item['title'] = $itemTitle;
$imageUrl = $title->find('.title-poster__image > img', 0)->attr['src'] ?? '';
if (str_starts_with($imageUrl, 'data')) {
$imageUrl = $title->find('.title-poster__image > img', 0)->attr['data-src'];
}
$content = '<b>Provider:</b> '
@ -190,7 +197,7 @@ class JustWatchBridge extends BridgeAbstract
$content .= '<b>Poster:</b><br><a href="'
. $title->find('a', 0)->href
. '"><img src="'
. $image
. $imageUrl
. '"></a>';
$item['content'] = $content;

View File

@ -100,12 +100,14 @@ class PatreonBridge extends BridgeAbstract
);
$item['author'] = $user->full_name;
if (isset($post->attributes->image)) {
$item['content'] .= '<p><a href="'
. $post->attributes->url
. '"><img src="'
. $post->attributes->image->thumb_url
. '" /></a></p>';
$image = $post->attributes->image ?? null;
if ($image) {
$logo = sprintf(
'<p><a href="%s"><img src="%s" /></a></p>',
$post->attributes->url,
$image->thumb_url ?? $image->url ?? $this->getURI()
);
$item['content'] .= $logo;
}
if (isset($post->attributes->content)) {

View File

@ -129,7 +129,7 @@ class PepperBridgeAbstract extends BridgeAbstract
// Find the text corresponding to the clock
$spanDateDiv = $clock->parent()->find('span[class=hide--toW3]', 0);
$itemDate = $spanDateDiv->plaintext;
$itemDate = $spanDateDiv->plaintext ?? '';
// In case of a Local deal, there is no date, but we can use
// this case for other reason (like date not in the last field)
if ($this->contains($itemDate, $this->i8n('localdeal'))) {
@ -481,12 +481,12 @@ HEREDOC;
]
);
if ($deal->find('span[class*=' . $selector . ']', 0) != null) {
return '<div>'
. $deal->find('span[class*=' . $selector . ']', 0)->children(2)->plaintext
. '</div>';
} else {
return '';
$children = $deal->find('span[class*=' . $selector . ']', 0)->children(2);
if ($children) {
return '<div>' . $children->plaintext . '</div>';
}
}
return '';
}
/**

View File

@ -53,7 +53,13 @@ class TikTokBridge extends BridgeAbstract
$views = $div->find('strong.video-count', 0)->plaintext;
$item['uri'] = $link;
$item['title'] = $div->find('a', 1)->plaintext;
$a = $div->find('a', 1);
if ($a) {
$item['title'] = $a->plaintext;
} else {
$item['title'] = $this->getName();
}
$item['enclosures'][] = $image;
$item['content'] = <<<EOD

View File

@ -39,7 +39,12 @@ class YandexZenBridge extends BridgeAbstract
$item['uri'] = $post->share_link;
$item['title'] = $post->title;
$item['timestamp'] = date(DateTimeInterface::ATOM, $post->publication_date);
$publicationDateUnixTimestamp = $post->publication_date ?? null;
if ($publicationDateUnixTimestamp) {
$item['timestamp'] = date(DateTimeInterface::ATOM, $publicationDateUnixTimestamp);
}
$item['content'] = $post->text;
$item['enclosures'] = [
$post->image,

View File

@ -316,7 +316,9 @@ abstract class BridgeAbstract implements BridgeInterface
}
$needle = $this->inputs[$this->queriedContext][$input]['value'];
foreach (static::PARAMETERS[$context][$input]['values'] as $first_level_key => $first_level_value) {
if ($needle === (string)$first_level_value) {
// todo: this cast emits error if it's an array
$valueString = (string) $first_level_value;
if ($needle === $valueString) {
return $first_level_key;
} elseif (is_array($first_level_value)) {
foreach ($first_level_value as $second_level_key => $second_level_value) {

View File

@ -43,6 +43,7 @@ final class Logger
$context['url'] = get_current_url();
$context['trace'] = trace_to_call_points(trace_from_exception($e));
// Don't log these exceptions
// todo: this logic belongs in log handler
$ignoredExceptions = [
'You must specify a format',
'Format name invalid',

View File

@ -420,14 +420,11 @@ function getSimpleHTMLDOMCached(
$defaultBRText = DEFAULT_BR_TEXT,
$defaultSpanText = DEFAULT_SPAN_TEXT
) {
Logger::debug(sprintf('Caching url %s, duration %d', $url, $duration));
// Initialize cache
$cacheFactory = new CacheFactory();
$cache = $cacheFactory->create();
$cache->setScope('pages');
$cache->purgeCache(86400); // 24 hours (forced)
$cache->purgeCache(86400);
$params = [$url];
$cache->setKey($params);