Switch Podcast reader to use simplepie

This commit is contained in:
drigato 2015-09-23 14:47:40 -04:00
parent c5b00e56bb
commit 727abac0b8
4 changed files with 89 additions and 57 deletions

View File

@ -57,9 +57,26 @@ class Podcast extends BasePodcast
// Kind of a pain; since the rss fields are SimpleXMLElements, // Kind of a pain; since the rss fields are SimpleXMLElements,
// we need to explicitly cast them to strings // we need to explicitly cast them to strings
$podcastArray["title"] = (string)$rss->title; $podcastArray["title"] = $rss->get_title();
$podcastArray["creator"] = (string)$rss->author; $podcastArray["description"] = $rss->get_description();
$podcastArray["link"] = $rss->get_link();
$podcastArray["language"] = $rss->get_language();
$podcastArray["copyright"] = $rss->get_copyright();
$podcastArray["author"] = $rss->get_author();
$podcastArray["category"] = $rss->get_categories();
/*$podcastArray["title"] = (string)$rss->title;
$podcastArray["description"] = (string)$rss->description; $podcastArray["description"] = (string)$rss->description;
$podcastArray["link"] = (string)$rss->link;
$podcastArray["language"] = (string)$rss->language;
$podcastArray["copyright"] = (string)$rss->copyright;
$podcastArray["itunes_author"] = (string)$rss->{'itunes:author'};
$podcastArray["itunes_keywords"] = (string)$rss->{'itunes:keywords'};
$podcastArray["itunes_subtitle"] = (string)$rss->{'itunes:subtitle'};
$podcastArray["itunes_summary"] = (string)$rss->{'itunes:summary'};
//TODO: fix itunes_category
$podcastArray["itunes_category"] = (string)$rss->{'itunes:category'};
$podcastArray["itunes_explicit"] = (string)$rss->{'itunes:explicit'};*/
self::validatePodcastMetadata($podcastArray); self::validatePodcastMetadata($podcastArray);
try { try {

View File

@ -51,7 +51,11 @@ class Application_Service_PodcastService extends Application_Service_ThirdPartyC
public static function getPodcastFeed($podcastUrl) public static function getPodcastFeed($podcastUrl)
{ {
try { try {
return Feed::loadRss($podcastUrl); $feed = new SimplePie();
$feed->set_feed_url($podcastUrl);
$feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/rss/cache_files');
$feed->init();
return $feed;
} catch (FeedException $e) { } catch (FeedException $e) {
return false; return false;
} }
@ -61,7 +65,6 @@ class Application_Service_PodcastService extends Application_Service_ThirdPartyC
{ {
} }
/** /**
* Given an array of track identifiers, download RSS feed tracks * Given an array of track identifiers, download RSS feed tracks
* *

View File

@ -5,6 +5,6 @@
"raven/raven": "0.12.0", "raven/raven": "0.12.0",
"ise/php-soundcloud": "3.0.1", "ise/php-soundcloud": "3.0.1",
"massivescale/celery-php": "2.0.*@dev", "massivescale/celery-php": "2.0.*@dev",
"dg/rss-php": "1.2" "simplepie/simplepie": "dev-master"
} }
} }

116
composer.lock generated
View File

@ -1,10 +1,10 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "26535a03b324113b05e6bd8bbc7f2bcb", "hash": "8d8a51740ad37127ff6618f80861ccfc",
"packages": [ "packages": [
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
@ -73,48 +73,6 @@
], ],
"time": "2014-12-08 21:56:46" "time": "2014-12-08 21:56:46"
}, },
{
"name": "dg/rss-php",
"version": "v1.2",
"source": {
"type": "git",
"url": "https://github.com/dg/rss-php.git",
"reference": "b33661748d89d8c0c288e8d86feada6018d05031"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dg/rss-php/zipball/b33661748d89d8c0c288e8d86feada6018d05031",
"reference": "b33661748d89d8c0c288e8d86feada6018d05031",
"shasum": ""
},
"require": {
"php": ">=5.2.2"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "David Grudl",
"homepage": "http://davidgrudl.com"
}
],
"description": "RSS & Atom Feeds for PHP is a very small and easy-to-use library for consuming an RSS and Atom feed",
"homepage": "https://github.com/dg/rss-php",
"keywords": [
"atom",
"feed",
"rss"
],
"time": "2015-07-02 11:54:05"
},
{ {
"name": "guzzle/guzzle", "name": "guzzle/guzzle",
"version": "v3.9.3", "version": "v3.9.3",
@ -273,7 +231,7 @@
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"predis/predis": ">=0.8.5", "predis/predis": "0.8.5",
"videlalvaro/php-amqplib": ">=2.4.0" "videlalvaro/php-amqplib": ">=2.4.0"
}, },
"type": "library", "type": "library",
@ -567,6 +525,60 @@
], ],
"time": "2015-05-19 20:20:08" "time": "2015-05-19 20:20:08"
}, },
{
"name": "simplepie/simplepie",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/simplepie/simplepie.git",
"reference": "6102a15d768c7d81fe48f7e2f1d8cf9e71e5959f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/6102a15d768c7d81fe48f7e2f1d8cf9e71e5959f",
"reference": "6102a15d768c7d81fe48f7e2f1d8cf9e71e5959f",
"shasum": ""
},
"require": {
"php": ">=5.2.0"
},
"type": "library",
"autoload": {
"psr-0": {
"SimplePie": "library"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Ryan Parman",
"homepage": "http://ryanparman.com/",
"role": "Creator, alumnus developer"
},
{
"name": "Geoffrey Sneddon",
"homepage": "http://gsnedders.com/",
"role": "Alumnus developer"
},
{
"name": "Ryan McCue",
"email": "me@ryanmccue.info",
"homepage": "http://ryanmccue.info/",
"role": "Developer"
}
],
"description": "A simple Atom/RSS parsing library for PHP",
"homepage": "http://simplepie.org/",
"keywords": [
"atom",
"feeds",
"rss"
],
"time": "2015-09-02 01:14:05"
},
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v2.7.4", "version": "v2.7.4",
@ -627,16 +639,16 @@
}, },
{ {
"name": "videlalvaro/php-amqplib", "name": "videlalvaro/php-amqplib",
"version": "v2.5.2", "version": "v2.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/videlalvaro/php-amqplib.git", "url": "https://github.com/videlalvaro/php-amqplib.git",
"reference": "eb8f94d97c8e79900accf77343dbd7eca7f58506" "reference": "8a6e89ad46130eb365b7f57d313f2a795f5e3269"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/videlalvaro/php-amqplib/zipball/eb8f94d97c8e79900accf77343dbd7eca7f58506", "url": "https://api.github.com/repos/videlalvaro/php-amqplib/zipball/8a6e89ad46130eb365b7f57d313f2a795f5e3269",
"reference": "eb8f94d97c8e79900accf77343dbd7eca7f58506", "reference": "8a6e89ad46130eb365b7f57d313f2a795f5e3269",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -677,17 +689,17 @@
"queue", "queue",
"rabbitmq" "rabbitmq"
], ],
"time": "2015-08-11 12:30:09" "time": "2015-09-23 02:25:31"
} }
], ],
"packages-dev": [], "packages-dev": [],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": {
"massivescale/celery-php": 20 "massivescale/celery-php": 20,
"simplepie/simplepie": 20
}, },
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false,
"platform": [], "platform": [],
"platform-dev": [] "platform-dev": []
} }