1 /** The osmplayer namespace. */
  2 var osmplayer = osmplayer || {};
  3 
  4 /** The parser object. */
  5 osmplayer.parser = osmplayer.parser || {};
  6 
  7 /**
  8  * The rss parser object.
  9  *
 10  * @return {object} The rss parser.
 11  **/
 12 osmplayer.parser.rss = {
 13 
 14   // The priority for this parser.
 15   priority: 8,
 16 
 17   // Return if this is a valid youtube feed.
 18   valid: function(feed) {
 19     feed = feed.replace(/(.*)\??(.*)/i, '$1');
 20     return feed.match(/\.rss$/i) !== null;
 21   },
 22 
 23   // Returns the type of request to make.
 24   getType: function(feed) {
 25     return 'xml';
 26   },
 27 
 28   // Returns the feed provided the start and numItems.
 29   getFeed: function(feed, start, numItems) {
 30     return feed;
 31   },
 32 
 33   // Parse the feed.
 34   parse: function(data) {
 35     var playlist = {
 36       total_rows: 0,
 37       nodes: []
 38     };
 39     jQuery('rss channel', data).find('item').each(function(index) {
 40       osmplayer.parser.rss.addRSSItem(playlist, jQuery(this));
 41     });
 42     return playlist;
 43   },
 44 
 45   // Parse an RSS item.
 46   addRSSItem: function(playlist, item) {
 47     playlist.total_rows++;
 48     playlist.nodes.push({
 49       title: item.find('title').text(),
 50       description: item.find('annotation').text(),
 51       mediafiles: {
 52         image: {
 53           'image': {
 54             path: item.find('image').text()
 55           }
 56         },
 57         media: {
 58           'media': {
 59             path: item.find('location').text()
 60           }
 61         }
 62       }
 63     });
 64   }
 65 };
 66