refactor: FeedExpander::parseItem() descendants (#3744)

This commit is contained in:
Dag 2023-10-13 00:25:34 +02:00 committed by GitHub
parent 9bda9e246a
commit 382648fc22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 314 additions and 281 deletions

View file

@ -1,5 +1,8 @@
<?php
/**
* Appears to be protected by cloudflare now
*/
class EsquerdaNetBridge extends FeedExpander
{
const MAINTAINER = 'somini';
@ -23,32 +26,16 @@ class EsquerdaNetBridge extends FeedExpander
]
];
public function getURI()
{
$type = $this->getInput('feed');
return self::URI . '/rss/' . $type;
}
public function getIcon()
{
return 'https://www.esquerda.net/sites/default/files/favicon_0.ico';
}
public function collectData()
{
parent::collectExpandableDatas($this->getURI());
}
protected function parseItem($newsItem)
protected function parseItem($item)
{
# Fix Publish date
$badDate = $newsItem->pubDate;
preg_match('|(?P<day>\d\d)/(?P<month>\d\d)/(?P<year>\d\d\d\d) - (?P<hour>\d\d):(?P<minute>\d\d)|', $badDate, $d);
$newsItem->pubDate = sprintf('%s-%s-%sT%s:%s', $d['year'], $d['month'], $d['day'], $d['hour'], $d['minute']);
$item = parent::parseItem($newsItem);
# Include all the content
$uri = $item['uri'];
$html = getSimpleHTMLDOMCached($uri);
$item = parent::parseItem($item);
$html = getSimpleHTMLDOMCached($item['uri']);
$content = $html->find('div#content div.content', 0);
## Fix author
$authorHTML = $html->find('.field-name-field-op-author a', 0);
@ -72,4 +59,15 @@ class EsquerdaNetBridge extends FeedExpander
$item['content'] = $content;
return $item;
}
public function getURI()
{
$type = $this->getInput('feed');
return self::URI . '/rss/' . $type;
}
public function getIcon()
{
return 'https://www.esquerda.net/sites/default/files/favicon_0.ico';
}
}