rebuilddb -enable to search rebuild.fm episodes-
TRANSCRIPT
Rebuild.fm DatabaseRebuild.fmいつも楽しく聴いていますが、1エピソードあたりの情報量がとても多く、話題が多岐に渡っているので、「あれ?あの話どのエピソードで話してたっけ・・・?」となることが多い。
@jacoyutorius, 2015 2
作り方4 RSSから全エピソードのタイトルとShownotesのタイトル及びURLが取得できるのでそれらをDB化
4 (本当は全ての会話をsearchableにしたいけど)4 DBを操作したいのとcronを使いたいのでRailsで4 getで条件を受け取って検索結果をjsonで返す
@jacoyutorius, 2015 4
schema.rbActiveRecord::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
rebuild.rakeurl = "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
curl https://rebuilddb.herokuapp.com/search?
title=ruby&shownotes_title=rubykaigi
@jacoyutorius, 2015 12
[ { id: null, episode_no: "10", title: "10: RailsConf, Ruby 2.0, Rails 4 (mrkn, r7kamura)", link: "http://rebuild.fm/10/" }]
@jacoyutorius, 2015 13
Console4 https://rebuilddb.herokuapp.com/
4 Rx.js
4 Web+DB Press vol85のサンプルコードそのまま
@jacoyutorius, 2015 15
URLhttps://rebuilddb.herokuapp.com/
Githubhttps://github.com/jacoyutorius/rebuild_database
@jacoyutorius, 2015 16