rebuild.fmのRubyクライアントを書きました
Go言語版とemacs版があったのでそれを参考にしました。
リポジトリは
https://github.com/wyukawa/ruby-rebuildfm
です。
AppleScriptとiTunesを使って再生する関係上Macでしか動きません。
インストールはgemからします。
$ gem install rebuildfm
下記のようにしてrebuild.fmの一覧を見ることが出来ます。
$ rebuildfm list 1: Podcasting, LTSV, RubyMotion (伊藤直也) 2: Rails, Redis, VPS (Kenn Ejima) 3: MessagePack (frsyuki, kiyoto) ... 34: Snappy Links (naan) 35: You Don't Need API Version 2 (Kenn Ejima) 36: Hubot, Deploy this Pull Request (Naoya Ito)
この一覧は
http://feeds.rebuild.fm/rebuildfm
から取得しています。
rebuild.fmの36を聞きたい場合は下記のように実行します。Show Notesを表示した後にiTunesが起動します。
$ rebuildfm play 36 伊藤直也さん (@naoya_ito) をゲストに迎えて、JAWS、Vagrant Share、CoffeeScript、コードレビューなどについて話しました。 Show Notes * JAWS DAYS 2014、Immutable Infrastructure について * You don't need API version 2 - yohei's diary * Cookpad's deployment and auto scaling * Docker 0.9: introducing execution drivers and libcontainer | Docker Blog * Vagrant 1.5 and Vagrant Cloud - Vagrant * ngrok - secure introspectable tunnels to localhost * RequestBin - Collect, inspect and debug HTTP requests and webhooks * Idobata ★ * Idobata会議01 ★ * Hubot, Chat, The Web, and Working in the Open * Hands-on with GitHub's New Text Editor Atom * Why coffeescript? - Atom Discussion * 些末なコードレビュー * cookpad/styleguide * bbatsov/rubocop * Deploy feature branch to Heroku with CircleCI
内部的な話をするとrebuild.fmの36を聞く場合は下記コマンドをRubyから実行しています。
osascript -e 'tell application "iTunes"' -e 'open location "http://tracking.feedpress.it/link/1949/24392/podcast-ep36.mp3" play' -e 'end tell'
下記をファイルに保存してそれをosascriptで実行することでも実現できますが、ファイルに書き出すと後で消す処理も必要なのでワンライナーにしました。改行が入るとうまく実行できなかったのですが、-eを複数かけばいいみたいです。
tell application "iTunes" open location "http://tracking.feedpress.it/link/1949/24392/podcast-ep36.mp3" play end tell
止めたい場合は下記のようにします。pauseも最初実装したのですが、resumeのやり方が分からなかったので止めています。
$ rebuildfm stop
コマンドライン引数の処理にはthorを使っており、Show Notes部分の表示のために行うHTMLのparseにはnokogiriを使っています。
まあそんな感じです。
rake releaseがずっとうまくいかず困ってたんだけど原因は~/.gem/credentialsにちゃんとAPI keyが書かれていなかったというもの。しょぼーん。