mirror of
https://github.com/moparisthebest/SickRage
synced 2024-11-16 22:35:03 -05:00
Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
c62245b5a3
@ -14,10 +14,10 @@ function check_notifications() {
|
|||||||
poll_interval = 5000;
|
poll_interval = 5000;
|
||||||
$.each(data, function (name, data) {
|
$.each(data, function (name, data) {
|
||||||
$.pnotify({
|
$.pnotify({
|
||||||
type: data.type,
|
pnotify_type: data.type,
|
||||||
hide: data.type == 'notice',
|
pnotify_hide: data.type == 'notice',
|
||||||
title: data.title,
|
pnotify_title: data.title,
|
||||||
text: data.message
|
pnotify_text: data.message
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -123,7 +123,6 @@ HANDLE_REVERSE_PROXY = None
|
|||||||
PROXY_SETTING = None
|
PROXY_SETTING = None
|
||||||
|
|
||||||
LOCALHOST_IP = None
|
LOCALHOST_IP = None
|
||||||
REMOTE_IP = None
|
|
||||||
|
|
||||||
CPU_PRESET = None
|
CPU_PRESET = None
|
||||||
|
|
||||||
@ -476,7 +475,7 @@ def initialize(consoleLogging=True):
|
|||||||
GUI_NAME, HOME_LAYOUT, HISTORY_LAYOUT, DISPLAY_SHOW_SPECIALS, COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, COMING_EPS_MISSED_RANGE, FUZZY_DATING, TRIM_ZERO, DATE_PRESET, TIME_PRESET, TIME_PRESET_W_SECONDS, \
|
GUI_NAME, HOME_LAYOUT, HISTORY_LAYOUT, DISPLAY_SHOW_SPECIALS, COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, COMING_EPS_MISSED_RANGE, FUZZY_DATING, TRIM_ZERO, DATE_PRESET, TIME_PRESET, TIME_PRESET_W_SECONDS, \
|
||||||
METADATA_WDTV, METADATA_TIVO, METADATA_MEDE8ER, IGNORE_WORDS, CALENDAR_UNPROTECTED, CREATE_MISSING_SHOW_DIRS, \
|
METADATA_WDTV, METADATA_TIVO, METADATA_MEDE8ER, IGNORE_WORDS, CALENDAR_UNPROTECTED, CREATE_MISSING_SHOW_DIRS, \
|
||||||
ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \
|
ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \
|
||||||
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, REMOTE_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
||||||
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
|
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
|
||||||
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
||||||
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT, RES
|
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT, RES
|
||||||
|
@ -19,17 +19,13 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
from tornado.web import RequestHandler
|
|
||||||
|
|
||||||
MESSAGE = 'notice'
|
MESSAGE = 'notice'
|
||||||
ERROR = 'error'
|
ERROR = 'error'
|
||||||
|
|
||||||
|
|
||||||
class Notifications(object):
|
class Notifications(object):
|
||||||
"""
|
"""
|
||||||
A queue of Notification objects.
|
A queue of Notification objects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._messages = []
|
self._messages = []
|
||||||
self._errors = []
|
self._errors = []
|
||||||
@ -52,7 +48,7 @@ class Notifications(object):
|
|||||||
"""
|
"""
|
||||||
self._errors.append(Notification(title, message, ERROR))
|
self._errors.append(Notification(title, message, ERROR))
|
||||||
|
|
||||||
def get_notifications(self):
|
def get_notifications(self, remote_ip='127.0.0.1'):
|
||||||
"""
|
"""
|
||||||
Return all the available notifications in a list. Marks them all as seen
|
Return all the available notifications in a list. Marks them all as seen
|
||||||
as it returns them. Also removes timed out Notifications from the queue.
|
as it returns them. Also removes timed out Notifications from the queue.
|
||||||
@ -65,7 +61,7 @@ class Notifications(object):
|
|||||||
self._messages = [x for x in self._messages if not x.is_expired()]
|
self._messages = [x for x in self._messages if not x.is_expired()]
|
||||||
|
|
||||||
# return any notifications that haven't been shown to the client already
|
# return any notifications that haven't been shown to the client already
|
||||||
return [x.see() for x in self._errors + self._messages if x.is_new()]
|
return [x.see(remote_ip) for x in self._errors + self._messages if x.is_new(remote_ip)]
|
||||||
|
|
||||||
# static notification queue object
|
# static notification queue object
|
||||||
notifications = Notifications()
|
notifications = Notifications()
|
||||||
@ -76,7 +72,6 @@ class Notification(object):
|
|||||||
Represents a single notification. Tracks its own timeout and a list of which clients have
|
Represents a single notification. Tracks its own timeout and a list of which clients have
|
||||||
seen it before.
|
seen it before.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, title, message='', type=None, timeout=None):
|
def __init__(self, title, message='', type=None, timeout=None):
|
||||||
self.title = title
|
self.title = title
|
||||||
self.message = message
|
self.message = message
|
||||||
@ -94,11 +89,11 @@ class Notification(object):
|
|||||||
else:
|
else:
|
||||||
self._timeout = datetime.timedelta(minutes=1)
|
self._timeout = datetime.timedelta(minutes=1)
|
||||||
|
|
||||||
def is_new(self):
|
def is_new(self, remote_ip='127.0.0.1'):
|
||||||
"""
|
"""
|
||||||
Returns True if the notification hasn't been displayed to the current client (aka IP address).
|
Returns True if the notification hasn't been displayed to the current client (aka IP address).
|
||||||
"""
|
"""
|
||||||
return sickbeard.REMOTE_IP not in self._seen
|
return remote_ip not in self._seen
|
||||||
|
|
||||||
def is_expired(self):
|
def is_expired(self):
|
||||||
"""
|
"""
|
||||||
@ -107,20 +102,19 @@ class Notification(object):
|
|||||||
return datetime.datetime.now() - self._when > self._timeout
|
return datetime.datetime.now() - self._when > self._timeout
|
||||||
|
|
||||||
|
|
||||||
def see(self):
|
def see(self, remote_ip='127.0.0.1'):
|
||||||
"""
|
"""
|
||||||
Returns this notification object and marks it as seen by the client ip
|
Returns this notification object and marks it as seen by the client ip
|
||||||
"""
|
"""
|
||||||
self._seen.append(sickbeard.REMOTE_IP)
|
self._seen.append(remote_ip)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class ProgressIndicator():
|
class ProgressIndicator():
|
||||||
|
|
||||||
def __init__(self, percentComplete=0, currentStatus={'title': ''}):
|
def __init__(self, percentComplete=0, currentStatus={'title': ''}):
|
||||||
self.percentComplete = percentComplete
|
self.percentComplete = percentComplete
|
||||||
self.currentStatus = currentStatus
|
self.currentStatus = currentStatus
|
||||||
|
|
||||||
|
|
||||||
class ProgressIndicators():
|
class ProgressIndicators():
|
||||||
_pi = {'massUpdate': [],
|
_pi = {'massUpdate': [],
|
||||||
'massAdd': [],
|
'massAdd': [],
|
||||||
@ -144,12 +138,10 @@ class ProgressIndicators():
|
|||||||
def setIndicator(name, indicator):
|
def setIndicator(name, indicator):
|
||||||
ProgressIndicators._pi[name].append(indicator)
|
ProgressIndicators._pi[name].append(indicator)
|
||||||
|
|
||||||
|
|
||||||
class QueueProgressIndicator():
|
class QueueProgressIndicator():
|
||||||
"""
|
"""
|
||||||
A class used by the UI to show the progress of the queue or a part of it.
|
A class used by the UI to show the progress of the queue or a part of it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, queueItemList):
|
def __init__(self, name, queueItemList):
|
||||||
self.queueItemList = queueItemList
|
self.queueItemList = queueItemList
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -164,8 +156,7 @@ class QueueProgressIndicator():
|
|||||||
return len([x for x in self.queueItemList if x.isInQueue()])
|
return len([x for x in self.queueItemList if x.isInQueue()])
|
||||||
|
|
||||||
def nextName(self):
|
def nextName(self):
|
||||||
for curItem in [
|
for curItem in [sickbeard.showQueueScheduler.action.currentItem]+sickbeard.showQueueScheduler.action.queue: #@UndefinedVariable
|
||||||
sickbeard.showQueueScheduler.action.currentItem] + sickbeard.showQueueScheduler.action.queue: #@UndefinedVariable
|
|
||||||
if curItem in self.queueItemList:
|
if curItem in self.queueItemList:
|
||||||
return curItem.name
|
return curItem.name
|
||||||
|
|
||||||
@ -180,10 +171,7 @@ class QueueProgressIndicator():
|
|||||||
else:
|
else:
|
||||||
return int(float(numFinished)/float(numTotal)*100)
|
return int(float(numFinished)/float(numTotal)*100)
|
||||||
|
|
||||||
|
|
||||||
class LoadingTVShow():
|
class LoadingTVShow():
|
||||||
def __init__(self, dir):
|
def __init__(self, dir):
|
||||||
self.dir = dir
|
self.dir = dir
|
||||||
self.show = None
|
self.show = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -1450,7 +1450,7 @@ class CMD_SickBeardGetMessages(ApiCall):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
messages = []
|
messages = []
|
||||||
for cur_notification in ui.notifications.get_notifications():
|
for cur_notification in ui.notifications.get_notifications(self.handler.request.remote_ip):
|
||||||
messages.append({"title": cur_notification.title,
|
messages.append({"title": cur_notification.title,
|
||||||
"message": cur_notification.message,
|
"message": cur_notification.message,
|
||||||
"type": cur_notification.type})
|
"type": cur_notification.type})
|
||||||
|
@ -144,10 +144,6 @@ def redirect(url, permanent=False, status=None):
|
|||||||
|
|
||||||
@authenticated
|
@authenticated
|
||||||
class MainHandler(RequestHandler):
|
class MainHandler(RequestHandler):
|
||||||
def __init__(self, application, request, **kwargs):
|
|
||||||
super(MainHandler, self).__init__(application, request, **kwargs)
|
|
||||||
sickbeard.REMOTE_IP = self.request.headers.get('X-Forwarded-For', self.request.headers.get('X-Real-Ip', self.request.remote_ip))
|
|
||||||
|
|
||||||
def http_error_401_handler(self):
|
def http_error_401_handler(self):
|
||||||
""" Custom handler for 401 error """
|
""" Custom handler for 401 error """
|
||||||
return r'''<!DOCTYPE html>
|
return r'''<!DOCTYPE html>
|
||||||
@ -4305,7 +4301,7 @@ class UI(MainHandler):
|
|||||||
def get_messages(self):
|
def get_messages(self):
|
||||||
messages = {}
|
messages = {}
|
||||||
cur_notification_num = 1
|
cur_notification_num = 1
|
||||||
for cur_notification in ui.notifications.get_notifications():
|
for cur_notification in ui.notifications.get_notifications(self.request.remote_ip):
|
||||||
messages['notification-' + str(cur_notification_num)] = {'title': cur_notification.title,
|
messages['notification-' + str(cur_notification_num)] = {'title': cur_notification.title,
|
||||||
'message': cur_notification.message,
|
'message': cur_notification.message,
|
||||||
'type': cur_notification.type}
|
'type': cur_notification.type}
|
||||||
|
Loading…
Reference in New Issue
Block a user