mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change notifier code to follow quotation standards
This commit is contained in:
parent
03defe0219
commit
5cc1855b73
15 changed files with 232 additions and 232 deletions
|
@ -103,6 +103,6 @@ def notify_snatch(ep_name):
|
|||
n.notify_snatch(ep_name)
|
||||
|
||||
|
||||
def notify_git_update(new_version=""):
|
||||
def notify_git_update(new_version=''):
|
||||
for n in notifiers:
|
||||
n.notify_git_update(new_version)
|
||||
|
|
|
@ -43,7 +43,7 @@ class EmailNotifier:
|
|||
msg['To'] = to
|
||||
return self._sendmail(host, port, smtp_from, use_tls, user, pwd, [to], msg, True)
|
||||
|
||||
def notify_snatch(self, ep_name, title="Snatched:"):
|
||||
def notify_snatch(self, ep_name, title='Snatched:'):
|
||||
"""
|
||||
Send a notification that an episode was snatched
|
||||
|
||||
|
@ -62,8 +62,8 @@ class EmailNotifier:
|
|||
msg = MIMEMultipart('alternative')
|
||||
msg.attach(MIMEText(
|
||||
"<body style='font-family:Helvetica, Arial, sans-serif;'><h3>SickGear Notification - Snatched</h3>\n<p>Show: <b>" + re.search(
|
||||
"(.+?) -.+", ep_name).group(1) + "</b></p>\n<p>Episode: <b>" + re.search(
|
||||
".+ - (.+?-.+) -.+", ep_name).group(
|
||||
'(.+?) -.+', ep_name).group(1) + '</b></p>\n<p>Episode: <b>' + re.search(
|
||||
'.+ - (.+?-.+) -.+', ep_name).group(
|
||||
1) + "</b></p>\n\n<footer style='margin-top: 2.5em; padding: .7em 0; color: #777; border-top: #BBB solid 1px;'>Powered by SickGear.</footer></body>",
|
||||
'html'))
|
||||
except:
|
||||
|
@ -74,11 +74,11 @@ class EmailNotifier:
|
|||
msg['To'] = ','.join(to)
|
||||
if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS,
|
||||
sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
|
||||
logger.log("Snatch notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
|
||||
logger.log('Snatch notification sent to [%s] for "%s"' % (to, ep_name), logger.DEBUG)
|
||||
else:
|
||||
logger.log("Snatch notification ERROR: %s" % self.last_err, logger.ERROR)
|
||||
logger.log('Snatch notification ERROR: %s' % self.last_err, logger.ERROR)
|
||||
|
||||
def notify_download(self, ep_name, title="Completed:"):
|
||||
def notify_download(self, ep_name, title='Completed:'):
|
||||
"""
|
||||
Send a notification that an episode was downloaded
|
||||
|
||||
|
@ -97,8 +97,8 @@ class EmailNotifier:
|
|||
msg = MIMEMultipart('alternative')
|
||||
msg.attach(MIMEText(
|
||||
"<body style='font-family:Helvetica, Arial, sans-serif;'><h3>SickGear Notification - Downloaded</h3>\n<p>Show: <b>" + re.search(
|
||||
"(.+?) -.+", ep_name).group(1) + "</b></p>\n<p>Episode: <b>" + re.search(
|
||||
".+ - (.+?-.+) -.+", ep_name).group(
|
||||
'(.+?) -.+', ep_name).group(1) + '</b></p>\n<p>Episode: <b>' + re.search(
|
||||
'.+ - (.+?-.+) -.+', ep_name).group(
|
||||
1) + "</b></p>\n\n<footer style='margin-top: 2.5em; padding: .7em 0; color: #777; border-top: #BBB solid 1px;'>Powered by SickGear.</footer></body>",
|
||||
'html'))
|
||||
except:
|
||||
|
@ -109,11 +109,11 @@ class EmailNotifier:
|
|||
msg['To'] = ','.join(to)
|
||||
if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS,
|
||||
sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
|
||||
logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
|
||||
logger.log('Download notification sent to [%s] for "%s"' % (to, ep_name), logger.DEBUG)
|
||||
else:
|
||||
logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
|
||||
logger.log('Download notification ERROR: %s' % self.last_err, logger.ERROR)
|
||||
|
||||
def notify_subtitle_download(self, ep_name, lang, title="Downloaded subtitle:"):
|
||||
def notify_subtitle_download(self, ep_name, lang, title='Downloaded subtitle:'):
|
||||
"""
|
||||
Send a notification that an subtitle was downloaded
|
||||
|
||||
|
@ -132,24 +132,24 @@ class EmailNotifier:
|
|||
msg = MIMEMultipart('alternative')
|
||||
msg.attach(MIMEText(
|
||||
"<body style='font-family:Helvetica, Arial, sans-serif;'><h3>SickGear Notification - Subtitle Downloaded</h3>\n<p>Show: <b>" + re.search(
|
||||
"(.+?) -.+", ep_name).group(1) + "</b></p>\n<p>Episode: <b>" + re.search(
|
||||
".+ - (.+?-.+) -.+", ep_name).group(
|
||||
1) + "</b></p>\n<p>Language: <b>" + lang + "</b></p>\n\n<footer style='margin-top: 2.5em; padding: .7em 0; color: #777; border-top: #BBB solid 1px;'>Powered by SickGear.</footer></body>",
|
||||
'(.+?) -.+', ep_name).group(1) + '</b></p>\n<p>Episode: <b>' + re.search(
|
||||
'.+ - (.+?-.+) -.+', ep_name).group(
|
||||
1) + '</b></p>\n<p>Language: <b>' + lang + "</b></p>\n\n<footer style='margin-top: 2.5em; padding: .7em 0; color: #777; border-top: #BBB solid 1px;'>Powered by SickGear.</footer></body>",
|
||||
'html'))
|
||||
except:
|
||||
msg = MIMEText(ep_name + ": " + lang)
|
||||
msg = MIMEText(ep_name + ': ' + lang)
|
||||
|
||||
msg['Subject'] = lang + ' Subtitle Downloaded: ' + ep_name
|
||||
msg['From'] = sickbeard.EMAIL_FROM
|
||||
msg['To'] = ','.join(to)
|
||||
if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS,
|
||||
sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
|
||||
logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
|
||||
logger.log('Download notification sent to [%s] for "%s"' % (to, ep_name), logger.DEBUG)
|
||||
else:
|
||||
logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
|
||||
logger.log('Download notification ERROR: %s' % self.last_err, logger.ERROR)
|
||||
|
||||
|
||||
def notify_git_update(self, new_version="??"):
|
||||
def notify_git_update(self, new_version='??'):
|
||||
pass
|
||||
|
||||
def _generate_recepients(self, show):
|
||||
|
@ -163,7 +163,7 @@ class EmailNotifier:
|
|||
# Grab the recipients for the show
|
||||
myDB = db.DBConnection()
|
||||
for s in show:
|
||||
for subs in myDB.select("SELECT notify_list FROM tv_shows WHERE show_name = ?", (s,)):
|
||||
for subs in myDB.select('SELECT notify_list FROM tv_shows WHERE show_name = ?', (s,)):
|
||||
if subs['notify_list']:
|
||||
for addr in subs['notify_list'].split(','):
|
||||
if (len(addr.strip()) > 0):
|
||||
|
@ -199,10 +199,10 @@ class EmailNotifier:
|
|||
def _parseEp(self, ep_name):
|
||||
ep_name = ep_name.encode('utf-8', 'replace')
|
||||
|
||||
sep = " - "
|
||||
sep = ' - '
|
||||
titles = ep_name.split(sep)
|
||||
titles.sort(key=len, reverse=True)
|
||||
logger.log("TITLES: %s" % titles, logger.DEBUG)
|
||||
logger.log('TITLES: %s' % titles, logger.DEBUG)
|
||||
return titles
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ from lib.growl import gntp
|
|||
class GrowlNotifier:
|
||||
def test_notify(self, host, password):
|
||||
self._sendRegistration(host, password, 'Test')
|
||||
return self._sendGrowl("Test Growl", "Testing Growl settings from SickGear", "Test", host, password,
|
||||
return self._sendGrowl('Test Growl', 'Testing Growl settings from SickGear', 'Test', host, password,
|
||||
force=True)
|
||||
|
||||
def notify_snatch(self, ep_name):
|
||||
|
@ -43,9 +43,9 @@ class GrowlNotifier:
|
|||
|
||||
def notify_subtitle_download(self, ep_name, lang):
|
||||
if sickbeard.GROWL_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||
self._sendGrowl(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], ep_name + ": " + lang)
|
||||
self._sendGrowl(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], ep_name + ': ' + lang)
|
||||
|
||||
def notify_git_update(self, new_version = "??"):
|
||||
def notify_git_update(self, new_version = '??'):
|
||||
if sickbeard.USE_GROWL:
|
||||
update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT]
|
||||
title=common.notifyStrings[common.NOTIFY_GIT_UPDATE]
|
||||
|
@ -93,7 +93,7 @@ class GrowlNotifier:
|
|||
|
||||
return response
|
||||
|
||||
def _sendGrowl(self, title="SickGear Notification", message=None, name=None, host=None, password=None,
|
||||
def _sendGrowl(self, title='SickGear Notification', message=None, name=None, host=None, password=None,
|
||||
force=False):
|
||||
if not sickbeard.USE_GROWL and not force:
|
||||
return False
|
||||
|
@ -134,7 +134,7 @@ class GrowlNotifier:
|
|||
for pc in growlHosts:
|
||||
opts['host'] = pc[0]
|
||||
opts['port'] = pc[1]
|
||||
logger.log(u"GROWL: Sending message '" + message + "' to " + opts['host'] + ":" + str(opts['port']), logger.DEBUG)
|
||||
logger.log(u'GROWL: Sending message "' + message + '" to ' + opts['host'] + ':' + str(opts['port']), logger.DEBUG)
|
||||
try:
|
||||
if self._send_growl(opts, message):
|
||||
return True
|
||||
|
@ -144,7 +144,7 @@ class GrowlNotifier:
|
|||
else:
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.log(u"GROWL: Unable to send growl to " + opts['host'] + ":" + str(opts['port']) + " - " + ex(e), logger.WARNING)
|
||||
logger.log(u'GROWL: Unable to send growl to ' + opts['host'] + ':' + str(opts['port']) + ' - ' + ex(e), logger.WARNING)
|
||||
return False
|
||||
|
||||
def _sendRegistration(self, host=None, password=None, name='SickGear Notification'):
|
||||
|
@ -188,7 +188,7 @@ class GrowlNotifier:
|
|||
try:
|
||||
return self._send(opts['host'], opts['port'], register.encode(), opts['debug'])
|
||||
except Exception as e:
|
||||
logger.log(u"GROWL: Unable to send growl to " + opts['host'] + ":" + str(opts['port']) + " - " + ex(e), logger.WARNING)
|
||||
logger.log(u'GROWL: Unable to send growl to ' + opts['host'] + ':' + str(opts['port']) + ' - ' + ex(e), logger.WARNING)
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from lib.pynma import pynma
|
|||
|
||||
class NMA_Notifier:
|
||||
def test_notify(self, nma_api, nma_priority):
|
||||
return self._sendNMA(nma_api, nma_priority, event="Test", message="Testing NMA settings from SickGear",
|
||||
return self._sendNMA(nma_api, nma_priority, event='Test', message='Testing NMA settings from SickGear',
|
||||
force=True)
|
||||
|
||||
def notify_snatch(self, ep_name):
|
||||
|
@ -22,9 +22,9 @@ class NMA_Notifier:
|
|||
def notify_subtitle_download(self, ep_name, lang):
|
||||
if sickbeard.NMA_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||
self._sendNMA(nma_api=None, nma_priority=None, event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD],
|
||||
message=ep_name + ": " + lang)
|
||||
message=ep_name + ': ' + lang)
|
||||
|
||||
def notify_git_update(self, new_version = "??"):
|
||||
def notify_git_update(self, new_version = '??'):
|
||||
if sickbeard.USE_NMA:
|
||||
update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT]
|
||||
title=common.notifyStrings[common.NOTIFY_GIT_UPDATE]
|
||||
|
@ -51,14 +51,14 @@ class NMA_Notifier:
|
|||
|
||||
if len(keys) > 1: batch = True
|
||||
|
||||
logger.log("NMA: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, batch=%s" % (event, message, nma_priority, batch), logger.DEBUG)
|
||||
logger.log('NMA: Sending notice with details: event="%s", message="%s", priority=%s, batch=%s' % (event, message, nma_priority, batch), logger.DEBUG)
|
||||
response = p.push(title, event, message, priority=nma_priority, batch_mode=batch)
|
||||
|
||||
if not response[nma_api][u'code'] == u'200':
|
||||
logger.log(u'Could not send notification to NotifyMyAndroid', logger.ERROR)
|
||||
return False
|
||||
else:
|
||||
logger.log(u"NMA: Notification sent to NotifyMyAndroid", logger.MESSAGE)
|
||||
logger.log(u'NMA: Notification sent to NotifyMyAndroid', logger.MESSAGE)
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -45,41 +45,41 @@ class NMJNotifier:
|
|||
try:
|
||||
terminal = telnetlib.Telnet(host)
|
||||
except Exception:
|
||||
logger.log(u"Warning: unable to get a telnet session to %s" % (host), logger.WARNING)
|
||||
logger.log(u'Warning: unable to get a telnet session to %s' % (host), logger.WARNING)
|
||||
return False
|
||||
|
||||
# tell the terminal to output the necessary info to the screen so we can search it later
|
||||
logger.log(u"Connected to %s via telnet" % (host), logger.DEBUG)
|
||||
terminal.read_until("sh-3.00# ")
|
||||
terminal.write("cat /tmp/source\n")
|
||||
terminal.write("cat /tmp/netshare\n")
|
||||
terminal.write("exit\n")
|
||||
logger.log(u'Connected to %s via telnet' % (host), logger.DEBUG)
|
||||
terminal.read_until('sh-3.00# ')
|
||||
terminal.write('cat /tmp/source\n')
|
||||
terminal.write('cat /tmp/netshare\n')
|
||||
terminal.write('exit\n')
|
||||
tnoutput = terminal.read_all()
|
||||
|
||||
database = ""
|
||||
device = ""
|
||||
match = re.search(r"(.+\.db)\r\n?(.+)(?=sh-3.00# cat /tmp/netshare)", tnoutput)
|
||||
database = ''
|
||||
device = ''
|
||||
match = re.search(r'(.+\.db)\r\n?(.+)(?=sh-3.00# cat /tmp/netshare)', tnoutput)
|
||||
|
||||
# if we found the database in the terminal output then save that database to the config
|
||||
if match:
|
||||
database = match.group(1)
|
||||
device = match.group(2)
|
||||
logger.log(u"Found NMJ database %s on device %s" % (database, device), logger.DEBUG)
|
||||
logger.log(u'Found NMJ database %s on device %s' % (database, device), logger.DEBUG)
|
||||
sickbeard.NMJ_DATABASE = database
|
||||
else:
|
||||
logger.log(u"Could not get current NMJ database on %s, NMJ is probably not running!" % (host), logger.WARNING)
|
||||
logger.log(u'Could not get current NMJ database on %s, NMJ is probably not running!' % (host), logger.WARNING)
|
||||
return False
|
||||
|
||||
# if the device is a remote host then try to parse the mounting URL and save it to the config
|
||||
if device.startswith("NETWORK_SHARE/"):
|
||||
match = re.search(".*(?=\r\n?%s)" % (re.escape(device[14:])), tnoutput)
|
||||
if device.startswith('NETWORK_SHARE/'):
|
||||
match = re.search('.*(?=\r\n?%s)' % (re.escape(device[14:])), tnoutput)
|
||||
|
||||
if match:
|
||||
mount = match.group().replace("127.0.0.1", host)
|
||||
logger.log(u"Found mounting url on the Popcorn Hour in configuration: %s" % (mount), logger.DEBUG)
|
||||
mount = match.group().replace('127.0.0.1', host)
|
||||
logger.log(u'Found mounting url on the Popcorn Hour in configuration: %s' % (mount), logger.DEBUG)
|
||||
sickbeard.NMJ_MOUNT = mount
|
||||
else:
|
||||
logger.log(u"Detected a network share on the Popcorn Hour, but could not get the mounting url",
|
||||
logger.log(u'Detected a network share on the Popcorn Hour, but could not get the mounting url',
|
||||
logger.WARNING)
|
||||
return False
|
||||
|
||||
|
@ -119,59 +119,59 @@ class NMJNotifier:
|
|||
if mount:
|
||||
try:
|
||||
req = urllib2.Request(mount)
|
||||
logger.log(u"Try to mount network drive via url: %s" % (mount), logger.DEBUG)
|
||||
logger.log(u'Try to mount network drive via url: %s' % (mount), logger.DEBUG)
|
||||
handle = urllib2.urlopen(req)
|
||||
except IOError as e:
|
||||
if hasattr(e, 'reason'):
|
||||
logger.log(u"NMJ: Could not contact Popcorn Hour on host %s: %s" % (host, e.reason), logger.WARNING)
|
||||
logger.log(u'NMJ: Could not contact Popcorn Hour on host %s: %s' % (host, e.reason), logger.WARNING)
|
||||
elif hasattr(e, 'code'):
|
||||
logger.log(u"NMJ: Problem with Popcorn Hour on host %s: %s" % (host, e.code), logger.WARNING)
|
||||
logger.log(u'NMJ: Problem with Popcorn Hour on host %s: %s' % (host, e.code), logger.WARNING)
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.log(u"NMJ: Unknown exception: " + ex(e), logger.ERROR)
|
||||
logger.log(u'NMJ: Unknown exception: ' + ex(e), logger.ERROR)
|
||||
return False
|
||||
|
||||
# build up the request URL and parameters
|
||||
UPDATE_URL = "http://%(host)s:8008/metadata_database?%(params)s"
|
||||
UPDATE_URL = 'http://%(host)s:8008/metadata_database?%(params)s'
|
||||
params = {
|
||||
"arg0": "scanner_start",
|
||||
"arg1": database,
|
||||
"arg2": "background",
|
||||
"arg3": ""
|
||||
'arg0': 'scanner_start',
|
||||
'arg1': database,
|
||||
'arg2': 'background',
|
||||
'arg3': ''
|
||||
}
|
||||
params = urllib.urlencode(params)
|
||||
updateUrl = UPDATE_URL % {"host": host, "params": params}
|
||||
updateUrl = UPDATE_URL % {'host': host, 'params': params}
|
||||
|
||||
# send the request to the server
|
||||
try:
|
||||
req = urllib2.Request(updateUrl)
|
||||
logger.log(u"Sending NMJ scan update command via url: %s" % (updateUrl), logger.DEBUG)
|
||||
logger.log(u'Sending NMJ scan update command via url: %s' % (updateUrl), logger.DEBUG)
|
||||
handle = urllib2.urlopen(req)
|
||||
response = handle.read()
|
||||
except IOError as e:
|
||||
if hasattr(e, 'reason'):
|
||||
logger.log(u"NMJ: Could not contact Popcorn Hour on host %s: %s" % (host, e.reason), logger.WARNING)
|
||||
logger.log(u'NMJ: Could not contact Popcorn Hour on host %s: %s' % (host, e.reason), logger.WARNING)
|
||||
elif hasattr(e, 'code'):
|
||||
logger.log(u"NMJ: Problem with Popcorn Hour on host %s: %s" % (host, e.code), logger.WARNING)
|
||||
logger.log(u'NMJ: Problem with Popcorn Hour on host %s: %s' % (host, e.code), logger.WARNING)
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.log(u"NMJ: Unknown exception: " + ex(e), logger.ERROR)
|
||||
logger.log(u'NMJ: Unknown exception: ' + ex(e), logger.ERROR)
|
||||
return False
|
||||
|
||||
# try to parse the resulting XML
|
||||
try:
|
||||
et = etree.fromstring(response)
|
||||
result = et.findtext("returnValue")
|
||||
result = et.findtext('returnValue')
|
||||
except SyntaxError as e:
|
||||
logger.log(u"Unable to parse XML returned from the Popcorn Hour: %s" % (e), logger.ERROR)
|
||||
logger.log(u'Unable to parse XML returned from the Popcorn Hour: %s' % (e), logger.ERROR)
|
||||
return False
|
||||
|
||||
# if the result was a number then consider that an error
|
||||
if int(result) > 0:
|
||||
logger.log(u"Popcorn Hour returned an errorcode: %s" % (result), logger.ERROR)
|
||||
logger.log(u'Popcorn Hour returned an errorcode: %s' % (result), logger.ERROR)
|
||||
return False
|
||||
else:
|
||||
logger.log(u"NMJ started background scan", logger.MESSAGE)
|
||||
logger.log(u'NMJ started background scan', logger.MESSAGE)
|
||||
return True
|
||||
|
||||
def _notifyNMJ(self, host=None, database=None, mount=None, force=False):
|
||||
|
@ -184,7 +184,7 @@ class NMJNotifier:
|
|||
force: If True then the notification will be sent even if NMJ is disabled in the config
|
||||
"""
|
||||
if not sickbeard.USE_NMJ and not force:
|
||||
logger.log("Notification for NMJ scan update not enabled, skipping this notification", logger.DEBUG)
|
||||
logger.log('Notification for NMJ scan update not enabled, skipping this notification', logger.DEBUG)
|
||||
return False
|
||||
|
||||
# fill in omitted parameters
|
||||
|
@ -195,7 +195,7 @@ class NMJNotifier:
|
|||
if not mount:
|
||||
mount = sickbeard.NMJ_MOUNT
|
||||
|
||||
logger.log(u"Sending scan command for NMJ ", logger.DEBUG)
|
||||
logger.log(u'Sending scan command for NMJ ', logger.DEBUG)
|
||||
|
||||
return self._sendNMJ(host, database, mount)
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class NMJv2Notifier:
|
|||
Returns: True if the settings were retrieved successfully, False otherwise
|
||||
"""
|
||||
try:
|
||||
url_loc = "http://" + host + ":8008/file_operation?arg0=list_user_storage_file&arg1=&arg2=" + instance + "&arg3=20&arg4=true&arg5=true&arg6=true&arg7=all&arg8=name_asc&arg9=false&arg10=false"
|
||||
url_loc = 'http://' + host + ':8008/file_operation?arg0=list_user_storage_file&arg1=&arg2=' + instance + '&arg3=20&arg4=true&arg5=true&arg6=true&arg7=all&arg8=name_asc&arg9=false&arg10=false'
|
||||
req = urllib2.Request(url_loc)
|
||||
handle1 = urllib2.urlopen(req)
|
||||
response1 = handle1.read()
|
||||
|
@ -70,22 +70,22 @@ class NMJv2Notifier:
|
|||
for node in xml.getElementsByTagName('path'):
|
||||
xmlTag = node.toxml();
|
||||
xmlData = xmlTag.replace('<path>', '').replace('</path>', '').replace('[=]', '')
|
||||
url_db = "http://" + host + ":8008/metadata_database?arg0=check_database&arg1=" + xmlData
|
||||
url_db = 'http://' + host + ':8008/metadata_database?arg0=check_database&arg1=' + xmlData
|
||||
reqdb = urllib2.Request(url_db)
|
||||
handledb = urllib2.urlopen(reqdb)
|
||||
responsedb = handledb.read()
|
||||
xmldb = parseString(responsedb)
|
||||
returnvalue = xmldb.getElementsByTagName('returnValue')[0].toxml().replace('<returnValue>', '').replace(
|
||||
'</returnValue>', '')
|
||||
if returnvalue == "0":
|
||||
if returnvalue == '0':
|
||||
DB_path = xmldb.getElementsByTagName('database_path')[0].toxml().replace('<database_path>',
|
||||
'').replace(
|
||||
'</database_path>', '').replace('[=]', '')
|
||||
if dbloc == "local" and DB_path.find("localhost") > -1:
|
||||
if dbloc == 'local' and DB_path.find('localhost') > -1:
|
||||
sickbeard.NMJv2_HOST = host
|
||||
sickbeard.NMJv2_DATABASE = DB_path
|
||||
return True
|
||||
if dbloc == "network" and DB_path.find("://") > -1:
|
||||
if dbloc == 'network' and DB_path.find('://') > -1:
|
||||
sickbeard.NMJv2_HOST = host
|
||||
sickbeard.NMJv2_DATABASE = DB_path
|
||||
return True
|
||||
|
@ -108,10 +108,10 @@ class NMJv2Notifier:
|
|||
|
||||
#if a host is provided then attempt to open a handle to that URL
|
||||
try:
|
||||
url_scandir = "http://" + host + ":8008/metadata_database?arg0=update_scandir&arg1=" + sickbeard.NMJv2_DATABASE + "&arg2=&arg3=update_all"
|
||||
logger.log(u"NMJ scan update command sent to host: %s" % (host), logger.DEBUG)
|
||||
url_updatedb = "http://" + host + ":8008/metadata_database?arg0=scanner_start&arg1=" + sickbeard.NMJv2_DATABASE + "&arg2=background&arg3="
|
||||
logger.log(u"Try to mount network drive via url: %s" % (host), logger.DEBUG)
|
||||
url_scandir = 'http://' + host + ':8008/metadata_database?arg0=update_scandir&arg1=' + sickbeard.NMJv2_DATABASE + '&arg2=&arg3=update_all'
|
||||
logger.log(u'NMJ scan update command sent to host: %s' % (host), logger.DEBUG)
|
||||
url_updatedb = 'http://' + host + ':8008/metadata_database?arg0=scanner_start&arg1=' + sickbeard.NMJv2_DATABASE + '&arg2=background&arg3='
|
||||
logger.log(u'Try to mount network drive via url: %s' % (host), logger.DEBUG)
|
||||
prereq = urllib2.Request(url_scandir)
|
||||
req = urllib2.Request(url_updatedb)
|
||||
handle1 = urllib2.urlopen(prereq)
|
||||
|
@ -124,37 +124,37 @@ class NMJv2Notifier:
|
|||
return False
|
||||
try:
|
||||
et = etree.fromstring(response1)
|
||||
result1 = et.findtext("returnValue")
|
||||
result1 = et.findtext('returnValue')
|
||||
except SyntaxError as e:
|
||||
logger.log(u"Unable to parse XML returned from the Popcorn Hour: update_scandir, %s" % (e), logger.ERROR)
|
||||
logger.log(u'Unable to parse XML returned from the Popcorn Hour: update_scandir, %s' % (e), logger.ERROR)
|
||||
return False
|
||||
try:
|
||||
et = etree.fromstring(response2)
|
||||
result2 = et.findtext("returnValue")
|
||||
result2 = et.findtext('returnValue')
|
||||
except SyntaxError as e:
|
||||
logger.log(u"Unable to parse XML returned from the Popcorn Hour: scanner_start, %s" % (e), logger.ERROR)
|
||||
logger.log(u'Unable to parse XML returned from the Popcorn Hour: scanner_start, %s' % (e), logger.ERROR)
|
||||
return False
|
||||
|
||||
# if the result was a number then consider that an error
|
||||
error_codes = ["8", "11", "22", "49", "50", "51", "60"]
|
||||
error_messages = ["Invalid parameter(s)/argument(s)",
|
||||
"Invalid database path",
|
||||
"Insufficient size",
|
||||
"Database write error",
|
||||
"Database read error",
|
||||
"Open fifo pipe failed",
|
||||
"Read only file system"]
|
||||
error_codes = ['8', '11', '22', '49', '50', '51', '60']
|
||||
error_messages = ['Invalid parameter(s)/argument(s)',
|
||||
'Invalid database path',
|
||||
'Insufficient size',
|
||||
'Database write error',
|
||||
'Database read error',
|
||||
'Open fifo pipe failed',
|
||||
'Read only file system']
|
||||
if int(result1) > 0:
|
||||
index = error_codes.index(result1)
|
||||
logger.log(u"Popcorn Hour returned an error: %s" % (error_messages[index]), logger.ERROR)
|
||||
logger.log(u'Popcorn Hour returned an error: %s' % (error_messages[index]), logger.ERROR)
|
||||
return False
|
||||
else:
|
||||
if int(result2) > 0:
|
||||
index = error_codes.index(result2)
|
||||
logger.log(u"Popcorn Hour returned an error: %s" % (error_messages[index]), logger.ERROR)
|
||||
logger.log(u'Popcorn Hour returned an error: %s' % (error_messages[index]), logger.ERROR)
|
||||
return False
|
||||
else:
|
||||
logger.log(u"NMJv2 started background scan", logger.MESSAGE)
|
||||
logger.log(u'NMJv2 started background scan', logger.MESSAGE)
|
||||
return True
|
||||
|
||||
def _notifyNMJ(self, host=None, force=False):
|
||||
|
@ -167,14 +167,14 @@ class NMJv2Notifier:
|
|||
force: If True then the notification will be sent even if NMJ is disabled in the config
|
||||
"""
|
||||
if not sickbeard.USE_NMJv2 and not force:
|
||||
logger.log("Notification for NMJ scan update not enabled, skipping this notification", logger.DEBUG)
|
||||
logger.log('Notification for NMJ scan update not enabled, skipping this notification', logger.DEBUG)
|
||||
return False
|
||||
|
||||
# fill in omitted parameters
|
||||
if not host:
|
||||
host = sickbeard.NMJv2_HOST
|
||||
|
||||
logger.log(u"Sending scan command for NMJ ", logger.DEBUG)
|
||||
logger.log(u'Sending scan command for NMJ ', logger.DEBUG)
|
||||
|
||||
return self._sendNMJ(host)
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ from sickbeard import logger, common
|
|||
|
||||
class ProwlNotifier:
|
||||
def test_notify(self, prowl_api, prowl_priority):
|
||||
return self._sendProwl(prowl_api, prowl_priority, event="Test",
|
||||
message="Testing Prowl settings from SickGear", force=True)
|
||||
return self._sendProwl(prowl_api, prowl_priority, event='Test',
|
||||
message='Testing Prowl settings from SickGear', force=True)
|
||||
|
||||
def notify_snatch(self, ep_name):
|
||||
if sickbeard.PROWL_NOTIFY_ONSNATCH:
|
||||
|
@ -52,9 +52,9 @@ class ProwlNotifier:
|
|||
def notify_subtitle_download(self, ep_name, lang):
|
||||
if sickbeard.PROWL_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||
self._sendProwl(prowl_api=None, prowl_priority=None,
|
||||
event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], message=ep_name + ": " + lang)
|
||||
event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], message=ep_name + ': ' + lang)
|
||||
|
||||
def notify_git_update(self, new_version = "??"):
|
||||
def notify_git_update(self, new_version = '??'):
|
||||
if sickbeard.USE_PROWL:
|
||||
update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT]
|
||||
title=common.notifyStrings[common.NOTIFY_GIT_UPDATE]
|
||||
|
@ -72,11 +72,11 @@ class ProwlNotifier:
|
|||
if prowl_priority == None:
|
||||
prowl_priority = sickbeard.PROWL_PRIORITY
|
||||
|
||||
title = "SickGear"
|
||||
title = 'SickGear'
|
||||
|
||||
logger.log("PROWL: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, api=%s" % (event, message, prowl_priority, prowl_api), logger.DEBUG)
|
||||
logger.log('PROWL: Sending notice with details: event="%s", message="%s", priority=%s, api=%s' % (event, message, prowl_priority, prowl_api), logger.DEBUG)
|
||||
|
||||
http_handler = moves.http_client.HTTPSConnection("api.prowlapp.com")
|
||||
http_handler = moves.http_client.HTTPSConnection('api.prowlapp.com')
|
||||
|
||||
data = {'apikey': prowl_api,
|
||||
'application': title,
|
||||
|
@ -85,24 +85,24 @@ class ProwlNotifier:
|
|||
'priority': prowl_priority}
|
||||
|
||||
try:
|
||||
http_handler.request("POST",
|
||||
"/publicapi/add",
|
||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||
http_handler.request('POST',
|
||||
'/publicapi/add',
|
||||
headers={'Content-type': 'application/x-www-form-urlencoded'},
|
||||
body=urlencode(data))
|
||||
except (SSLError, moves.http_client.HTTPException, socket.error):
|
||||
logger.log(u"Prowl notification failed.", logger.ERROR)
|
||||
logger.log(u'Prowl notification failed.', logger.ERROR)
|
||||
return False
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
|
||||
if request_status == 200:
|
||||
logger.log(u"Prowl notifications sent.", logger.MESSAGE)
|
||||
logger.log(u'Prowl notifications sent.', logger.MESSAGE)
|
||||
return True
|
||||
elif request_status == 401:
|
||||
logger.log(u"Prowl authentication failed: %s" % response.reason, logger.ERROR)
|
||||
logger.log(u'Prowl authentication failed: %s' % response.reason, logger.ERROR)
|
||||
return False
|
||||
else:
|
||||
logger.log(u"Prowl notification failed.", logger.ERROR)
|
||||
logger.log(u'Prowl notification failed.', logger.ERROR)
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ from sickbeard import logger, common
|
|||
|
||||
class PushalotNotifier:
|
||||
def test_notify(self, pushalot_authorizationtoken):
|
||||
return self._sendPushalot(pushalot_authorizationtoken, event="Test",
|
||||
message="Testing Pushalot settings from SickGear", force=True)
|
||||
return self._sendPushalot(pushalot_authorizationtoken, event='Test',
|
||||
message='Testing Pushalot settings from SickGear', force=True)
|
||||
|
||||
def notify_snatch(self, ep_name):
|
||||
if sickbeard.PUSHALOT_NOTIFY_ONSNATCH:
|
||||
|
@ -46,9 +46,9 @@ class PushalotNotifier:
|
|||
if sickbeard.PUSHALOT_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||
self._sendPushalot(pushalot_authorizationtoken=None,
|
||||
event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD],
|
||||
message=ep_name + ": " + lang)
|
||||
message=ep_name + ': ' + lang)
|
||||
|
||||
def notify_git_update(self, new_version = "??"):
|
||||
def notify_git_update(self, new_version = '??'):
|
||||
if sickbeard.USE_PUSHALOT:
|
||||
update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT]
|
||||
title=common.notifyStrings[common.NOTIFY_GIT_UPDATE]
|
||||
|
@ -64,35 +64,35 @@ class PushalotNotifier:
|
|||
if pushalot_authorizationtoken == None:
|
||||
pushalot_authorizationtoken = sickbeard.PUSHALOT_AUTHORIZATIONTOKEN
|
||||
|
||||
logger.log(u"Pushalot event: " + event, logger.DEBUG)
|
||||
logger.log(u"Pushalot message: " + message, logger.DEBUG)
|
||||
logger.log(u"Pushalot api: " + pushalot_authorizationtoken, logger.DEBUG)
|
||||
logger.log(u'Pushalot event: ' + event, logger.DEBUG)
|
||||
logger.log(u'Pushalot message: ' + message, logger.DEBUG)
|
||||
logger.log(u'Pushalot api: ' + pushalot_authorizationtoken, logger.DEBUG)
|
||||
|
||||
http_handler = moves.http_client.HTTPSConnection("pushalot.com")
|
||||
http_handler = moves.http_client.HTTPSConnection('pushalot.com')
|
||||
|
||||
data = {'AuthorizationToken': pushalot_authorizationtoken,
|
||||
'Title': event.encode('utf-8'),
|
||||
'Body': message.encode('utf-8')}
|
||||
|
||||
try:
|
||||
http_handler.request("POST",
|
||||
"/api/sendmessage",
|
||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||
http_handler.request('POST',
|
||||
'/api/sendmessage',
|
||||
headers={'Content-type': 'application/x-www-form-urlencoded'},
|
||||
body=urlencode(data))
|
||||
except (SSLError, moves.http_client.HTTPException, socket.error):
|
||||
logger.log(u"Pushalot notification failed.", logger.ERROR)
|
||||
logger.log(u'Pushalot notification failed.', logger.ERROR)
|
||||
return False
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
|
||||
if request_status == 200:
|
||||
logger.log(u"Pushalot notifications sent.", logger.DEBUG)
|
||||
logger.log(u'Pushalot notifications sent.', logger.DEBUG)
|
||||
return True
|
||||
elif request_status == 410:
|
||||
logger.log(u"Pushalot authentication failed: %s" % response.reason, logger.ERROR)
|
||||
logger.log(u'Pushalot authentication failed: %s' % response.reason, logger.ERROR)
|
||||
return False
|
||||
else:
|
||||
logger.log(u"Pushalot notification failed.", logger.ERROR)
|
||||
logger.log(u'Pushalot notification failed.', logger.ERROR)
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class PushbulletNotifier:
|
|||
if not device_iden:
|
||||
device_iden = sickbeard.PUSHBULLET_DEVICE_IDEN
|
||||
|
||||
logger.log(u'PUSHBULLET: Sending notice with details: \"%s - %s\", device_iden: %s' % (title, body, device_iden), logger.DEBUG)
|
||||
logger.log(u'PUSHBULLET: Sending notice with details: "%s - %s", device_iden: %s' % (title, body, device_iden), logger.DEBUG)
|
||||
|
||||
return self._sendPushbullet(title, body, accessToken, device_iden)
|
||||
|
||||
|
|
|
@ -73,19 +73,19 @@ class pyTivoNotifier:
|
|||
|
||||
# Some show names have colons in them which are illegal in a path location, so strip them out.
|
||||
# (Are there other characters?)
|
||||
showName = showName.replace(":", "")
|
||||
showName = showName.replace(':', '')
|
||||
|
||||
root = showPath.replace(showName, "")
|
||||
showAndSeason = rootShowAndSeason.replace(root, "")
|
||||
root = showPath.replace(showName, '')
|
||||
showAndSeason = rootShowAndSeason.replace(root, '')
|
||||
|
||||
container = shareName + "/" + showAndSeason
|
||||
file = "/" + absPath.replace(root, "")
|
||||
container = shareName + '/' + showAndSeason
|
||||
file = '/' + absPath.replace(root, '')
|
||||
|
||||
# Finally create the url and make request
|
||||
requestUrl = "http://" + host + "/TiVoConnect?" + urlencode(
|
||||
requestUrl = 'http://' + host + '/TiVoConnect?' + urlencode(
|
||||
{'Command': 'Push', 'Container': container, 'File': file, 'tsn': tsn})
|
||||
|
||||
logger.log(u"pyTivo notification: Requesting " + requestUrl, logger.DEBUG)
|
||||
logger.log(u'pyTivo notification: Requesting ' + requestUrl, logger.DEBUG)
|
||||
|
||||
request = Request(requestUrl)
|
||||
|
||||
|
@ -93,16 +93,16 @@ class pyTivoNotifier:
|
|||
response = urlopen(request) #@UnusedVariable
|
||||
except HTTPError as e:
|
||||
if hasattr(e, 'reason'):
|
||||
logger.log(u"pyTivo notification: Error, failed to reach a server - " + e.reason, logger.ERROR)
|
||||
logger.log(u'pyTivo notification: Error, failed to reach a server - ' + e.reason, logger.ERROR)
|
||||
return False
|
||||
elif hasattr(e, 'code'):
|
||||
logger.log(u"pyTivo notification: Error, the server couldn't fulfill the request - " + e.code, logger.ERROR)
|
||||
return False
|
||||
except Exception as e:
|
||||
logger.log(u"PYTIVO: Unknown exception: " + ex(e), logger.ERROR)
|
||||
logger.log(u'PYTIVO: Unknown exception: ' + ex(e), logger.ERROR)
|
||||
return False
|
||||
else:
|
||||
logger.log(u"pyTivo notification: Successfully requested transfer of file")
|
||||
logger.log(u'pyTivo notification: Successfully requested transfer of file')
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -51,15 +51,15 @@ class synoIndexNotifier:
|
|||
if sickbeard.USE_SYNOINDEX:
|
||||
synoindex_cmd = ['/usr/syno/bin/synoindex', '-N', ek.ek(os.path.abspath, new_path),
|
||||
ek.ek(os.path.abspath, old_path)]
|
||||
logger.log(u"Executing command " + str(synoindex_cmd), logger.DEBUG)
|
||||
logger.log(u"Absolute path to command: " + ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
|
||||
logger.log(u'Executing command ' + str(synoindex_cmd), logger.DEBUG)
|
||||
logger.log(u'Absolute path to command: ' + ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
|
||||
try:
|
||||
p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
cwd=sickbeard.PROG_DIR)
|
||||
out, err = p.communicate() #@UnusedVariable
|
||||
logger.log(u"Script result: " + str(out), logger.DEBUG)
|
||||
logger.log(u'Script result: ' + str(out), logger.DEBUG)
|
||||
except OSError as e:
|
||||
logger.log(u"Unable to run synoindex: " + ex(e), logger.ERROR)
|
||||
logger.log(u'Unable to run synoindex: ' + ex(e), logger.ERROR)
|
||||
|
||||
def deleteFolder(self, cur_path):
|
||||
self.makeObject('-D', cur_path)
|
||||
|
@ -76,15 +76,15 @@ class synoIndexNotifier:
|
|||
def makeObject(self, cmd_arg, cur_path):
|
||||
if sickbeard.USE_SYNOINDEX:
|
||||
synoindex_cmd = ['/usr/syno/bin/synoindex', cmd_arg, ek.ek(os.path.abspath, cur_path)]
|
||||
logger.log(u"Executing command " + str(synoindex_cmd), logger.DEBUG)
|
||||
logger.log(u"Absolute path to command: " + ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
|
||||
logger.log(u'Executing command ' + str(synoindex_cmd), logger.DEBUG)
|
||||
logger.log(u'Absolute path to command: ' + ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
|
||||
try:
|
||||
p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
cwd=sickbeard.PROG_DIR)
|
||||
out, err = p.communicate() #@UnusedVariable
|
||||
logger.log(u"Script result: " + str(out), logger.DEBUG)
|
||||
logger.log(u'Script result: ' + str(out), logger.DEBUG)
|
||||
except OSError as e:
|
||||
logger.log(u"Unable to run synoindex: " + ex(e), logger.ERROR)
|
||||
logger.log(u'Unable to run synoindex: ' + ex(e), logger.ERROR)
|
||||
|
||||
|
||||
notifier = synoIndexNotifier
|
||||
|
|
|
@ -39,25 +39,25 @@ class synologyNotifier:
|
|||
|
||||
def notify_subtitle_download(self, ep_name, lang):
|
||||
if sickbeard.SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||
self._send_synologyNotifier(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD])
|
||||
self._send_synologyNotifier(ep_name + ': ' + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD])
|
||||
|
||||
def notify_git_update(self, new_version = "??"):
|
||||
def notify_git_update(self, new_version = '??'):
|
||||
if sickbeard.USE_SYNOLOGYNOTIFIER:
|
||||
update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT]
|
||||
title=common.notifyStrings[common.NOTIFY_GIT_UPDATE]
|
||||
self._send_synologyNotifier(update_text + new_version, title)
|
||||
|
||||
def _send_synologyNotifier(self, message, title):
|
||||
synodsmnotify_cmd = ["/usr/syno/bin/synodsmnotify", "@administrators", title, message]
|
||||
logger.log(u"Executing command " + str(synodsmnotify_cmd))
|
||||
logger.log(u"Absolute path to command: " + ek.ek(os.path.abspath, synodsmnotify_cmd[0]), logger.DEBUG)
|
||||
synodsmnotify_cmd = ['/usr/syno/bin/synodsmnotify', '@administrators', title, message]
|
||||
logger.log(u'Executing command ' + str(synodsmnotify_cmd))
|
||||
logger.log(u'Absolute path to command: ' + ek.ek(os.path.abspath, synodsmnotify_cmd[0]), logger.DEBUG)
|
||||
try:
|
||||
p = subprocess.Popen(synodsmnotify_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
cwd=sickbeard.PROG_DIR)
|
||||
out, err = p.communicate() #@UnusedVariable
|
||||
logger.log(u"Script result: " + str(out), logger.DEBUG)
|
||||
logger.log(u'Script result: ' + str(out), logger.DEBUG)
|
||||
except OSError as e:
|
||||
logger.log(u"Unable to run synodsmnotify: " + ex(e))
|
||||
logger.log(u'Unable to run synodsmnotify: ' + ex(e))
|
||||
|
||||
|
||||
notifier = synologyNotifier
|
||||
|
|
|
@ -59,9 +59,9 @@ class TraktNotifier:
|
|||
}
|
||||
|
||||
if data is not None:
|
||||
TraktCall("show/episode/library/%API%", self._api(), self._username(), self._password(), data)
|
||||
TraktCall('show/episode/library/%API%', self._api(), self._username(), self._password(), data)
|
||||
if sickbeard.TRAKT_REMOVE_WATCHLIST:
|
||||
TraktCall("show/episode/unwatchlist/%API%", self._api(), self._username(), self._password(), data)
|
||||
TraktCall('show/episode/unwatchlist/%API%', self._api(), self._username(), self._password(), data)
|
||||
|
||||
if sickbeard.TRAKT_REMOVE_SERIESLIST:
|
||||
data_show = None
|
||||
|
@ -77,11 +77,11 @@ class TraktNotifier:
|
|||
]
|
||||
}
|
||||
|
||||
TraktCall("show/unwatchlist/%API%", self._api(), self._username(), self._password(), data)
|
||||
TraktCall('show/unwatchlist/%API%', self._api(), self._username(), self._password(), data)
|
||||
|
||||
# Remove all episodes from episode watchlist
|
||||
# Start by getting all episodes in the watchlist
|
||||
watchlist = TraktCall("user/watchlist/episodes.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
|
||||
watchlist = TraktCall('user/watchlist/episodes.json/%API%/' + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
|
||||
|
||||
if watchlist is not None:
|
||||
# Convert watchlist to only contain current show
|
||||
|
@ -100,7 +100,7 @@ class TraktNotifier:
|
|||
ep = {'season': episodes['season'], 'episode': episodes['number']}
|
||||
data_show['episodes'].append(ep)
|
||||
if data_show is not None:
|
||||
TraktCall("show/episode/unwatchlist/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, data_show)
|
||||
TraktCall('show/episode/unwatchlist/%API%', sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, data_show)
|
||||
else:
|
||||
logger.log('Failed to get watchlist from trakt. Unable to remove episode from watchlist',
|
||||
logger.ERROR)
|
||||
|
@ -117,8 +117,8 @@ class TraktNotifier:
|
|||
Returns: True if the request succeeded, False otherwise
|
||||
"""
|
||||
|
||||
data = TraktCall("account/test/%API%", api, username, password)
|
||||
if data and data["status"] == "success":
|
||||
data = TraktCall('account/test/%API%', api, username, password)
|
||||
if data and data['status'] == 'success':
|
||||
return True
|
||||
|
||||
def _username(self):
|
||||
|
|
|
@ -32,8 +32,8 @@ import lib.pythontwitter as twitter
|
|||
|
||||
|
||||
class TwitterNotifier:
|
||||
consumer_key = "vHHtcB6WzpWDG6KYlBMr8g"
|
||||
consumer_secret = "zMqq5CB3f8cWKiRO2KzWPTlBanYmV0VYxSXZ0Pxds0E"
|
||||
consumer_key = 'vHHtcB6WzpWDG6KYlBMr8g'
|
||||
consumer_secret = 'zMqq5CB3f8cWKiRO2KzWPTlBanYmV0VYxSXZ0Pxds0E'
|
||||
|
||||
REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
|
||||
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
|
||||
|
@ -50,16 +50,16 @@ class TwitterNotifier:
|
|||
|
||||
def notify_subtitle_download(self, ep_name, lang):
|
||||
if sickbeard.TWITTER_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||
self._notifyTwitter(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD] + ' ' + ep_name + ": " + lang)
|
||||
self._notifyTwitter(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD] + ' ' + ep_name + ': ' + lang)
|
||||
|
||||
def notify_git_update(self, new_version = "??"):
|
||||
def notify_git_update(self, new_version = '??'):
|
||||
if sickbeard.USE_TWITTER:
|
||||
update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT]
|
||||
title=common.notifyStrings[common.NOTIFY_GIT_UPDATE]
|
||||
self._notifyTwitter(title + " - " + update_text + new_version)
|
||||
self._notifyTwitter(title + ' - ' + update_text + new_version)
|
||||
|
||||
def test_notify(self):
|
||||
return self._notifyTwitter("This is a test notification from SickGear", force=True)
|
||||
return self._notifyTwitter('This is a test notification from SickGear', force=True)
|
||||
|
||||
def _get_authorization(self):
|
||||
|
||||
|
@ -79,7 +79,7 @@ class TwitterNotifier:
|
|||
sickbeard.TWITTER_USERNAME = request_token['oauth_token']
|
||||
sickbeard.TWITTER_PASSWORD = request_token['oauth_token_secret']
|
||||
|
||||
return self.AUTHORIZATION_URL + "?oauth_token=" + request_token['oauth_token']
|
||||
return self.AUTHORIZATION_URL + '?oauth_token=' + request_token['oauth_token']
|
||||
|
||||
def _get_credentials(self, key):
|
||||
request_token = {}
|
||||
|
@ -123,14 +123,14 @@ class TwitterNotifier:
|
|||
access_token_key = sickbeard.TWITTER_USERNAME
|
||||
access_token_secret = sickbeard.TWITTER_PASSWORD
|
||||
|
||||
logger.log(u"Sending tweet: " + message, logger.DEBUG)
|
||||
logger.log(u'Sending tweet: ' + message, logger.DEBUG)
|
||||
|
||||
api = twitter.Api(username, password, access_token_key, access_token_secret)
|
||||
|
||||
try:
|
||||
api.PostUpdate(message.encode('utf8'))
|
||||
except Exception as e:
|
||||
logger.log(u"Error Sending Tweet: " + ex(e), logger.ERROR)
|
||||
logger.log(u'Error Sending Tweet: ' + ex(e), logger.ERROR)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -141,7 +141,7 @@ class TwitterNotifier:
|
|||
if not sickbeard.USE_TWITTER and not force:
|
||||
return False
|
||||
|
||||
return self._send_tweet(prefix + ": " + message)
|
||||
return self._send_tweet(prefix + ': ' + message)
|
||||
|
||||
|
||||
notifier = TwitterNotifier
|
||||
|
|
|
@ -81,7 +81,7 @@ class XBMCNotifier:
|
|||
socket.setdefaulttimeout(sickbeard.SOCKET_TIMEOUT)
|
||||
|
||||
if result:
|
||||
return result["result"]["version"]
|
||||
return result['result']['version']
|
||||
else:
|
||||
# fallback to legacy HTTPAPI method
|
||||
testCommand = {'command': 'Help'}
|
||||
|
@ -92,7 +92,7 @@ class XBMCNotifier:
|
|||
else:
|
||||
return False
|
||||
|
||||
def _notify_xbmc(self, message, title="SickGear", host=None, username=None, password=None, force=False):
|
||||
def _notify_xbmc(self, message, title='SickGear', host=None, username=None, password=None, force=False):
|
||||
"""Internal wrapper for the notify_snatch and notify_download functions
|
||||
|
||||
Detects JSON-RPC version then branches the logic for either the JSON-RPC or legacy HTTP API methods.
|
||||
|
@ -121,34 +121,34 @@ class XBMCNotifier:
|
|||
|
||||
# suppress notifications if the notifier is disabled but the notify options are checked
|
||||
if not sickbeard.USE_XBMC and not force:
|
||||
logger.log("Notification for XBMC not enabled, skipping this notification", logger.DEBUG)
|
||||
logger.log('Notification for XBMC not enabled, skipping this notification', logger.DEBUG)
|
||||
return False
|
||||
|
||||
result = ''
|
||||
for curHost in [x.strip() for x in host.split(",")]:
|
||||
logger.log(u"Sending XBMC notification to '" + curHost + "' - " + message, logger.MESSAGE)
|
||||
for curHost in [x.strip() for x in host.split(',')]:
|
||||
logger.log(u'Sending XBMC notification to "' + curHost + '" - ' + message, logger.MESSAGE)
|
||||
|
||||
xbmcapi = self._get_xbmc_version(curHost, username, password)
|
||||
if xbmcapi:
|
||||
if (xbmcapi <= 4):
|
||||
logger.log(u"Detected XBMC version <= 11, using XBMC HTTP API", logger.DEBUG)
|
||||
logger.log(u'Detected XBMC version <= 11, using XBMC HTTP API', logger.DEBUG)
|
||||
command = {'command': 'ExecBuiltIn',
|
||||
'parameter': 'Notification(' + title.encode("utf-8") + ',' + message.encode(
|
||||
"utf-8") + ')'}
|
||||
'parameter': 'Notification(' + title.encode('utf-8') + ',' + message.encode(
|
||||
'utf-8') + ')'}
|
||||
notifyResult = self._send_to_xbmc(command, curHost, username, password)
|
||||
if notifyResult:
|
||||
result += curHost + ':' + str(notifyResult)
|
||||
else:
|
||||
logger.log(u"Detected XBMC version >= 12, using XBMC JSON API", logger.DEBUG)
|
||||
logger.log(u'Detected XBMC version >= 12, using XBMC JSON API', logger.DEBUG)
|
||||
command = '{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"%s","message":"%s", "image": "%s"},"id":1}' % (
|
||||
title.encode("utf-8"), message.encode("utf-8"), self.sb_logo_url)
|
||||
title.encode('utf-8'), message.encode('utf-8'), self.sb_logo_url)
|
||||
notifyResult = self._send_to_xbmc_json(command, curHost, username, password)
|
||||
if notifyResult.get('result'):
|
||||
result += curHost + ':' + notifyResult["result"].decode(sickbeard.SYS_ENCODING)
|
||||
result += curHost + ':' + notifyResult['result'].decode(sickbeard.SYS_ENCODING)
|
||||
else:
|
||||
if sickbeard.XBMC_ALWAYS_ON or force:
|
||||
logger.log(
|
||||
u"Failed to detect XBMC version for '" + curHost + "', check configuration and try again.",
|
||||
u'Failed to detect XBMC version for "' + curHost + '", check configuration and try again.',
|
||||
logger.ERROR)
|
||||
result += curHost + ':False'
|
||||
|
||||
|
@ -168,26 +168,26 @@ class XBMCNotifier:
|
|||
|
||||
"""
|
||||
|
||||
logger.log(u"Sending request to update library for XBMC host: '" + host + "'", logger.MESSAGE)
|
||||
logger.log(u'Sending request to update library for XBMC host: "' + host + '"', logger.MESSAGE)
|
||||
|
||||
xbmcapi = self._get_xbmc_version(host, sickbeard.XBMC_USERNAME, sickbeard.XBMC_PASSWORD)
|
||||
if xbmcapi:
|
||||
if (xbmcapi <= 4):
|
||||
# try to update for just the show, if it fails, do full update if enabled
|
||||
if not self._update_library(host, showName) and sickbeard.XBMC_UPDATE_FULL:
|
||||
logger.log(u"Single show update failed, falling back to full update", logger.WARNING)
|
||||
logger.log(u'Single show update failed, falling back to full update', logger.WARNING)
|
||||
return self._update_library(host)
|
||||
else:
|
||||
return True
|
||||
else:
|
||||
# try to update for just the show, if it fails, do full update if enabled
|
||||
if not self._update_library_json(host, showName) and sickbeard.XBMC_UPDATE_FULL:
|
||||
logger.log(u"Single show update failed, falling back to full update", logger.WARNING)
|
||||
logger.log(u'Single show update failed, falling back to full update', logger.WARNING)
|
||||
return self._update_library_json(host)
|
||||
else:
|
||||
return True
|
||||
else:
|
||||
logger.log(u"Failed to detect XBMC version for '" + host + "', check configuration and try again.",
|
||||
logger.log(u'Failed to detect XBMC version for "' + host + '", check configuration and try again.',
|
||||
logger.DEBUG)
|
||||
return False
|
||||
|
||||
|
@ -226,7 +226,7 @@ class XBMCNotifier:
|
|||
command[key] = command[key].encode('utf-8')
|
||||
|
||||
enc_command = urllib.urlencode(command)
|
||||
logger.log(u"XBMC encoded API command: " + enc_command, logger.DEBUG)
|
||||
logger.log(u'XBMC encoded API command: ' + enc_command, logger.DEBUG)
|
||||
|
||||
url = 'http://%s/xbmcCmds/xbmcHttp/?%s' % (host, enc_command)
|
||||
try:
|
||||
|
@ -234,21 +234,21 @@ class XBMCNotifier:
|
|||
# if we have a password, use authentication
|
||||
if password:
|
||||
base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
|
||||
authheader = "Basic %s" % base64string
|
||||
req.add_header("Authorization", authheader)
|
||||
logger.log(u"Contacting XBMC (with auth header) via url: " + fixStupidEncodings(url), logger.DEBUG)
|
||||
authheader = 'Basic %s' % base64string
|
||||
req.add_header('Authorization', authheader)
|
||||
logger.log(u'Contacting XBMC (with auth header) via url: ' + fixStupidEncodings(url), logger.DEBUG)
|
||||
else:
|
||||
logger.log(u"Contacting XBMC via url: " + fixStupidEncodings(url), logger.DEBUG)
|
||||
logger.log(u'Contacting XBMC via url: ' + fixStupidEncodings(url), logger.DEBUG)
|
||||
|
||||
response = urllib2.urlopen(req)
|
||||
result = response.read().decode(sickbeard.SYS_ENCODING)
|
||||
response.close()
|
||||
|
||||
logger.log(u"XBMC HTTP response: " + result.replace('\n', ''), logger.DEBUG)
|
||||
logger.log(u'XBMC HTTP response: ' + result.replace('\n', ''), logger.DEBUG)
|
||||
return result
|
||||
|
||||
except (urllib2.URLError, IOError) as e:
|
||||
logger.log(u"Warning: Couldn't contact XBMC HTTP at " + fixStupidEncodings(url) + " " + ex(e),
|
||||
logger.log(u"Warning: Couldn't contact XBMC HTTP at " + fixStupidEncodings(url) + ' ' + ex(e),
|
||||
logger.WARNING)
|
||||
return False
|
||||
|
||||
|
@ -271,11 +271,11 @@ class XBMCNotifier:
|
|||
logger.log(u'No XBMC host passed, aborting update', logger.DEBUG)
|
||||
return False
|
||||
|
||||
logger.log(u"Updating XMBC library via HTTP method for host: " + host, logger.DEBUG)
|
||||
logger.log(u'Updating XMBC library via HTTP method for host: ' + host, logger.DEBUG)
|
||||
|
||||
# if we're doing per-show
|
||||
if showName:
|
||||
logger.log(u"Updating library in XBMC via HTTP method for show " + showName, logger.DEBUG)
|
||||
logger.log(u'Updating library in XBMC via HTTP method for show ' + showName, logger.DEBUG)
|
||||
|
||||
pathSql = 'select path.strPath from path, tvshow, tvshowlinkpath where ' \
|
||||
'tvshow.c00 = "%s" and tvshowlinkpath.idShow = tvshow.idShow ' \
|
||||
|
@ -298,30 +298,30 @@ class XBMCNotifier:
|
|||
request = self._send_to_xbmc(resetCommand, host)
|
||||
|
||||
if not sqlXML:
|
||||
logger.log(u"Invalid response for " + showName + " on " + host, logger.DEBUG)
|
||||
logger.log(u'Invalid response for ' + showName + ' on ' + host, logger.DEBUG)
|
||||
return False
|
||||
|
||||
encSqlXML = urllib.quote(sqlXML, ':\\/<>')
|
||||
try:
|
||||
et = etree.fromstring(encSqlXML)
|
||||
except SyntaxError as e:
|
||||
logger.log(u"Unable to parse XML returned from XBMC: " + ex(e), logger.ERROR)
|
||||
logger.log(u'Unable to parse XML returned from XBMC: ' + ex(e), logger.ERROR)
|
||||
return False
|
||||
|
||||
paths = et.findall('.//field')
|
||||
|
||||
if not paths:
|
||||
logger.log(u"No valid paths found for " + showName + " on " + host, logger.DEBUG)
|
||||
logger.log(u'No valid paths found for ' + showName + ' on ' + host, logger.DEBUG)
|
||||
return False
|
||||
|
||||
for path in paths:
|
||||
# we do not need it double-encoded, gawd this is dumb
|
||||
unEncPath = urllib.unquote(path.text).decode(sickbeard.SYS_ENCODING)
|
||||
logger.log(u"XBMC Updating " + showName + " on " + host + " at " + unEncPath, logger.DEBUG)
|
||||
logger.log(u'XBMC Updating ' + showName + ' on ' + host + ' at ' + unEncPath, logger.DEBUG)
|
||||
updateCommand = {'command': 'ExecBuiltIn', 'parameter': 'XBMC.updatelibrary(video, %s)' % (unEncPath)}
|
||||
request = self._send_to_xbmc(updateCommand, host)
|
||||
if not request:
|
||||
logger.log(u"Update of show directory failed on " + showName + " on " + host + " at " + unEncPath,
|
||||
logger.log(u'Update of show directory failed on ' + showName + ' on ' + host + ' at ' + unEncPath,
|
||||
logger.ERROR)
|
||||
return False
|
||||
# sleep for a few seconds just to be sure xbmc has a chance to finish each directory
|
||||
|
@ -329,12 +329,12 @@ class XBMCNotifier:
|
|||
time.sleep(5)
|
||||
# do a full update if requested
|
||||
else:
|
||||
logger.log(u"Doing Full Library XBMC update on host: " + host, logger.MESSAGE)
|
||||
logger.log(u'Doing Full Library XBMC update on host: ' + host, logger.MESSAGE)
|
||||
updateCommand = {'command': 'ExecBuiltIn', 'parameter': 'XBMC.updatelibrary(video)'}
|
||||
request = self._send_to_xbmc(updateCommand, host)
|
||||
|
||||
if not request:
|
||||
logger.log(u"XBMC Full Library update failed on: " + host, logger.ERROR)
|
||||
logger.log(u'XBMC Full Library update failed on: ' + host, logger.ERROR)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -368,25 +368,25 @@ class XBMCNotifier:
|
|||
return False
|
||||
|
||||
command = command.encode('utf-8')
|
||||
logger.log(u"XBMC JSON command: " + command, logger.DEBUG)
|
||||
logger.log(u'XBMC JSON command: ' + command, logger.DEBUG)
|
||||
|
||||
url = 'http://%s/jsonrpc' % (host)
|
||||
try:
|
||||
req = urllib2.Request(url, command)
|
||||
req.add_header("Content-type", "application/json")
|
||||
req.add_header('Content-type', 'application/json')
|
||||
# if we have a password, use authentication
|
||||
if password:
|
||||
base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
|
||||
authheader = "Basic %s" % base64string
|
||||
req.add_header("Authorization", authheader)
|
||||
logger.log(u"Contacting XBMC (with auth header) via url: " + fixStupidEncodings(url), logger.DEBUG)
|
||||
authheader = 'Basic %s' % base64string
|
||||
req.add_header('Authorization', authheader)
|
||||
logger.log(u'Contacting XBMC (with auth header) via url: ' + fixStupidEncodings(url), logger.DEBUG)
|
||||
else:
|
||||
logger.log(u"Contacting XBMC via url: " + fixStupidEncodings(url), logger.DEBUG)
|
||||
logger.log(u'Contacting XBMC via url: ' + fixStupidEncodings(url), logger.DEBUG)
|
||||
|
||||
try:
|
||||
response = urllib2.urlopen(req)
|
||||
except urllib2.URLError as e:
|
||||
logger.log(u"Error while trying to retrieve XBMC API version for " + host + ": " + ex(e),
|
||||
logger.log(u'Error while trying to retrieve XBMC API version for ' + host + ': ' + ex(e),
|
||||
logger.WARNING)
|
||||
return False
|
||||
|
||||
|
@ -394,14 +394,14 @@ class XBMCNotifier:
|
|||
try:
|
||||
result = json.load(response)
|
||||
response.close()
|
||||
logger.log(u"XBMC JSON response: " + str(result), logger.DEBUG)
|
||||
logger.log(u'XBMC JSON response: ' + str(result), logger.DEBUG)
|
||||
return result # need to return response for parsing
|
||||
except ValueError as e:
|
||||
logger.log(u"Unable to decode JSON: " + response, logger.WARNING)
|
||||
logger.log(u'Unable to decode JSON: ' + response, logger.WARNING)
|
||||
return False
|
||||
|
||||
except IOError as e:
|
||||
logger.log(u"Warning: Couldn't contact XBMC JSON API at " + fixStupidEncodings(url) + " " + ex(e),
|
||||
logger.log(u"Warning: Couldn't contact XBMC JSON API at " + fixStupidEncodings(url) + ' ' + ex(e),
|
||||
logger.WARNING)
|
||||
return False
|
||||
|
||||
|
@ -424,26 +424,26 @@ class XBMCNotifier:
|
|||
logger.log(u'No XBMC host passed, aborting update', logger.DEBUG)
|
||||
return False
|
||||
|
||||
logger.log(u"Updating XMBC library via JSON method for host: " + host, logger.MESSAGE)
|
||||
logger.log(u'Updating XMBC library via JSON method for host: ' + host, logger.MESSAGE)
|
||||
|
||||
# if we're doing per-show
|
||||
if showName:
|
||||
tvshowid = -1
|
||||
logger.log(u"Updating library in XBMC via JSON method for show " + showName, logger.DEBUG)
|
||||
logger.log(u'Updating library in XBMC via JSON method for show ' + showName, logger.DEBUG)
|
||||
|
||||
# get tvshowid by showName
|
||||
showsCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShows","id":1}'
|
||||
showsResponse = self._send_to_xbmc_json(showsCommand, host)
|
||||
|
||||
if showsResponse and "result" in showsResponse and "tvshows" in showsResponse["result"]:
|
||||
shows = showsResponse["result"]["tvshows"]
|
||||
if showsResponse and 'result' in showsResponse and 'tvshows' in showsResponse['result']:
|
||||
shows = showsResponse['result']['tvshows']
|
||||
else:
|
||||
logger.log(u"XBMC: No tvshows in XBMC TV show list", logger.DEBUG)
|
||||
logger.log(u'XBMC: No tvshows in XBMC TV show list', logger.DEBUG)
|
||||
return False
|
||||
|
||||
for show in shows:
|
||||
if (show["label"] == showName):
|
||||
tvshowid = show["tvshowid"]
|
||||
if (show['label'] == showName):
|
||||
tvshowid = show['tvshowid']
|
||||
break # exit out of loop otherwise the label and showname will not match up
|
||||
|
||||
# this can be big, so free some memory
|
||||
|
@ -459,21 +459,21 @@ class XBMCNotifier:
|
|||
tvshowid)
|
||||
pathResponse = self._send_to_xbmc_json(pathCommand, host)
|
||||
|
||||
path = pathResponse["result"]["tvshowdetails"]["file"]
|
||||
logger.log(u"Received Show: " + showName + " with ID: " + str(tvshowid) + " Path: " + path,
|
||||
path = pathResponse['result']['tvshowdetails']['file']
|
||||
logger.log(u'Received Show: ' + showName + ' with ID: ' + str(tvshowid) + ' Path: ' + path,
|
||||
logger.DEBUG)
|
||||
|
||||
if (len(path) < 1):
|
||||
logger.log(u"No valid path found for " + showName + " with ID: " + str(tvshowid) + " on " + host,
|
||||
logger.log(u'No valid path found for ' + showName + ' with ID: ' + str(tvshowid) + ' on ' + host,
|
||||
logger.WARNING)
|
||||
return False
|
||||
|
||||
logger.log(u"XBMC Updating " + showName + " on " + host + " at " + path, logger.DEBUG)
|
||||
logger.log(u'XBMC Updating ' + showName + ' on ' + host + ' at ' + path, logger.DEBUG)
|
||||
updateCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.Scan","params":{"directory":%s},"id":1}' % (
|
||||
json.dumps(path))
|
||||
request = self._send_to_xbmc_json(updateCommand, host)
|
||||
if not request:
|
||||
logger.log(u"Update of show directory failed on " + showName + " on " + host + " at " + path,
|
||||
logger.log(u'Update of show directory failed on ' + showName + ' on ' + host + ' at ' + path,
|
||||
logger.ERROR)
|
||||
return False
|
||||
|
||||
|
@ -481,18 +481,18 @@ class XBMCNotifier:
|
|||
for r in request:
|
||||
if 'error' in r:
|
||||
logger.log(
|
||||
u"Error while attempting to update show directory for " + showName + " on " + host + " at " + path,
|
||||
u'Error while attempting to update show directory for ' + showName + ' on ' + host + ' at ' + path,
|
||||
logger.ERROR)
|
||||
return False
|
||||
|
||||
# do a full update if requested
|
||||
else:
|
||||
logger.log(u"Doing Full Library XBMC update on host: " + host, logger.MESSAGE)
|
||||
logger.log(u'Doing Full Library XBMC update on host: ' + host, logger.MESSAGE)
|
||||
updateCommand = '{"jsonrpc":"2.0","method":"VideoLibrary.Scan","id":1}'
|
||||
request = self._send_to_xbmc_json(updateCommand, host, sickbeard.XBMC_USERNAME, sickbeard.XBMC_PASSWORD)
|
||||
|
||||
if not request:
|
||||
logger.log(u"XBMC Full Library update failed on: " + host, logger.ERROR)
|
||||
logger.log(u'XBMC Full Library update failed on: ' + host, logger.ERROR)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -511,16 +511,16 @@ class XBMCNotifier:
|
|||
|
||||
def notify_subtitle_download(self, ep_name, lang):
|
||||
if sickbeard.XBMC_NOTIFY_ONSUBTITLEDOWNLOAD:
|
||||
self._notify_xbmc(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD])
|
||||
self._notify_xbmc(ep_name + ': ' + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD])
|
||||
|
||||
def notify_git_update(self, new_version = "??"):
|
||||
def notify_git_update(self, new_version = '??'):
|
||||
if sickbeard.USE_XBMC:
|
||||
update_text=common.notifyStrings[common.NOTIFY_GIT_UPDATE_TEXT]
|
||||
title=common.notifyStrings[common.NOTIFY_GIT_UPDATE]
|
||||
self._notify_xbmc(update_text + new_version, title)
|
||||
|
||||
def test_notify(self, host, username, password):
|
||||
return self._notify_xbmc("Testing XBMC notifications from SickGear", "Test Notification", host, username,
|
||||
return self._notify_xbmc('Testing XBMC notifications from SickGear', 'Test Notification', host, username,
|
||||
password, force=True)
|
||||
|
||||
def update_library(self, showName=None):
|
||||
|
@ -541,21 +541,21 @@ class XBMCNotifier:
|
|||
|
||||
if sickbeard.USE_XBMC and sickbeard.XBMC_UPDATE_LIBRARY:
|
||||
if not sickbeard.XBMC_HOST:
|
||||
logger.log(u"No XBMC hosts specified, check your settings", logger.DEBUG)
|
||||
logger.log(u'No XBMC hosts specified, check your settings', logger.DEBUG)
|
||||
return False
|
||||
|
||||
# either update each host, or only attempt to update until one successful result
|
||||
result = 0
|
||||
for host in [x.strip() for x in sickbeard.XBMC_HOST.split(",")]:
|
||||
for host in [x.strip() for x in sickbeard.XBMC_HOST.split(',')]:
|
||||
if self._send_update_library(host, showName):
|
||||
if sickbeard.XBMC_UPDATE_ONLYFIRST:
|
||||
logger.log(u"Successfully updated '" + host + "', stopped sending update library commands.",
|
||||
logger.log(u'Successfully updated "' + host + '", stopped sending update library commands.',
|
||||
logger.DEBUG)
|
||||
return True
|
||||
else:
|
||||
if sickbeard.XBMC_ALWAYS_ON:
|
||||
logger.log(
|
||||
u"Failed to detect XBMC version for '" + host + "', check configuration and try again.",
|
||||
u'Failed to detect XBMC version for "' + host + '", check configuration and try again.',
|
||||
logger.ERROR)
|
||||
result = result + 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue