mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 06:08:27 +01:00
* [CssSelectorFeedExpander] Fix ArgumentCountError (#3739) Fix ArgumentCountError (#3739) using new FeedParser class (#3740) Implement default value for feed name / url if missing * [CssSelectorFeedExpander] Skip empty fields in source feed Fix empty feed properties being passed down from source feed rssbridge.DEBUG lib/FeedItem.php(177): Author must be a string! rssbridge.DEBUG lib/FeedItem.php(267): Unique id must be a string! If "don't expand metadata" is checked, then source feed is passed down verbatim (only content is expanded) so the debug messages will persist, but the issue is in source feed, not in the bridge.
This commit is contained in:
parent
920d00480d
commit
fd52b9b9a4
@ -1,16 +1,5 @@
|
||||
<?php
|
||||
|
||||
if (!class_exists('CssSelectorFeedExpanderBridgeInternal')) {
|
||||
// Utility class used internally by CssSelectorFeedExpanderBridge
|
||||
class CssSelectorFeedExpanderBridgeInternal extends FeedExpander
|
||||
{
|
||||
public function collectData()
|
||||
{
|
||||
// Unused. Call collectExpandableDatas($url) inherited from FeedExpander instead
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CssSelectorFeedExpanderBridge extends CssSelectorBridge
|
||||
{
|
||||
const MAINTAINER = 'ORelio';
|
||||
@ -61,16 +50,29 @@ class CssSelectorFeedExpanderBridge extends CssSelectorBridge
|
||||
$discard_thumbnail = $this->getInput('discard_thumbnail');
|
||||
$limit = $this->getInput('limit');
|
||||
|
||||
//$xmlString = getContents($url);
|
||||
//$feed = (new FeedParser())->parseFeed($xmlString);
|
||||
//$items = $feed['items'];
|
||||
$source_feed = (new FeedParser())->parseFeed(getContents($url));
|
||||
$items = $source_feed['items'];
|
||||
|
||||
$feed_expander = new CssSelectorFeedExpanderBridgeInternal();
|
||||
$items = $feed_expander->collectExpandableDatas($url)->getItems();
|
||||
// Map Homepage URL (Default: Root page)
|
||||
if (isset($source_feed['uri'])) {
|
||||
$this->homepageUrl = $source_feed['uri'];
|
||||
} else {
|
||||
$this->homepageUrl = urljoin($url, '/');
|
||||
}
|
||||
|
||||
$this->homepageUrl = urljoin($url, '/');
|
||||
$this->feedName = $feed_expander->getName();
|
||||
// Map Feed Name (Default: Domain name)
|
||||
if (isset($source_feed['title'])) {
|
||||
$this->feedName = $source_feed['title'];
|
||||
} else {
|
||||
$this->feedName = explode('/', urljoin($url, '/'))[2];
|
||||
}
|
||||
|
||||
// Apply item limit (Default: Global limit)
|
||||
if ($limit > 0) {
|
||||
$items = array_slice($items, 0, $limit);
|
||||
}
|
||||
|
||||
// Expand feed items (CssSelectorBridge)
|
||||
foreach ($items as $item_from_feed) {
|
||||
$item_expanded = $this->expandEntryWithSelector(
|
||||
$item_from_feed['uri'],
|
||||
@ -86,7 +88,7 @@ class CssSelectorFeedExpanderBridge extends CssSelectorBridge
|
||||
} else {
|
||||
// Take expanded item, but give priority to metadata already in source item
|
||||
foreach ($item_from_feed as $field => $val) {
|
||||
if ($field !== 'content') {
|
||||
if ($field !== 'content' && !empty($val)) {
|
||||
$item_expanded[$field] = $val;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user