summaryrefslogtreecommitdiffstats
path: root/utility
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-22 12:35:30 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-22 12:35:30 +0100
commit7a579b42fa731b65db26bd0c026bc68f2339c451 (patch)
tree77f6481abfa90157ab3cc77566f6d4acd7ce8dda /utility
parent880184d0c2372c2493d62cb6fa4d268902043a65 (diff)
added creating feeds
Diffstat (limited to 'utility')
-rw-r--r--utility/feedfetcher.php17
1 files changed, 8 insertions, 9 deletions
diff --git a/utility/feedfetcher.php b/utility/feedfetcher.php
index edaa72b9a..e6ebba5e8 100644
--- a/utility/feedfetcher.php
+++ b/utility/feedfetcher.php
@@ -33,16 +33,16 @@ class FeedFetcher {
* Fetch a feed from remote
* @param string url remote url of the feed
* @throws FetcherException if simple pie fails
- * @returns array an array containing the new feed and its items
+ * @return array an array containing the new feed and its items
*/
public function fetch($url) {
$simplePie = new \SimplePie_Core();
$simplePie->set_feed_url( $url );
$simplePie->enable_cache( false );
- // TODO: throw error
+
if (!$simplePie->init()) {
- return null;
+ throw new FetcherException('Could not initialize simple pie');
}
// temporary try-catch to bypass SimplePie bugs
@@ -64,7 +64,7 @@ class FeedFetcher {
$item->setAuthor( $author->get_name() );
}
- // associated media file, for podcasts
+ // TODO: make it work for video files also
$enclosure = $feedItem->get_enclosure();
if($enclosure !== null) {
$enclosureType = $enclosure->get_type();
@@ -96,7 +96,7 @@ class FeedFetcher {
}
}
return array($feed, $items);
- } catch(Exception $ex){
+ } catch(\Exception $ex){
throw new FetcherException($ex->getMessage());
}
@@ -104,8 +104,7 @@ class FeedFetcher {
/**
* Perform a "slim" fetch of a feed from remote.
- * Differently from Utils::fetch(), it doesn't retrieve items nor a favicon
- *
+ * Differently from fetch(), it doesn't retrieve items nor a favicon
* @param string url remote url of the feed
* @returns \OCA\News\Db\Feed
*/
@@ -116,7 +115,7 @@ class FeedFetcher {
$simplePie->set_stupidly_fast( true );
if (!$simplePie->init()) {
- return null;
+ throw new FetcherException('Could not initialize simple pie');
}
// temporary try-catch to bypass SimplePie bugs
@@ -128,7 +127,7 @@ class FeedFetcher {
$feed->setAdded(time());
return $feed;
- } catch(Exception $ex){
+ } catch(\Exception $ex){
throw new FetcherException($ex->getMessage());
}
}