Sha256: cf867d922177d8578e431cde2daba1da487d2cd10e22c880d6f7058aa7b42365

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

module Feedjira

  module Parser
    # iTunes is RSS 2.0 + some apple extensions
    # Source: http://www.apple.com/itunes/whatson/podcasts/specs.html
    class ITunesRSS
      include SAXMachine
      include FeedUtilities

      attr_accessor :feed_url

      # RSS 2.0 elements that need including
      element :copyright
      element :description
      element :language
      element :managingEditor
      element :title
      element :link, :as => :url

      # If author is not present use managingEditor on the channel
      element :"itunes:author", :as => :itunes_author
      element :"itunes:block", :as => :itunes_block
      element :"itunes:image", :value => :href, :as => :itunes_image
      element :"itunes:explicit", :as => :itunes_explicit
      element :"itunes:keywords", :as => :itunes_keywords
      # New URL for the podcast feed
      element :"itunes:new-feed-url", :as => :itunes_new_feed_url
      element :"itunes:subtitle", :as => :itunes_subtitle
      # If summary is not present, use the description tag
      element :"itunes:summary", :as => :itunes_summary

      # iTunes RSS feeds can have multiple main categories...
      # ...and multiple sub-categories per category
      # TODO subcategories not supported correctly - they are at the same level
      #   as the main categories
      elements :"itunes:category", :as => :itunes_categories, :value => :text

      elements :"itunes:owner", :as => :itunes_owners, :class => ITunesRSSOwner

      elements :item, :as => :entries, :class => ITunesRSSItem

      def self.able_to_parse?(xml)
        /xmlns:itunes\s?=\s?\"http:\/\/www.itunes.com\/dtds\/podcast-1.0.dtd\"/i =~ xml
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
feedjira-1.1.0 lib/feedjira/parser/itunes_rss.rb
feedjira-1.0.0 lib/feedjira/parser/itunes_rss.rb
feedjira-0.9.0 lib/feedjira/parser/itunes_rss.rb