diff options
Diffstat (limited to 'fetcher')
-rw-r--r-- | fetcher/feedfetcher.php | 42 | ||||
-rw-r--r-- | fetcher/fetcher.php | 9 | ||||
-rw-r--r-- | fetcher/ifeedfetcher.php | 7 | ||||
-rw-r--r-- | fetcher/youtubefetcher.php | 6 |
4 files changed, 39 insertions, 25 deletions
diff --git a/fetcher/feedfetcher.php b/fetcher/feedfetcher.php index 2d3cdb0ba..3222a8419 100644 --- a/fetcher/feedfetcher.php +++ b/fetcher/feedfetcher.php @@ -13,23 +13,23 @@ namespace OCA\News\Fetcher; -use \PicoFeed\Parser\MalFormedXmlException; -use \PicoFeed\Reader\Reader; -use \PicoFeed\Reader\SubscriptionNotFoundException; -use \PicoFeed\Reader\UnsupportedFeedFormatException; -use \PicoFeed\Client\InvalidCertificateException; -use \PicoFeed\Client\InvalidUrlException; -use \PicoFeed\Client\MaxRedirectException; -use \PicoFeed\Client\MaxSizeException; -use \PicoFeed\Client\TimeoutException; - -use \OCP\IL10N; -use \OCP\AppFramework\Utility\ITimeFactory; - -use \OCA\News\Db\Item; -use \OCA\News\Db\Feed; -use \OCA\News\Utility\PicoFeedFaviconFactory; -use \OCA\News\Utility\PicoFeedReaderFactory; +use PicoFeed\Parser\MalFormedXmlException; +use PicoFeed\Reader\Reader; +use PicoFeed\Reader\SubscriptionNotFoundException; +use PicoFeed\Reader\UnsupportedFeedFormatException; +use PicoFeed\Client\InvalidCertificateException; +use PicoFeed\Client\InvalidUrlException; +use PicoFeed\Client\MaxRedirectException; +use PicoFeed\Client\MaxSizeException; +use PicoFeed\Client\TimeoutException; + +use OCP\IL10N; +use OCP\AppFramework\Utility\ITimeFactory; + +use OCA\News\Db\Item; +use OCA\News\Db\Feed; +use OCA\News\Utility\PicoFeedFaviconFactory; +use OCA\News\Utility\PicoFeedReaderFactory; class FeedFetcher implements IFeedFetcher { @@ -68,12 +68,14 @@ class FeedFetcher implements IFeedFetcher { * @param string $etag an etag from an http header. * If lastModified matches the http header from the feed * no results are fetched + * @param bool fullTextEnabled if true tells the fetcher to enhance the + * articles by fetching custom enhanced content * @throws FetcherException if it fails * @return array an array containing the new feed and its items, first * element being the Feed and second element being an array of Items */ public function fetch($url, $getFavicon=true, $lastModified=null, - $etag=null) { + $etag=null, $fullTextEnabled=false) { try { $resource = $this->reader->discover($url, $lastModified, $etag); @@ -89,6 +91,10 @@ class FeedFetcher implements IFeedFetcher { $parser = $this->reader->getParser($location, $content, $encoding); + if ($fullTextEnabled) { + $parser->enableContentGrabber(); + } + $parsedFeed = $parser->execute(); $feed = $this->buildFeed( diff --git a/fetcher/fetcher.php b/fetcher/fetcher.php index c93402e7f..4787ccfdd 100644 --- a/fetcher/fetcher.php +++ b/fetcher/fetcher.php @@ -42,15 +42,18 @@ class Fetcher { * @param string $etag an etag from an http header. * If lastModified matches the http header from the feed * no results are fetched + * @param bool fullTextEnabled if true tells the fetcher to enhance the + * articles by fetching custom enhanced content * @throws FetcherException if simple pie fails * @return array an array containing the new feed and its items, first * element being the Feed and second element being an array of Items */ public function fetch($url, $getFavicon=true, $lastModified=null, - $etag=null) { + $etag=null, $fullTextEnabled=false) { foreach($this->fetchers as $fetcher){ if($fetcher->canHandle($url)){ - return $fetcher->fetch($url, $getFavicon, $lastModified, $etag); + return $fetcher->fetch($url, $getFavicon, $lastModified, $etag, + $fullTextEnabled); } } @@ -58,4 +61,4 @@ class Fetcher { } -}
\ No newline at end of file +} diff --git a/fetcher/ifeedfetcher.php b/fetcher/ifeedfetcher.php index 388b491bf..297885930 100644 --- a/fetcher/ifeedfetcher.php +++ b/fetcher/ifeedfetcher.php @@ -25,11 +25,14 @@ interface IFeedFetcher { * @param string $etag an etag from an http header. * If lastModified matches the http header from the feed * no results are fetched + * @param bool fullTextEnabled if true tells the fetcher to enhance the + * articles by fetching custom enhanced content * @throws FetcherException if the fetcher encounters a problem * @return array an array containing the new feed and its items, first * element being the Feed and second element being an array of Items */ - function fetch($url, $getFavicon=true, $lastModified=null, $etag=null); + function fetch($url, $getFavicon=true, $lastModified=null, $etag=null, + $fullTextEnabled=false); /** * @param string $url the url that should be fetched @@ -38,4 +41,4 @@ interface IFeedFetcher { */ function canHandle($url); -}
\ No newline at end of file +} diff --git a/fetcher/youtubefetcher.php b/fetcher/youtubefetcher.php index 33a7671a4..35ecd80f0 100644 --- a/fetcher/youtubefetcher.php +++ b/fetcher/youtubefetcher.php @@ -53,16 +53,18 @@ class YoutubeFetcher implements IFeedFetcher { * @param string $etag an etag from an http header. * If lastModified matches the http header from the feed * no results are fetched + * @param bool fullTextEnabled if true tells the fetcher to enhance the + * articles by fetching custom enhanced content * @throws FetcherException if it fails * @return array an array containing the new feed and its items, first * element being the Feed and second element being an array of Items */ public function fetch($url, $getFavicon=true, $lastModified=null, - $etag=null) { + $etag=null, $fullTextEnabled=false) { $transformedUrl = $this->buildUrl($url); $result = $this->feedFetcher->fetch( - $transformedUrl, $getFavicon, $lastModified, $etag + $transformedUrl, $getFavicon, $lastModified, $etag, $fullTextEnabled ); // reset feed url so we know the correct added url for the feed |