Skip to content

Instantly share code, notes, and snippets.

@nakiwo
Created January 19, 2020 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakiwo/a35d52776e75759653df41db76cde368 to your computer and use it in GitHub Desktop.
Save nakiwo/a35d52776e75759653df41db76cde368 to your computer and use it in GitHub Desktop.
podcast_to_csv.rb
require 'rss'
require "csv"
rss_source = File.new('feed.xml')
rss = RSS::Parser.parse(rss_source, false)
CSV.open('test.csv','w') do |csv|
rss.items.each do |item|
title = item.title
date = item.pubDate.localtime.strftime('%Y/%m/%d')
duration = if item.itunes_duration then
sprintf('%02d:%02d:%02d', item.itunes_duration.hour, item.itunes_duration.minute, item.itunes_duration.second)
else
''
end
link = item.link
summary = item.itunes_summary
csv << [date, title, duration, link, summary]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment