Permalink
Browse files

Added more comments.

  • Loading branch information...
1 parent 4abdfbb commit 03d27d1c475aba287474eaf2222c0f410774dfa1 Wes Hays committed Feb 1, 2010
Showing with 84 additions and 19 deletions.
  1. +19 −15 index.php
  2. +4 −1 lib/channel_parser.php
  3. +57 −2 lib/iTunes.php
  4. +4 −1 test/itunes_test.php
View
@@ -5,26 +5,30 @@
$itunes = new iTunes('./test/some_rss.xml');
//$itunes = new iTunes('http://www.livingstonesreno.com/podcast/LSPodcast.xml');
- $itunes->search_all('dog');
+ $retVal = $itunes->get_channel_info();
+ if($retVal) { print_r($retVal); }
// $retVal = $itunes->get_authors();
// if($retVal) { print_r($retVal); }
-
+ //
// $retVal = $itunes->get_all_podcast_titles();
// if($retVal) { print_r($retVal); }
-
+ //
// $retVal = $itunes->get_podcast_info('Some Podcast Show - #2');
// if($retVal) { print_r($retVal); }
-
- $retVal = $itunes->search_authors('Bobby');
- if($retVal) { print_r($retVal); }
-
- $retVal = $itunes->search_keywords('four');
- if($retVal) { print_r($retVal); }
-
- $retVal = $itunes->search_description('bible');
- if($retVal) { print_r($retVal); }
-
- $retVal = $itunes->search_title('Show');
- if($retVal) { print_r($retVal); }
+ //
+ // $retVal = $itunes->search_all('bible');
+ // if($retVal) { print_r($retVal); }
+ //
+ // $retVal = $itunes->search_authors('Bobby');
+ // if($retVal) { print_r($retVal); }
+ //
+ // $retVal = $itunes->search_keywords('four');
+ // if($retVal) { print_r($retVal); }
+ //
+ // $retVal = $itunes->search_description('bible');
+ // if($retVal) { print_r($retVal); }
+ //
+ // $retVal = $itunes->search_title('Show');
+ // if($retVal) { print_r($retVal); }
?>
View
@@ -1,7 +1,10 @@
<?php
/* *******************************************
- # Blah Blah Blah
+ # This class is used to parse an iTunes
+ # RSS Feed (xml file).
+ #
+ # @author Wes Hays <weshays@weshays.com>
******************************************* */
class ChannelParser {
View
@@ -3,7 +3,10 @@
require_once 'channel_parser.php';
/* *******************************************
- # Blah blah blah
+ # This class is meant to be a wrapper for the
+ # iTunes RSS Feed (xml file).
+ #
+ # @author Wes Hays <weshays@weshays.com>
******************************************* */
class iTunes {
@@ -25,6 +28,50 @@ public function __construct($itunes_xml_file, $cache = false) {
/***
+ * Get the channel info for the RSS feed (xml file) that was used to initial this object.
+ * @return array of channel info. If no channel info is found then null is returned.
+ */
+ public function get_channel_info() {
+ $info = array();
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['LANGUAGE']))
+ $info['language'] = $this->channel_data['RSS']['CHANNEL']['LANGUAGE'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['TITLE']))
+ $info['title'] = $this->channel_data['RSS']['CHANNEL']['TITLE'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['DESCRIPTION']))
+ $info['description'] = $this->channel_data['RSS']['CHANNEL']['DESCRIPTION'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['LINK']))
+ $info['link'] = $this->channel_data['RSS']['CHANNEL']['LINK'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['LASTBUILDDATE']))
+ $info['last_build_date'] = $this->channel_data['RSS']['CHANNEL']['LASTBUILDDATE'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['PUBDATE']))
+ $info['publication_date'] = $this->channel_data['RSS']['CHANNEL']['PUBDATE'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['ITUNES:SUBTITLE']))
+ $info['subtitle'] = $this->channel_data['RSS']['CHANNEL']['ITUNES:SUBTITLE'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['ITUNES:SUMMARY']))
+ $info['summary'] = $this->channel_data['RSS']['CHANNEL']['ITUNES:SUMMARY'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['ITUNES:AUTHOR']))
+ $info['author'] = $this->channel_data['RSS']['CHANNEL']['ITUNES:AUTHOR'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['ITUNES:OWNER']['ITUNES:NAME']))
+ $info['owner_name'] = $this->channel_data['RSS']['CHANNEL']['ITUNES:OWNER']['ITUNES:NAME'];
+
+ if(isset($this->channel_data['RSS']['CHANNEL']['ITUNES:OWNER']['ITUNES:EMAIL']))
+ $info['owner_email'] = $this->channel_data['RSS']['CHANNEL']['ITUNES:OWNER']['ITUNES:EMAIL'];
+
+ return empty($info) ? NULL : $info;
+ }
+
+
+ /***
* Returns all the authors found.
* @return array of authors. If no authors are found then null is returned.
*/
@@ -116,7 +163,15 @@ public function get_podcast_info($title) {
* @return array of podcast titles. If no results are found then an empty array will be returned.
*/
public function search_all($keyword) {
- print_r($this->channel_data);
+ $retVal = array();
+ $retVal[] = $this->search_authors($keyword);
+ $retVal[] = $this->search_keywords($keyword);
+ $retVal[] = $this->search_description($keyword);
+ $retVal[] = $this->search_title($keyword);
+ $titles = array_merge($retVal[0], $retVal[1], $retVal[2], $retVal[3]);
+ $titles = array_unique($titles);
+ sort($titles);
+ return $titles;
}
/***
View
@@ -1 +1,4 @@
-require_once 'helper.php'
+<?php
+ require_once 'helper.php'
+
+?>

0 comments on commit 03d27d1

Please sign in to comment.