Skip to content

Instantly share code, notes, and snippets.

@cbguder
Created November 11, 2011 20:53
Show Gist options
  • Save cbguder/1359211 to your computer and use it in GitHub Desktop.
Save cbguder/1359211 to your computer and use it in GitHub Desktop.
Growl notifier for rTorrent
system.method.set_key = event.download.finished,notify_finished,"execute=rtorrentNotify,--finished,$d.get_name="
system.method.set_key = event.download.inserted_new,notify_inserted_new,"execute=rtorrentNotify,--inserted-new,$d.get_name="
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# rtorrentNotify: Growl notifier for rTorrent.
# Copyright (c) 2011 Can Berk Güder
#
import sys
import gntp.notifier
CONFIG = {
"hostname": "localhost",
"password": None
}
ACTIONS = {
"finished": "Download complete",
"inserted-new": "Torrent added"
}
def main():
if len(sys.argv) < 3:
usage()
action, name = sys.argv[1:3]
action = action.lstrip('-')
if action not in ACTIONS:
usage()
notify(action, name)
def usage():
print "USAGE: rtorrentNotify --finished TORRENT"
print " rtorrentNotify --inserted-new TORRENT"
sys.exit(2)
def notify(action, name):
growl = gntp.notifier.GrowlNotifier(
applicationName = "rTorrent",
notifications = ACTIONS.values(),
hostname = CONFIG["hostname"],
password = CONFIG["password"]
)
growl.register()
title = ACTIONS[action]
growl.notify(
noteType = title,
title = title,
description = name
)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment