1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-14 13:25:11 -05:00
SickRage/lib/growl/gntp_bridge.py
echel0n 0d9fbc1ad7 Welcome to our SickBeard-TVRage Edition ...
This version of SickBeard uses both TVDB and TVRage to search and gather it's series data from allowing you to now have access to and download shows that you couldn't before because of being locked into only what TheTVDB had to offer.

Also this edition is based off the code we used in our XEM editon so it does come with scene numbering support as well as all the other features our XEM edition has to offer.

Please before using this with your existing database (sickbeard.db) please make a backup copy of it and delete any other database files such as cache.db and failed.db if present, we HIGHLY recommend starting out with no database files at all to make this a fresh start but the choice is at your own risk!

Enjoy!
2014-03-09 22:39:12 -07:00

68 lines
1.8 KiB
Python

from gntp import *
import urllib
import Growl
def register_send(self):
'''
Resend a GNTP Register message to Growl running on a local OSX Machine
'''
print 'Sending Local Registration'
#Local growls only need a list of strings
notifications=[]
defaultNotifications = []
for notice in self.notifications:
notifications.append(notice['Notification-Name'])
if notice.get('Notification-Enabled',True):
defaultNotifications.append(notice['Notification-Name'])
appIcon = get_resource(self,'Application-Icon')
growl = Growl.GrowlNotifier(
applicationName = self.headers['Application-Name'],
notifications = notifications,
defaultNotifications = defaultNotifications,
applicationIcon = appIcon,
)
growl.register()
return self.encode()
def notice_send(self):
'''
Resend a GNTP Notify message to Growl running on a local OSX Machine
'''
print 'Sending Local Notification'
growl = Growl.GrowlNotifier(
applicationName = self.headers['Application-Name'],
notifications = [self.headers['Notification-Name']]
)
noticeIcon = get_resource(self,'Notification-Icon')
growl.notify(
noteType = self.headers['Notification-Name'],
title = self.headers['Notification-Title'],
description=self.headers.get('Notification-Text',''),
icon=noticeIcon
)
return self.encode()
def get_resource(self,key):
try:
resource = self.headers.get(key,'')
if resource.startswith('x-growl-resource://'):
resource = resource.split('://')
return self.resources.get(resource[1])['Data']
elif resource.startswith('http'):
resource = resource.replace(' ', '%20')
icon = urllib.urlopen(resource)
return icon.read()
else:
return None
except Exception,e:
print e
return None
GNTPRegister.send = register_send
GNTPNotice.send = notice_send