Created
November 11, 2011 20:53
-
-
Save cbguder/1359211 to your computer and use it in GitHub Desktop.
Growl notifier for rTorrent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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