Más contenido relacionado
RebuildDB -enable to search Rebuild.fm episodes-
- 6. schema.rb
ActiveRecord::Schema.define(version: 20150705144513) do
create_table "episodes", force: :cascade do |t|
t.string "episode_no"
t.string "title"
t.string "subtitle"
t.text "link"
t.text "description"
t.datetime "pubdate"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "shownotes", force: :cascade do |t|
t.integer "episode_id"
t.string "title"
t.string "url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
@jacoyutorius, 2015 6
- 8. rebuild.rake
url = "http://feeds.rebuild.fm/rebuildfm"
list = RSS::Parser.parse(url)
list.items.each do |row|
begin
episode_no = URI.parse(row.link).path.delete("/")
next if Episode.find_by(episode_no: episode_no)
episode = Episode.create(
episode_no: episode_no,
title: row.title,
subtitle: row.itunes_subtitle,
link: row.link,
description: row.description,
pubdate: row.pubDate
)
doc = Nokogiri::HTML.parse(row.description)
doc.css("li").each do |url|
episode.shownotes.create(
title: url.children.text,
url: url.children.css("a").first.attribute("href").value
)
end
ensure
end
end
@jacoyutorius, 2015 8