jasonyork/podcast-index

It is recommended to identify the empty podcastindex feed to avoid undefined method `transform_keys' for []:Array (NoMethodError)

Closed this issue · 0 comments

Example:

pp PodcastIndex::Podcast.find(6361143)

undefined method `transform_keys' for []:Array (NoMethodError)

pp PodcastIndex::Api::Podcasts.by_feed_id(id: 6361143)

{"status"=>"true", "query"=>{"id"=>"6361143"}, "feed"=>[], "description"=>"No feeds match this id."}

/lib/podcast_index/podcast.rb

suggested to change to:

      def find(id)
        response = Api::Podcasts.by_feed_id(id: id)
        unless response["feed"].empty?
           from_response(response)
        else
           raise PodcastIndex::Error, "PodcastIndex: No feeds match this id." 
        end
      end