iTunesで聞いてる曲をTwitterにPostするAppleScript
9/5追記
Twitterの認証方式の変更のため、スクリプトは動作しなくなりました。
代わりにこちらをどうぞ
iTunesで聞いてる曲をbrightkiteにPostするAppleScript - Macと愛猫
追記ここまで
http://tint.de/twitunes-applescriptからもらってきてちょっといじってみた。
変更点は、
-
- アルバム名とジャンルと評価をPostできるようにした。
- keychainを使うほど大げさなものではないので使わないようにした。
ダウンロードはこちら
http://files.lingurin.com/TwiTunes.scpt.zip
インストール方法は、
ダウンロードして解凍したスクリプトを
/Users/ユーザ名/ライブラリ/iTunes/scripts/
に放り込む。scriptsディレクトリが無かったら作って放り込む。
TwiTunes.scptをスクリプトエディタで開いて、
-
- 「ユーザ名:パスワード」となっている箇所をTwitterのアカウントとパスワードに変更
- change the status message to your liking here:のところを自分らしいメッセージに変更
して保存しておく。
使い方は、
iTunesで再生中に、メニューバーのスクリプトのマークからTwiTunesを選ぶとダイアログが出てくるのでOKを押すだけ。
以下スクリプトソース。
--TwiTunes -- get properties of the playing track --string replace sub function on replace(src, tg, rp) set oldDel to AppleScript's text item delimiters set AppleScript's text item delimiters to tg set myList to text items of src set AppleScript's text item delimiters to rp set myText to myList as string set AppleScript's text item delimiters to oldDel return myText end replace tell application "iTunes" set thisTrack to current track set trackName to the name of thisTrack set trackArtist to thisTrack's artist set trackAlbum to thisTrack's album set janru to thisTrack's genre set hoge to rating of current track end tell if hoge = 0 then set hoshi to "は未評価" end if if hoge = 20 then set hoshi to "★・・・・" end if if hoge = 40 then set hoshi to "★★・・・" end if if hoge = 60 then set hoshi to "★★★・・" end if if hoge = 80 then set hoshi to "★★★★・" end if if hoge = 100 then set hoshi to "★★★★★" end if -- change the status message to your liking here: set tweet to trackArtist & "の" & trackAlbum & "の" & trackName & "を聴いてる。ジャンルは" & janru & "。俺の評価" & hoshi & "。" set tweet to replace(tweet, "&", "&") -- let the user edit display dialog "Edit your Twitter status" with title "TwiTunes" default answer tweet cancel button 1 default button 2 buttons {"Cancel", "Send"} set tweet to (text returned of result) -- get login set twitter_login to "ユーザ名:パスワード" -- post to twitter set twitter_status to quoted form of ("status=" & tweet) set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json" display dialog "Twitter Status was updated. " & tweet with title "TwiTunes" default button 1 buttons "OK"