forked from blallo/rss-bridge
[FilterMore] include enclosures in output
This commit is contained in:
parent
d1c224b483
commit
82dd4994ce
1 changed files with 26 additions and 0 deletions
|
@ -59,6 +59,26 @@ class FilterMoreBridge extends FeedExpander {
|
|||
|
||||
protected function parseItem($newItem){
|
||||
$item = parent::parseItem($newItem);
|
||||
$item['enclosures'] = [];
|
||||
if(isset($newItem->enclosure)) {
|
||||
foreach($newItem->enclosure as $encl) {
|
||||
$serialized = [];
|
||||
foreach($encl->attributes() as $key => $value) {
|
||||
$serialized[$key] = (string)$value;
|
||||
}
|
||||
$serialized["length"] = intval($serialized["length"]);
|
||||
$item['enclosures'][] = $serialized;
|
||||
}
|
||||
}
|
||||
if(isset($newItem->link)) {
|
||||
foreach($newItem->link as $el) {
|
||||
if(((string)$el['rel']) !== 'enclosure') continue;
|
||||
$serialized = [];
|
||||
$serialized['url'] = (string)$el['href'];
|
||||
|
||||
$item['enclosures'][] = $serialized;
|
||||
}
|
||||
}
|
||||
|
||||
$filters = ['filterByTitle', 'filterByBody', 'filterByAuthor', 'filterByDateNewer', 'filterByDateOlder'];
|
||||
$results = [];
|
||||
|
@ -68,6 +88,12 @@ class FilterMoreBridge extends FeedExpander {
|
|||
if($filter_res === null) continue;
|
||||
$results[] = $filter_res;
|
||||
}
|
||||
|
||||
$old_enclosures = $item['enclosures'];
|
||||
$item['enclosures'] = [];
|
||||
foreach($old_enclosures as $e) {
|
||||
$item['enclosures'][] = $e['url'];
|
||||
}
|
||||
if(count($results) === 0) {
|
||||
return $item;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue