Skip to content

Add media and enclosure helpers #45

@cardmagic

Description

@cardmagic

Summary

Add helper methods to easily extract media content and enclosures from feeds, especially useful for podcast and media-heavy feeds.

Proposed Features

enclosures

Extract all enclosures (commonly used in podcasts):

def enclosures
  items.filter_map do |item|
    # Check for standard enclosure tag
    if item[:enclosure_url]
      {
        url: item[:enclosure_url],
        type: item[:enclosure_type],
        length: item[:enclosure_length],
        item: item
      }
    end
  end
end

Requires adding enclosure tags:

SimpleRSS.item_tags << :'enclosure#url'
SimpleRSS.item_tags << :'enclosure#type'
SimpleRSS.item_tags << :'enclosure#length'

images

Collect all image URLs from items:

def images
  items.filter_map do |item|
    item[:media_thumbnail_url] || item[:media_content_url]
  end.compact.uniq
end

Item-level helper

# Add to item hash via method_missing or explicit method
item.has_media?
item.media_url  # Returns first available media URL

Additional Tags to Support

Consider adding these to default @@item_tags:

  • enclosure#url, enclosure#type, enclosure#length
  • itunes:duration, itunes:image#href
  • media:description

Benefits

  • First-class podcast feed support
  • Easy media extraction for feed readers
  • Consistent interface across different media tag formats

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions