1
0
Fork 0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-02-24 11:19:17 +03:00

Merge remote-tracking branch 'origin/master' into fix1

This commit is contained in:
Dag 2022-04-08 22:37:16 +02:00
commit a535121ab1
5 changed files with 128 additions and 1 deletions

View file

@ -0,0 +1,54 @@
<?php
class FeedMergeBridge extends FeedExpander {
const MAINTAINER = 'dvikan';
const NAME = 'FeedMerge';
const URI = 'https://github.com/RSS-Bridge/rss-bridge';
const DESCRIPTION = <<<'TEXT'
This bridge merges two or more feeds into a single feed. Max 10 items are fetched from each feed.
TEXT;
const PARAMETERS = [
[
'feed_name' => [
'name' => 'Feed name',
'type' => 'text',
'exampleValue' => 'rss-bridge/FeedMerger',
],
'feed_1' => [
'name' => 'Feed url',
'type' => 'text',
'required' => true,
'exampleValue' => 'https://lorem-rss.herokuapp.com/feed?unit=day'
],
'feed_2' => ['name' => 'Feed url', 'type' => 'text'],
'feed_3' => ['name' => 'Feed url', 'type' => 'text'],
'feed_4' => ['name' => 'Feed url', 'type' => 'text'],
'feed_5' => ['name' => 'Feed url', 'type' => 'text'],
]
];
public function collectData() {
$limit = 10;
$feeds = [
$this->getInput('feed_1'),
$this->getInput('feed_2'),
$this->getInput('feed_3'),
$this->getInput('feed_4'),
$this->getInput('feed_5'),
];
// Remove empty values
$feeds = array_filter($feeds);
foreach ($feeds as $feed) {
$this->collectExpandableDatas($feed, $limit);
}
}
public function getIcon() {
return 'https://cdn.jsdelivr.net/npm/famfamfam-silk@1.0.0/dist/png/folder_feed.png';
}
public function getName() {
return $this->getInput('feed_name') ?: 'rss-bridge/FeedMerger';
}
}

View file

@ -0,0 +1,54 @@
<?php
class GatesNotesBridge extends FeedExpander {
const MAINTAINER = 'corenting';
const NAME = 'Gates Notes';
const URI = 'https://www.gatesnotes.com';
const DESCRIPTION = 'Returns the newest articles.';
const CACHE_TIMEOUT = 21600; // 6h
protected function parseItem($item){
$item = parent::parseItem($item);
$article_html = getSimpleHTMLDOMCached($item['uri']);
if(!$article_html) {
$item['content'] .= '<p><em>Could not request ' . $this->getName() . ': ' . $item['uri'] . '</em></p>';
return $item;
}
$article_html = defaultLinkTo($article_html, $this->getURI());
$top_description = '<p>' . $article_html->find('div.article_top_description', 0)->innertext . '</p>';
$hero_image = '<img src=' . $article_html->find('img.article_top_DMT_Image', 0)->getAttribute('data-src') . '>';
$article_body = $article_html->find('div.TGN_Article_ReadTimeSection', 0);
// Convert iframe of Youtube videos to link
foreach($article_body->find('iframe') as $found) {
$iframeUrl = $found->getAttribute('src');
if ($iframeUrl) {
$text = 'Embedded Youtube video, click here to watch on Youtube.com';
$found->outertext = '<p><a href="' . $iframeUrl . '">' . $text . '</a></p>';
}
}
// Remove <link> CSS ressources
foreach($article_body->find('link') as $found) {
$linkedRessourceUrl = $found->getAttribute('href');
if (str_ends_with($linkedRessourceUrl, '.css')) {
$found->outertext = '';
}
}
$article_body = sanitize($article_body->innertext);
$item['content'] = $top_description . $hero_image . $article_body;
return $item;
}
public function collectData(){
$feed = static::URI . '/rss';
$this->collectExpandableDatas($feed);
}
}

View file

@ -13,6 +13,7 @@
timezone = "UTC"
[http]
timeout = 60
useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
[cache]

View file

@ -17,6 +17,7 @@ __Notice__: If a parameter is not specified in your `config.ini.php` RSS-Bridge
The configuration file is split into sections:
* [system](#system)
* [http client](#http client)
* [cache](#cache)
* [proxy](#proxy)
* [authentication](#authentication)
@ -25,6 +26,8 @@ The configuration file is split into sections:
_System_: This section specifies system specific parameters
_Http client_: This section has http client options
_Cache_: This section is all about the caching behavior of RSS-Bridge
_Proxy_: This section can be used to specify a proxy server for RSS-Bridge to utilize for fetching contents
@ -98,6 +101,21 @@ Allow users to disable proxy usage for specific requests.
`false` = disabled (default)
## Http client
This section provides the following parameters:
- timeout
- useragent
### timeout
Default network timeout.
### useragent
Default user agent.
## Authentication
This section provides following parameters:

View file

@ -140,6 +140,7 @@ function getContents($url, $header = array(), $opts = array(), $returnHeader = f
}
curl_setopt($ch, CURLOPT_USERAGENT, Configuration::getConfig('http', 'useragent'));
curl_setopt($ch, CURLOPT_TIMEOUT, Configuration::getConfig('http', 'timeout'));
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
@ -150,7 +151,6 @@ function getContents($url, $header = array(), $opts = array(), $returnHeader = f
foreach($opts as $key => $value) {
curl_setopt($ch, $key, $value);
}
}
if(defined('PROXY_URL') && !defined('NOPROXY')) {