<commit_before>require 'open-uri'
require 'timeout'
require 'rexml/document'

module RPodcast
  class PodcastError < StandardError; end

  class Feed
    FEED_ATTRIBUTES = [:title, :link, :image, :summary, :language, :owner_email, :owner_name, :keywords, :categories]
    
    attr_accessor :feed, :episodes, :attributes

    def initialize(content, options={})
      @content = content
      @attributes = {}
      @episodes = []

      raise PodcastError, "This is not an RSS feed. Try again." unless @content =~ /^[\s]*<\?xml/

      @doc = parse_feed

      unless @content.nil?
        @episodes = RPodcast::Episode.parse(@content)
      end
    end

    def parse_feed
      doc = REXML::Document.new(@content)
      raise PodcastError, "This is not a podcast feed." unless REXML::XPath.first(doc, "//enclosure")

      FEED_ATTRIBUTES.each do |attribute|
        @attributes[attribute] = self.send("parse_#{attribute.to_s}", doc) rescue nil
      end

      doc
    end

    def parse_title(doc)
      get_text_from_element(doc, 'rss/channel/title')
    end
<commit_msg>Updated error messages a little bit<commit_after>require 'open-uri'
require 'timeout'
require 'rexml/document'

module RPodcast
  class PodcastError < StandardError; end

  class Feed
    FEED_ATTRIBUTES = [:title, :link, :image, :summary, :language, :owner_email, :owner_name, :keywords, :categories]
    
    attr_accessor :feed, :episodes, :attributes

    def initialize(content, options={})
      @content = content
      @attributes = {}
      @episodes = []

      raise PodcastError, "That's not an RSS feed." unless @content =~ /^[\s]*<\?xml/

      @doc = parse_feed

      unless @content.nil?
        @episodes = RPodcast::Episode.parse(@content)
      end
    end

    def parse_feed
      doc = REXML::Document.new(@content)
      raise PodcastError, "That's a text RSS feed, not an audio or video podcast." unless REXML::XPath.first(doc, "//enclosure")

      FEED_ATTRIBUTES.each do |attribute|
        @attributes[attribute] = self.send("parse_#{attribute.to_s}", doc) rescue nil
      end

      doc
    end

    def parse_title(doc)
      get_text_from_element(doc, 'rss/channel/title')
    end

{'fraction_non_alphanumeric': 0.12140575079872204, 'fraction_numerical': 0.0, 'mean_word_length': 3.097196261682243, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5483357', 'n_tokens_mistral': 719, 'n_tokens_neox': 693, 'n_words': 181}