2016-09-05 19:05:19 +03:00
|
|
|
<?php
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
|
|
|
|
* Atom feeds for websites that don't have one.
|
|
|
|
*
|
|
|
|
* For the full license information, please view the UNLICENSE file distributed
|
|
|
|
* with this source code.
|
|
|
|
*
|
|
|
|
* @package Core
|
|
|
|
* @license http://unlicense.org/ UNLICENSE
|
|
|
|
* @link https://github.com/rss-bridge/rss-bridge
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An abstract class for bridges that need to transform existing RSS or Atom
|
|
|
|
* feeds.
|
|
|
|
*
|
|
|
|
* This class extends {@see BridgeAbstract} with functions to extract contents
|
|
|
|
* from existing RSS or Atom feeds. Bridges that need to transform existing feeds
|
|
|
|
* should inherit from this class instead of {@see BridgeAbstract}.
|
|
|
|
*
|
|
|
|
* Bridges that extend this class don't need to concern themselves with getting
|
|
|
|
* contents from existing feeds, but can focus on adding additional contents
|
|
|
|
* (i.e. by downloading additional data), filtering or just transforming a feed
|
|
|
|
* into another format.
|
|
|
|
*
|
|
|
|
* @link http://www.rssboard.org/rss-0-9-1 RSS 0.91 Specification
|
|
|
|
* @link http://web.resource.org/rss/1.0/spec RDF Site Summary (RSS) 1.0
|
|
|
|
* @link http://www.rssboard.org/rss-specification RSS 2.0 Specification
|
|
|
|
* @link https://tools.ietf.org/html/rfc4287 The Atom Syndication Format
|
|
|
|
*
|
|
|
|
* @todo Return `self` on more functions to allow chaining
|
|
|
|
* @todo The parsing functions should all be private. This class is complicated
|
|
|
|
* enough without having to consider children overriding functions.
|
|
|
|
*/
|
2016-09-10 20:11:09 +03:00
|
|
|
abstract class FeedExpander extends BridgeAbstract {
|
2016-09-05 19:05:19 +03:00
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Holds the title of the current feed
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @todo Rename this parameter to $title for clarity
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
private $name;
|
2018-11-16 23:48:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds the URI of the feed
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
private $uri;
|
2018-11-16 23:48:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds the feed type during internal operations.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @todo Define possible values as constant instead of static strings
|
|
|
|
*/
|
2016-09-12 11:38:50 +03:00
|
|
|
private $feedType;
|
2016-09-10 21:41:11 +03:00
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Collects data from an existing feed.
|
|
|
|
*
|
|
|
|
* Children should call this function in {@see BridgeInterface::collectData()}
|
|
|
|
* to extract a feed.
|
|
|
|
*
|
|
|
|
* @param string $url URL to the feed.
|
|
|
|
* @param int $maxItems Maximum number of items to collect from the feed
|
|
|
|
* (`-1`: no limit).
|
|
|
|
* @return void
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
public function collectExpandableDatas($url, $maxItems = -1){
|
2017-07-29 20:28:00 +03:00
|
|
|
if(empty($url)) {
|
2016-09-26 00:22:33 +03:00
|
|
|
returnServerError('There is no $url for this RSS expander');
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
|
|
|
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('Loading from ' . $url);
|
2016-09-10 21:41:11 +03:00
|
|
|
|
|
|
|
/* Notice we do not use cache here on purpose:
|
|
|
|
* we want a fresh view of the RSS stream each time
|
|
|
|
*/
|
2016-09-26 00:22:33 +03:00
|
|
|
$content = getContents($url)
|
|
|
|
or returnServerError('Could not request ' . $url);
|
2017-08-10 14:20:32 +03:00
|
|
|
$rssContent = simplexml_load_string(trim($content));
|
2016-09-10 21:41:11 +03:00
|
|
|
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('Detecting feed format/version');
|
2017-07-29 20:28:00 +03:00
|
|
|
switch(true) {
|
2016-09-12 11:38:50 +03:00
|
|
|
case isset($rssContent->item[0]):
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('Detected RSS 1.0 format');
|
2018-06-30 00:55:33 +03:00
|
|
|
$this->feedType = 'RSS_1_0';
|
2016-09-12 11:38:50 +03:00
|
|
|
break;
|
|
|
|
case isset($rssContent->channel[0]):
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('Detected RSS 0.9x or 2.0 format');
|
2018-06-30 00:55:33 +03:00
|
|
|
$this->feedType = 'RSS_2_0';
|
2016-09-12 11:38:50 +03:00
|
|
|
break;
|
|
|
|
case isset($rssContent->entry[0]):
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('Detected ATOM format');
|
2018-06-30 00:55:33 +03:00
|
|
|
$this->feedType = 'ATOM_1_0';
|
2016-09-12 11:38:50 +03:00
|
|
|
break;
|
|
|
|
default:
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('Unknown feed format/version');
|
2016-09-26 00:22:33 +03:00
|
|
|
returnServerError('The feed format is unknown!');
|
2016-09-12 11:38:50 +03:00
|
|
|
break;
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
2016-09-12 11:38:50 +03:00
|
|
|
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('Calling function "collect_' . $this->feedType . '_data"');
|
2016-09-17 19:16:25 +03:00
|
|
|
$this->{'collect_' . $this->feedType . '_data'}($rssContent, $maxItems);
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Collect data from a RSS 1.0 compatible feed
|
|
|
|
*
|
|
|
|
* @link http://web.resource.org/rss/1.0/spec RDF Site Summary (RSS) 1.0
|
|
|
|
*
|
|
|
|
* @param string $rssContent The RSS content
|
|
|
|
* @param int $maxItems Maximum number of items to collect from the feed
|
|
|
|
* (`-1`: no limit).
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @todo Instead of passing $maxItems to all functions, just add all items
|
|
|
|
* and remove excessive items later.
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function collect_RSS_1_0_data($rssContent, $maxItems){
|
|
|
|
$this->load_RSS_2_0_feed_data($rssContent->channel[0]);
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($rssContent->item as $item) {
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('parsing item ' . var_export($item, true));
|
2017-06-11 13:58:53 +03:00
|
|
|
$tmp_item = $this->parseItem($item);
|
|
|
|
if (!empty($tmp_item)) {
|
|
|
|
$this->items[] = $tmp_item;
|
|
|
|
}
|
2016-09-10 21:41:11 +03:00
|
|
|
if($maxItems !== -1 && count($this->items) >= $maxItems) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Collect data from a RSS 2.0 compatible feed
|
|
|
|
*
|
|
|
|
* @link http://www.rssboard.org/rss-specification RSS 2.0 Specification
|
|
|
|
*
|
|
|
|
* @param object $rssContent The RSS content
|
|
|
|
* @param int $maxItems Maximum number of items to collect from the feed
|
|
|
|
* (`-1`: no limit).
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @todo Instead of passing $maxItems to all functions, just add all items
|
|
|
|
* and remove excessive items later.
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function collect_RSS_2_0_data($rssContent, $maxItems){
|
|
|
|
$rssContent = $rssContent->channel[0];
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('RSS content is ===========\n'
|
2016-09-10 21:41:11 +03:00
|
|
|
. var_export($rssContent, true)
|
|
|
|
. '===========');
|
|
|
|
|
|
|
|
$this->load_RSS_2_0_feed_data($rssContent);
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($rssContent->item as $item) {
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('parsing item ' . var_export($item, true));
|
2017-06-11 13:58:53 +03:00
|
|
|
$tmp_item = $this->parseItem($item);
|
|
|
|
if (!empty($tmp_item)) {
|
|
|
|
$this->items[] = $tmp_item;
|
|
|
|
}
|
2016-09-10 21:41:11 +03:00
|
|
|
if($maxItems !== -1 && count($this->items) >= $maxItems) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Collect data from a Atom 1.0 compatible feed
|
|
|
|
*
|
|
|
|
* @link https://tools.ietf.org/html/rfc4287 The Atom Syndication Format
|
|
|
|
*
|
|
|
|
* @param object $content The Atom content
|
|
|
|
* @param int $maxItems Maximum number of items to collect from the feed
|
|
|
|
* (`-1`: no limit).
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @todo Instead of passing $maxItems to all functions, just add all items
|
|
|
|
* and remove excessive items later.
|
|
|
|
*/
|
2016-09-12 11:38:50 +03:00
|
|
|
protected function collect_ATOM_1_0_data($content, $maxItems){
|
2016-09-10 21:41:11 +03:00
|
|
|
$this->load_ATOM_feed_data($content);
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($content->entry as $item) {
|
2018-11-10 22:03:03 +03:00
|
|
|
Debug::log('parsing item ' . var_export($item, true));
|
2017-06-11 13:58:53 +03:00
|
|
|
$tmp_item = $this->parseItem($item);
|
|
|
|
if (!empty($tmp_item)) {
|
|
|
|
$this->items[] = $tmp_item;
|
|
|
|
}
|
2016-09-10 21:41:11 +03:00
|
|
|
if($maxItems !== -1 && count($this->items) >= $maxItems) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Convert RSS 2.0 time to timestamp
|
|
|
|
*
|
|
|
|
* @param object $item A feed item
|
|
|
|
* @return int The timestamp
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function RSS_2_0_time_to_timestamp($item){
|
|
|
|
return DateTime::createFromFormat('D, d M Y H:i:s e', $item->pubDate)->getTimestamp();
|
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Load RSS 2.0 feed data into RSS-Bridge
|
|
|
|
*
|
|
|
|
* @param object $rssContent The RSS content
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @todo set title, link, description, language, and so on
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function load_RSS_2_0_feed_data($rssContent){
|
2017-03-14 00:11:20 +03:00
|
|
|
$this->name = trim((string)$rssContent->title);
|
|
|
|
$this->uri = trim((string)$rssContent->link);
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Load Atom feed data into RSS-Bridge
|
|
|
|
*
|
|
|
|
* @param object $content The Atom content
|
|
|
|
* @return void
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function load_ATOM_feed_data($content){
|
2017-03-14 00:11:20 +03:00
|
|
|
$this->name = (string)$content->title;
|
2016-09-10 21:41:11 +03:00
|
|
|
|
|
|
|
// Find best link (only one, or first of 'alternate')
|
2017-07-29 20:28:00 +03:00
|
|
|
if(!isset($content->link)) {
|
2016-09-10 21:41:11 +03:00
|
|
|
$this->uri = '';
|
2017-07-29 20:28:00 +03:00
|
|
|
} elseif (count($content->link) === 1) {
|
2017-08-10 14:35:17 +03:00
|
|
|
$this->uri = (string)$content->link[0]['href'];
|
2016-09-10 21:41:11 +03:00
|
|
|
} else {
|
|
|
|
$this->uri = '';
|
2017-07-29 20:28:00 +03:00
|
|
|
foreach($content->link as $link) {
|
|
|
|
if(strtolower($link['rel']) === 'alternate') {
|
2017-08-10 14:35:17 +03:00
|
|
|
$this->uri = (string)$link['href'];
|
2016-09-10 21:41:11 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Parse the contents of a single Atom feed item into a RSS-Bridge item for
|
|
|
|
* further transformation.
|
|
|
|
*
|
|
|
|
* @param object $feedItem A single feed item
|
|
|
|
* @return object The RSS-Bridge item
|
|
|
|
*
|
|
|
|
* @todo To reduce confusion, the RSS-Bridge item should maybe have a class
|
|
|
|
* of its own?
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function parseATOMItem($feedItem){
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
// Some ATOM entries also contain RSS 2.0 fields
|
|
|
|
$item = $this->parseRSS_2_0_Item($feedItem);
|
|
|
|
|
2016-10-02 19:07:56 +03:00
|
|
|
if(isset($feedItem->id)) $item['uri'] = (string)$feedItem->id;
|
|
|
|
if(isset($feedItem->title)) $item['title'] = (string)$feedItem->title;
|
|
|
|
if(isset($feedItem->updated)) $item['timestamp'] = strtotime((string)$feedItem->updated);
|
|
|
|
if(isset($feedItem->author)) $item['author'] = (string)$feedItem->author->name;
|
|
|
|
if(isset($feedItem->content)) $item['content'] = (string)$feedItem->content;
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
|
|
|
|
//When "link" field is present, URL is more reliable than "id" field
|
|
|
|
if (count($feedItem->link) === 1) {
|
|
|
|
$this->uri = (string)$feedItem->link[0]['href'];
|
|
|
|
} else {
|
|
|
|
foreach($feedItem->link as $link) {
|
|
|
|
if(strtolower($link['rel']) === 'alternate') {
|
|
|
|
$item['uri'] = (string)$link['href'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-10 21:41:11 +03:00
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Parse the contents of a single RSS 0.91 feed item into a RSS-Bridge item
|
|
|
|
* for further transformation.
|
|
|
|
*
|
|
|
|
* @param object $feedItem A single feed item
|
|
|
|
* @return object The RSS-Bridge item
|
|
|
|
*
|
|
|
|
* @todo To reduce confusion, the RSS-Bridge item should maybe have a class
|
|
|
|
* of its own?
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function parseRSS_0_9_1_Item($feedItem){
|
|
|
|
$item = array();
|
2016-10-02 19:07:56 +03:00
|
|
|
if(isset($feedItem->link)) $item['uri'] = (string)$feedItem->link;
|
|
|
|
if(isset($feedItem->title)) $item['title'] = (string)$feedItem->title;
|
2016-09-10 21:41:11 +03:00
|
|
|
// rss 0.91 doesn't support timestamps
|
|
|
|
// rss 0.91 doesn't support authors
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
// rss 0.91 doesn't support enclosures
|
2016-10-02 19:07:56 +03:00
|
|
|
if(isset($feedItem->description)) $item['content'] = (string)$feedItem->description;
|
2016-09-10 21:41:11 +03:00
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Parse the contents of a single RSS 1.0 feed item into a RSS-Bridge item
|
|
|
|
* for further transformation.
|
|
|
|
*
|
|
|
|
* @param object $feedItem A single feed item
|
|
|
|
* @return object The RSS-Bridge item
|
|
|
|
*
|
|
|
|
* @todo To reduce confusion, the RSS-Bridge item should maybe have a class
|
|
|
|
* of its own?
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function parseRSS_1_0_Item($feedItem){
|
|
|
|
// 1.0 adds optional elements around the 0.91 standard
|
|
|
|
$item = $this->parseRSS_0_9_1_Item($feedItem);
|
|
|
|
|
|
|
|
$namespaces = $feedItem->getNamespaces(true);
|
2017-07-29 20:28:00 +03:00
|
|
|
if(isset($namespaces['dc'])) {
|
2016-09-10 21:41:11 +03:00
|
|
|
$dc = $feedItem->children($namespaces['dc']);
|
2016-10-02 19:07:56 +03:00
|
|
|
if(isset($dc->date)) $item['timestamp'] = strtotime((string)$dc->date);
|
|
|
|
if(isset($dc->creator)) $item['author'] = (string)$dc->creator;
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Parse the contents of a single RSS 2.0 feed item into a RSS-Bridge item
|
|
|
|
* for further transformation.
|
|
|
|
*
|
|
|
|
* @param object $feedItem A single feed item
|
|
|
|
* @return object The RSS-Bridge item
|
|
|
|
*
|
|
|
|
* @todo To reduce confusion, the RSS-Bridge item should maybe have a class
|
|
|
|
* of its own?
|
|
|
|
*/
|
2016-09-10 21:41:11 +03:00
|
|
|
protected function parseRSS_2_0_Item($feedItem){
|
|
|
|
// Primary data is compatible to 0.91 with some additional data
|
|
|
|
$item = $this->parseRSS_0_9_1_Item($feedItem);
|
|
|
|
|
|
|
|
$namespaces = $feedItem->getNamespaces(true);
|
|
|
|
if(isset($namespaces['dc'])) $dc = $feedItem->children($namespaces['dc']);
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
if(isset($namespaces['media'])) $media = $feedItem->children($namespaces['media']);
|
2016-09-10 21:41:11 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if(isset($feedItem->guid)) {
|
|
|
|
foreach($feedItem->guid->attributes() as $attribute => $value) {
|
2016-09-17 21:43:05 +03:00
|
|
|
if($attribute === 'isPermaLink'
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
&& ($value === 'true' || (
|
|
|
|
filter_var($feedItem->guid, FILTER_VALIDATE_URL)
|
|
|
|
&& !filter_var($item['uri'], FILTER_VALIDATE_URL)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
2016-10-02 19:07:56 +03:00
|
|
|
$item['uri'] = (string)$feedItem->guid;
|
2016-09-14 14:36:44 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if(isset($feedItem->pubDate)) {
|
2016-10-02 19:07:56 +03:00
|
|
|
$item['timestamp'] = strtotime((string)$feedItem->pubDate);
|
2017-07-29 20:28:00 +03:00
|
|
|
} elseif(isset($dc->date)) {
|
2016-10-02 19:07:56 +03:00
|
|
|
$item['timestamp'] = strtotime((string)$dc->date);
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
|
2017-07-29 20:28:00 +03:00
|
|
|
if(isset($feedItem->author)) {
|
2016-10-02 19:07:56 +03:00
|
|
|
$item['author'] = (string)$feedItem->author;
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
} elseif (isset($feedItem->creator)) {
|
|
|
|
$item['author'] = (string)$feedItem->creator;
|
2017-07-29 20:28:00 +03:00
|
|
|
} elseif(isset($dc->creator)) {
|
2016-10-02 19:07:56 +03:00
|
|
|
$item['author'] = (string)$dc->creator;
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
} elseif(isset($media->credit)) {
|
|
|
|
$item['author'] = (string)$media->credit;
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
|
|
|
|
if(isset($feedItem->enclosure) && !empty($feedItem->enclosure['url'])) {
|
|
|
|
$item['enclosures'] = array((string)$feedItem->enclosure['url']);
|
|
|
|
}
|
|
|
|
|
2016-09-10 21:41:11 +03:00
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-11-16 23:48:59 +03:00
|
|
|
* Parse the contents of a single feed item, depending on the current feed
|
|
|
|
* type, into a RSS-Bridge item.
|
|
|
|
*
|
|
|
|
* @param object $item The current feed item
|
|
|
|
* @return object A RSS-Bridge item, with (hopefully) the whole content
|
2016-09-10 21:41:11 +03:00
|
|
|
*/
|
2016-09-12 11:39:34 +03:00
|
|
|
protected function parseItem($item){
|
2017-07-29 20:28:00 +03:00
|
|
|
switch($this->feedType) {
|
2016-09-12 11:39:34 +03:00
|
|
|
case 'RSS_1_0':
|
|
|
|
return $this->parseRSS_1_0_Item($item);
|
|
|
|
break;
|
|
|
|
case 'RSS_2_0':
|
|
|
|
return $this->parseRSS_2_0_Item($item);
|
|
|
|
break;
|
|
|
|
case 'ATOM_1_0':
|
|
|
|
return $this->parseATOMItem($item);
|
|
|
|
break;
|
2016-09-26 00:22:33 +03:00
|
|
|
default: returnClientError('Unknown version ' . $this->getInput('version') . '!');
|
2016-09-12 11:39:34 +03:00
|
|
|
}
|
|
|
|
}
|
2016-09-10 21:41:11 +03:00
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/** {@inheritdoc} */
|
2016-09-10 21:41:11 +03:00
|
|
|
public function getURI(){
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
return !empty($this->uri) ? $this->uri : parent::getURI();
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/** {@inheritdoc} */
|
2016-09-10 21:41:11 +03:00
|
|
|
public function getName(){
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
return !empty($this->name) ? $this->name : parent::getName();
|
2016-09-10 21:41:11 +03:00
|
|
|
}
|
2018-08-21 18:46:47 +03:00
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/** {@inheritdoc} */
|
2018-08-21 18:46:47 +03:00
|
|
|
public function getIcon(){
|
Catching up | [Main] Debug mode, parse utils, MIME | [Bridges] Add/Improve 20 bridges (#802)
* Debug mode improvements
- Improve debug warning message
- Restore error reporting in debug mode
- Fix 'notice' messages for unset fields
* Add parsing utility functions
html.php
- extractFromDelimiters
- stripWithDelimiters
- stripRecursiveHTMLSection
- markdownToHtml (partial)
bridges
- remove now-duplicate functions
- call functions from html.php instead
* [Anidex] New bridge
Anime torrent tracker
* [Anime-Ultime] Restore thumbnail
* [CNET] Recreate bridge
Full rewrite as the previous one was broken
* [Dilbert] Minor URI fix
Use new self::URI property
* [EstCeQuonMetEnProd] Fix content extraction
Bridge was broken
* [Facebook] Fix "SpSonsSoriSsés" label
... which was taking space in item title
* [Futura-Sciences] Use HTTPS, More cleanup
Use HTTPS as FS now offer HTTPS
Clean additional useless HTML elements
* [GBATemp] Multiple fixes
- Fix categories: missing "break" statements
- Restore thumbnail as enclosure
- Fix date extraction
- Fix user blog post extraction
- Use getSimpleHTMLDOMCached
* [JapanExpo] Fix bridge, HTTPS, thumbnails
- Fix getSimpleHTMLDOMCached call
- Upgrade to HTTPS as JE now offers HTTPS
- Restore thumbnails as enclosures
* [LeMondeInformatique] Fix bridge, HTTPS
- Upgrade to HTTPS as LMI now offers HTTPS
- Restore thumbnails using small images
- Fix content extraction
- Fix text encoding issue
* [Nextgov] Fix content extraction
- Restore thumbnail and use small image
- Field extraction fixes
* [NextInpact] Add categories and filtering by type
- Offer all RSS feeds
- Allow filtering by article type
- Implement extraction for brief articles
- Remove article limit, many brief articles are publied all at once
* [NyaaTorrents] New bridge
Anime torrent tracker
* [Releases3DS] Cache content, restore thumbnail
- Use getSimpleHTMLDOMCached
- Restore thumbnail as enclosure
* [TheHackerNews] Fix bridge
- Fix content extraction including article body
- Restore thumbnail as enclosure
* [WeLiveSecurity] HTTPS, Fix content extraction
- Upgrade to HTTPS as WLS now offers HTTPS
- Fix content extraction including article body
* [WordPress] Reduce timeout, more content selectors
- Reduce timeout to use default one (1h)
- Add new content selector (articleBody)
- Find thumbnail and set as enclosure
- Fix <script> cleanup
* [YGGTorrent] Increase limit, use cache
- Increase item limit as uploads are very frequent
- Use getSimpleHTMLDOMCached
* [ZDNet] Rewrite with FeedExpander
- Upgrade to HTTPS as ZD now offers HTTPS
- Use FeedExpander for secondary fields
- Fix content extraction for article body
* [Main] Handle MIME type for enclosures
Many feed readers will ignore enclosures (e.g. thumbnails) with no MIME type. This commit adds automatic MIME type detection based on file extension (which may be inaccurate but is the only way without fetching the content).
One can force enclosure type using #.ext anchor (hacky, needs improving)
* [FeedExpander] Improve field extraction
- Add support for passing enclosures
- Improve author and uri extraction
- Fix 'notice' PHP error messages
* [Pull] Coding style fixes for #802
* [Pull] Implementing changes for #802
- Fix coding style issues with str append
- Remove useless CACHE_TIMEOUT
- Use count() instead of $limit
- Use defaultLinkTo() + handle strings
- Use http_build_query()
- Fix missing </em>
- Remove error_reporting(0)
- warning CSS (@LogMANOriginal)
- Fix typo in FeedExpander comment
* [Main] More documentation for markdownToHtml
See #802 for more details
2018-09-09 22:20:13 +03:00
|
|
|
return !empty($this->icon) ? $this->icon : parent::getIcon();
|
2018-08-21 18:46:47 +03:00
|
|
|
}
|
2016-09-05 19:05:19 +03:00
|
|
|
}
|