mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-29 03:47:42 +01:00
fix(duckduckgo): order by date (#3689)
This commit is contained in:
parent
07f49225d9
commit
cb6c931b1f
@ -14,29 +14,10 @@ class AwwwardsBridge extends BridgeAbstract
|
||||
|
||||
private $sites = [];
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
return 'https://www.awwwards.com/favicon.ico';
|
||||
}
|
||||
|
||||
private function fetchSites()
|
||||
{
|
||||
Debug::log('Fetching all sites');
|
||||
$sites = getSimpleHTMLDOM(self::SITESURI);
|
||||
|
||||
Debug::log('Parsing all JSON data');
|
||||
foreach ($sites->find('.grid-sites li') as $site) {
|
||||
$decode = html_entity_decode($site->attr['data-collectable-model-value'], ENT_QUOTES, 'utf-8');
|
||||
$decode = json_decode($decode, true);
|
||||
$this->sites[] = $decode;
|
||||
}
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$this->fetchSites();
|
||||
|
||||
Debug::log('Building RSS feed');
|
||||
foreach ($this->sites as $site) {
|
||||
$item = [];
|
||||
$item['title'] = $site['title'];
|
||||
@ -56,4 +37,23 @@ class AwwwardsBridge extends BridgeAbstract
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
return 'https://www.awwwards.com/favicon.ico';
|
||||
}
|
||||
|
||||
private function fetchSites()
|
||||
{
|
||||
$sites = getSimpleHTMLDOM(self::SITESURI);
|
||||
foreach ($sites->find('.grid-sites li') as $li) {
|
||||
$encodedJson = $li->attr['data-collectable-model-value'] ?? null;
|
||||
if (!$encodedJson) {
|
||||
continue;
|
||||
}
|
||||
$json = html_entity_decode($encodedJson, ENT_QUOTES, 'utf-8');
|
||||
$site = Json::decode($json);
|
||||
$this->sites[] = $site;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class DuckDuckGoBridge extends BridgeAbstract
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = 'Returns results from DuckDuckGo.';
|
||||
|
||||
const SORT_DATE = '+sort:date';
|
||||
const SORT_DATE = ' sort:date';
|
||||
const SORT_RELEVANCE = '';
|
||||
|
||||
const PARAMETERS = [ [
|
||||
@ -31,13 +31,22 @@ class DuckDuckGoBridge extends BridgeAbstract
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$html = getSimpleHTMLDOM(self::URI . 'html/?kd=-1&q=' . $this->getInput('u') . $this->getInput('sort'));
|
||||
$query = [
|
||||
'kd' => '-1',
|
||||
'q' => $this->getInput('u') . $this->getInput('sort'),
|
||||
];
|
||||
$url = 'https://duckduckgo.com/html/?' . http_build_query($query);
|
||||
$html = getSimpleHTMLDOM($url);
|
||||
|
||||
foreach ($html->find('div.result') as $element) {
|
||||
$item = [];
|
||||
$item['uri'] = $element->find('a.result__a', 0)->href;
|
||||
$item['title'] = $element->find('h2.result__title', 0)->plaintext;
|
||||
$item['content'] = $element->find('a.result__snippet', 0)->plaintext;
|
||||
|
||||
$snippet = $element->find('a.result__snippet', 0);
|
||||
if ($snippet) {
|
||||
$item['content'] = $snippet->plaintext;
|
||||
}
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,19 @@ class EngadgetBridge extends FeedExpander
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$this->collectExpandableDatas(static::URI . 'rss.xml', 15);
|
||||
$max = 10;
|
||||
$this->collectExpandableDatas(static::URI . 'rss.xml', $max);
|
||||
}
|
||||
|
||||
protected function parseItem($newsItem)
|
||||
{
|
||||
$item = parent::parseItem($newsItem);
|
||||
// $articlePage gets the entire page's contents
|
||||
$articlePage = getSimpleHTMLDOM($newsItem->link);
|
||||
$url = (string) $newsItem->link;
|
||||
if (!$url) {
|
||||
return $item;
|
||||
}
|
||||
// todo: remove querystring tracking
|
||||
$articlePage = getSimpleHTMLDOM($url);
|
||||
// figure contain's the main article image
|
||||
$article = $articlePage->find('figure', 0);
|
||||
// .article-text has the actual article
|
||||
|
@ -170,22 +170,21 @@ class JustWatchBridge extends BridgeAbstract
|
||||
$item = [];
|
||||
$item['uri'] = $title->find('a', 0)->href;
|
||||
|
||||
$posterImage = $title->find('.title-poster__image > img', 0);
|
||||
$itemTitle = sprintf(
|
||||
'%s - %s',
|
||||
$provider->find('picture > img', 0)->alt ?? '',
|
||||
$title->find('.title-poster__image > img', 0)->alt ?? ''
|
||||
$posterImage->alt ?? ''
|
||||
);
|
||||
$item['title'] = $itemTitle;
|
||||
|
||||
$imageUrl = $title->find('.title-poster__image > img', 0)->attr['src'] ?? '';
|
||||
$imageUrl = $posterImage->attr['src'] ?? '';
|
||||
if (str_starts_with($imageUrl, 'data')) {
|
||||
$imageUrl = $title->find('.title-poster__image > img', 0)->attr['data-src'];
|
||||
$imageUrl = $posterImage->attr['data-src'];
|
||||
}
|
||||
|
||||
$content = '<b>Provider:</b> '
|
||||
. $provider->find('picture > img', 0)->alt . '<br>';
|
||||
$content .= '<b>Media:</b> '
|
||||
. $title->find('.title-poster__image > img', 0)->alt . '<br>';
|
||||
$content = '<b>Provider:</b> ' . $provider->find('picture > img', 0)->alt . '<br>';
|
||||
$content .= '<b>Media:</b> ' . ($posterImage->alt ?? '') . '<br>';
|
||||
|
||||
if (isset($title->find('.title-poster__badge', 0)->plaintext)) {
|
||||
$content .= '<b>Type:</b> Series<br>';
|
||||
|
@ -45,10 +45,12 @@ class YandexZenBridge extends BridgeAbstract
|
||||
$item['timestamp'] = date(DateTimeInterface::ATOM, $publicationDateUnixTimestamp);
|
||||
}
|
||||
|
||||
$item['content'] = $post->text . "<br /><img src='$post->image' />";
|
||||
$item['enclosures'] = [
|
||||
$post->image,
|
||||
];
|
||||
$postImage = $post->image ?? null;
|
||||
$item['content'] = $post->text;
|
||||
if ($postImage) {
|
||||
$item['content'] .= "<br /><img src='$postImage' />";
|
||||
$item['enclosures'] = [$postImage];
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
@ -228,7 +228,10 @@ class YoutubeBridge extends BridgeAbstract
|
||||
return;
|
||||
}
|
||||
|
||||
$jsonData = $jsonData->contents->twoColumnWatchNextResults->results->results->contents;
|
||||
$jsonData = $jsonData->contents->twoColumnWatchNextResults->results->results->contents ?? null;
|
||||
if (!$jsonData) {
|
||||
throw new \Exception('Unable to find json data');
|
||||
}
|
||||
$videoSecondaryInfo = null;
|
||||
foreach ($jsonData as $item) {
|
||||
if (isset($item->videoSecondaryInfoRenderer)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user