Friendfeed のエントリを Growl で表示
Friendfeed API を python から使い新規更新分のエントリを Growl に表示するスクリプトを作ったので公開。
friendfeed-api
http://code.google.com/p/friendfeed-api/
からライブラリを落としてきて python ディレクトリの friendfeed.py を使用。
自分の feed を取るのに remote key が必要なので、friendfeed にログインしたまま
https://friendfeed.com/account/api
にアクセスして入手。
python から Growl を使う方法はid:nishiohirokazuの[http://d.hatena.ne.jp/nishiohirokazu/20080318/12
05833455:title=PythonでGrowlを叩く]を参考。
Growl に表示する画像、もうちょっとサイズが大きいのがあればいいんだけど。
http://friendfeed.com/static/images/icons/internal.png
import time import datetime import Growl from friendfeed import FriendFeed def ffeed(nick, key): session = FriendFeed(auth_nickname=nick, auth_key=key) def homefeed(): return session.fetch_home_feed() return homefeed def main(): img = Growl.Image.imageFromPath('./internal.png') g = Growl.GrowlNotifier( applicationName='FFgrowl', notifications=['Entry'] ) g.register() recent_entry_time = datetime.datetime.now() homefeed = ffeed("user", "key") while True: feed = homefeed() for entry in feed["entries"]: if recent_entry_time < entry["published"]: g.notify( noteType='Entry', title='%s %s' % (entry["user"]["nickname"], entry["service"]["name"]), description=entry["title"].encode("latin-1"), icon=img, sticky=False) recent_entry_time = feed["entries"][0]["published"] time.sleep(60) if __name__ == "__main__": main()