mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05:00
Fixed issues with trakt and root dirs.
Fixed web root issues.
This commit is contained in:
parent
e891e9d637
commit
2d0c31510e
@ -152,19 +152,23 @@ class TraktChecker():
|
|||||||
|
|
||||||
logger.log(u"Adding show " + str(indexerid))
|
logger.log(u"Adding show " + str(indexerid))
|
||||||
root_dirs = sickbeard.ROOT_DIRS.split('|')
|
root_dirs = sickbeard.ROOT_DIRS.split('|')
|
||||||
location = root_dirs[int(root_dirs[0]) + 1]
|
if root_dirs:
|
||||||
|
location = root_dirs[int(root_dirs[0]) + 1]
|
||||||
|
|
||||||
showPath = ek.ek(os.path.join, location, helpers.sanitizeFileName(name))
|
showPath = ek.ek(os.path.join, location, helpers.sanitizeFileName(name))
|
||||||
dir_exists = helpers.makeDir(showPath)
|
dir_exists = helpers.makeDir(showPath)
|
||||||
if not dir_exists:
|
if not dir_exists:
|
||||||
logger.log(u"Unable to create the folder " + showPath + ", can't add the show", logger.ERROR)
|
logger.log(u"Unable to create the folder " + showPath + ", can't add the show", logger.ERROR)
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
helpers.chmodAsParent(showPath)
|
||||||
|
|
||||||
|
sickbeard.showQueueScheduler.action.addShow(1, int(indexerid), showPath, status,
|
||||||
|
int(sickbeard.QUALITY_DEFAULT),
|
||||||
|
int(sickbeard.FLATTEN_FOLDERS_DEFAULT))
|
||||||
else:
|
else:
|
||||||
helpers.chmodAsParent(showPath)
|
logger.log(u"There was an error creating the show, no root directory setting found", logger.ERROR)
|
||||||
|
return
|
||||||
sickbeard.showQueueScheduler.action.addShow(1, int(indexerid), showPath, status,
|
|
||||||
int(sickbeard.QUALITY_DEFAULT),
|
|
||||||
int(sickbeard.FLATTEN_FOLDERS_DEFAULT))
|
|
||||||
|
|
||||||
def setEpisodeToWanted(self, show, s, e):
|
def setEpisodeToWanted(self, show, s, e):
|
||||||
"""
|
"""
|
||||||
|
@ -2830,25 +2830,29 @@ class NewHomeAddShows(MainHandler):
|
|||||||
return
|
return
|
||||||
|
|
||||||
root_dirs = sickbeard.ROOT_DIRS.split('|')
|
root_dirs = sickbeard.ROOT_DIRS.split('|')
|
||||||
location = root_dirs[int(root_dirs[0]) + 1]
|
if root_dirs:
|
||||||
|
location = root_dirs[int(root_dirs[0]) + 1]
|
||||||
|
|
||||||
show_dir = ek.ek(os.path.join, location, helpers.sanitizeFileName(showName))
|
show_dir = ek.ek(os.path.join, location, helpers.sanitizeFileName(showName))
|
||||||
dir_exists = helpers.makeDir(show_dir)
|
dir_exists = helpers.makeDir(show_dir)
|
||||||
if not dir_exists:
|
if not dir_exists:
|
||||||
logger.log(u"Unable to create the folder " + show_dir + ", can't add the show", logger.ERROR)
|
logger.log(u"Unable to create the folder " + show_dir + ", can't add the show", logger.ERROR)
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
helpers.chmodAsParent(show_dir)
|
||||||
|
|
||||||
|
sickbeard.showQueueScheduler.action.addShow(1, int(indexer_id), show_dir,
|
||||||
|
default_status=sickbeard.STATUS_DEFAULT,
|
||||||
|
quality=sickbeard.QUALITY_DEFAULT,
|
||||||
|
flatten_folders=sickbeard.FLATTEN_FOLDERS_DEFAULT,
|
||||||
|
subtitles=sickbeard.SUBTITLES_DEFAULT,
|
||||||
|
anime=sickbeard.ANIME_DEFAULT,
|
||||||
|
scene=sickbeard.SCENE_DEFAULT)
|
||||||
|
|
||||||
|
ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir)
|
||||||
else:
|
else:
|
||||||
helpers.chmodAsParent(show_dir)
|
logger.log(u"There was an error creating the show, no root directory setting found", logger.ERROR)
|
||||||
|
return
|
||||||
sickbeard.showQueueScheduler.action.addShow(1, int(indexer_id), show_dir,
|
|
||||||
default_status=sickbeard.STATUS_DEFAULT,
|
|
||||||
quality=sickbeard.QUALITY_DEFAULT,
|
|
||||||
flatten_folders=sickbeard.FLATTEN_FOLDERS_DEFAULT,
|
|
||||||
subtitles=sickbeard.SUBTITLES_DEFAULT,
|
|
||||||
anime=sickbeard.ANIME_DEFAULT,
|
|
||||||
scene=sickbeard.SCENE_DEFAULT)
|
|
||||||
|
|
||||||
ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir)
|
|
||||||
|
|
||||||
# done adding show
|
# done adding show
|
||||||
redirect('/home/')
|
redirect('/home/')
|
||||||
|
@ -13,6 +13,7 @@ from tornado.web import Application, StaticFileHandler, RedirectHandler, HTTPErr
|
|||||||
from tornado.httpserver import HTTPServer
|
from tornado.httpserver import HTTPServer
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
|
|
||||||
class MultiStaticFileHandler(StaticFileHandler):
|
class MultiStaticFileHandler(StaticFileHandler):
|
||||||
def initialize(self, paths, default_filename=None):
|
def initialize(self, paths, default_filename=None):
|
||||||
self.paths = paths
|
self.paths = paths
|
||||||
@ -34,6 +35,7 @@ class MultiStaticFileHandler(StaticFileHandler):
|
|||||||
# Oops file not found anywhere!
|
# Oops file not found anywhere!
|
||||||
raise HTTPError(404)
|
raise HTTPError(404)
|
||||||
|
|
||||||
|
|
||||||
class SRWebServer(threading.Thread):
|
class SRWebServer(threading.Thread):
|
||||||
def __init__(self, options={}, io_loop=None):
|
def __init__(self, options={}, io_loop=None):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
@ -48,10 +50,18 @@ class SRWebServer(threading.Thread):
|
|||||||
self.options.setdefault('log_dir', None)
|
self.options.setdefault('log_dir', None)
|
||||||
self.options.setdefault('username', '')
|
self.options.setdefault('username', '')
|
||||||
self.options.setdefault('password', '')
|
self.options.setdefault('password', '')
|
||||||
self.options.setdefault('web_root', '/')
|
self.options.setdefault('web_root', None)
|
||||||
assert isinstance(self.options['port'], int)
|
assert isinstance(self.options['port'], int)
|
||||||
assert 'data_root' in self.options
|
assert 'data_root' in self.options
|
||||||
|
|
||||||
|
# video root
|
||||||
|
root_dirs = sickbeard.ROOT_DIRS.split('|')
|
||||||
|
self.video_root = root_dirs[int(root_dirs[0]) + 1] if root_dirs else None
|
||||||
|
|
||||||
|
# web root
|
||||||
|
self.options['web_root'] = ('/' + self.options['web_root'].lstrip('/')) if self.options[
|
||||||
|
'web_root'] else ''
|
||||||
|
|
||||||
# tornado setup
|
# tornado setup
|
||||||
self.enable_https = self.options['enable_https']
|
self.enable_https = self.options['enable_https']
|
||||||
self.https_cert = self.options['https_cert']
|
self.https_cert = self.options['https_cert']
|
||||||
@ -59,7 +69,8 @@ class SRWebServer(threading.Thread):
|
|||||||
|
|
||||||
if self.enable_https:
|
if self.enable_https:
|
||||||
# If either the HTTPS certificate or key do not exist, make some self-signed ones.
|
# If either the HTTPS certificate or key do not exist, make some self-signed ones.
|
||||||
if not (self.https_cert and os.path.exists(self.https_cert)) or not (self.https_key and os.path.exists(self.https_key)):
|
if not (self.https_cert and os.path.exists(self.https_cert)) or not (
|
||||||
|
self.https_key and os.path.exists(self.https_key)):
|
||||||
if not create_https_certificates(self.https_cert, self.https_key):
|
if not create_https_certificates(self.https_cert, self.https_key):
|
||||||
logger.log(u"Unable to create CERT/KEY files, disabling HTTPS")
|
logger.log(u"Unable to create CERT/KEY files, disabling HTTPS")
|
||||||
sickbeard.ENABLE_HTTPS = False
|
sickbeard.ENABLE_HTTPS = False
|
||||||
@ -72,39 +83,45 @@ class SRWebServer(threading.Thread):
|
|||||||
|
|
||||||
# Load the app
|
# Load the app
|
||||||
self.app = Application([],
|
self.app = Application([],
|
||||||
debug=True,
|
debug=True,
|
||||||
autoreload=False,
|
autoreload=False,
|
||||||
gzip=True,
|
gzip=True,
|
||||||
xheaders=sickbeard.HANDLE_REVERSE_PROXY,
|
xheaders=sickbeard.HANDLE_REVERSE_PROXY,
|
||||||
cookie_secret='61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo='
|
cookie_secret='61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo='
|
||||||
)
|
)
|
||||||
|
|
||||||
# Main Handler
|
# Main Handler
|
||||||
self.app.add_handlers(".*$", [
|
self.app.add_handlers(".*$", [
|
||||||
(r'%s/api/(.*)(/?)' % self.options['web_root'], webapi.Api),
|
(r'%s/api/(.*)' % self.options['web_root'], webapi.Api),
|
||||||
(r'%s/(.*)(/?)' % self.options['web_root'], webserve.MainHandler),
|
(r'%s/(.*)' % self.options['web_root'], webserve.MainHandler),
|
||||||
(r'(.*)', webserve.MainHandler)
|
(r'(.*)', webserve.MainHandler)
|
||||||
])
|
])
|
||||||
|
|
||||||
# Static Path Handler
|
# Static Path Handler
|
||||||
self.app.add_handlers(".*$", [
|
self.app.add_handlers(".*$", [
|
||||||
(r'/(favicon\.ico)', MultiStaticFileHandler,
|
(r'%s/(favicon\.ico)' % self.options['web_root'], MultiStaticFileHandler,
|
||||||
{'paths': [os.path.join(self.options['data_root'], 'images/ico/favicon.ico')]}),
|
{'paths': [os.path.join(self.options['data_root'], 'images/ico/favicon.ico')]}),
|
||||||
(r'%s/%s/(.*)(/?)' % (self.options['web_root'], 'images'), MultiStaticFileHandler,
|
(r'%s/%s/(.*)' % (self.options['web_root'], 'images'), MultiStaticFileHandler,
|
||||||
{'paths': [os.path.join(self.options['data_root'], 'images'),
|
{'paths': [os.path.join(self.options['data_root'], 'images'),
|
||||||
os.path.join(sickbeard.CACHE_DIR, 'images')]}),
|
os.path.join(sickbeard.CACHE_DIR, 'images')]}),
|
||||||
(r'%s/%s/(.*)(/?)' % (self.options['web_root'], 'css'), MultiStaticFileHandler,
|
(r'%s/%s/(.*)' % (self.options['web_root'], 'css'), MultiStaticFileHandler,
|
||||||
{'paths': [os.path.join(self.options['data_root'], 'css')]}),
|
{'paths': [os.path.join(self.options['data_root'], 'css')]}),
|
||||||
(r'%s/%s/(.*)(/?)' % (self.options['web_root'], 'js'), MultiStaticFileHandler,
|
(r'%s/%s/(.*)' % (self.options['web_root'], 'js'), MultiStaticFileHandler,
|
||||||
{'paths': [os.path.join(self.options['data_root'], 'js')]})
|
{'paths': [os.path.join(self.options['data_root'], 'js')]}),
|
||||||
|
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# Static Videos Path
|
||||||
|
if self.video_root:
|
||||||
|
self.app.add_handlers(".*$", [
|
||||||
|
(r'%s/%s/(.*)' % (self.options['web_root'], self.video_root), MultiStaticFileHandler,
|
||||||
|
{'paths': [self.video_root]}),
|
||||||
|
])
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.enable_https:
|
if self.enable_https:
|
||||||
protocol = "https"
|
protocol = "https"
|
||||||
self.server = HTTPServer(self.app, no_keep_alive=True,
|
self.server = HTTPServer(self.app, no_keep_alive=True,
|
||||||
ssl_options={"certfile": self.https_cert, "keyfile": self.https_key})
|
ssl_options={"certfile": self.https_cert, "keyfile": self.https_key})
|
||||||
else:
|
else:
|
||||||
protocol = "http"
|
protocol = "http"
|
||||||
self.server = HTTPServer(self.app, no_keep_alive=True)
|
self.server = HTTPServer(self.app, no_keep_alive=True)
|
||||||
@ -116,7 +133,9 @@ class SRWebServer(threading.Thread):
|
|||||||
self.server.listen(self.options['port'], self.options['host'])
|
self.server.listen(self.options['port'], self.options['host'])
|
||||||
except:
|
except:
|
||||||
etype, evalue, etb = sys.exc_info()
|
etype, evalue, etb = sys.exc_info()
|
||||||
logger.log("Could not start webserver on %s. Excpeption: %s, Error: %s" % (self.options['port'], etype, evalue), logger.ERROR)
|
logger.log(
|
||||||
|
"Could not start webserver on %s. Excpeption: %s, Error: %s" % (self.options['port'], etype, evalue),
|
||||||
|
logger.ERROR)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user