Created
January 19, 2020 11:48
-
-
Save nakiwo/a35d52776e75759653df41db76cde368 to your computer and use it in GitHub Desktop.
podcast_to_csv.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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