mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-03 01:43:37 +00:00
Fixed issues with webroot settings and reverse proxies.
Fixed issues with WebAPI and WebAPI builder.
This commit is contained in:
parent
b9c22582cf
commit
07685f4295
4 changed files with 115 additions and 112 deletions
|
@ -275,7 +275,7 @@ def main():
|
|||
if restore(restoreDir, sickbeard.PROG_DIR):
|
||||
logger.log(u"Restore successful...")
|
||||
else:
|
||||
logger.log(u"Restore FAILED!")
|
||||
logger.log(u"Restore FAILED!", logger.ERROR)
|
||||
|
||||
# If they don't specify a config file then put it in the data dir
|
||||
if not sickbeard.CONFIG_FILE:
|
||||
|
|
|
@ -98,11 +98,11 @@ class Api(webserve.MainHandler):
|
|||
|
||||
# if debug was set call the "_call_dispatcher"
|
||||
if 'debug' in kwargs:
|
||||
outDict = _call_dispatcher(args, kwargs) # this way we can debug the cherry.py traceback in the browser
|
||||
outDict = _call_dispatcher(self, args, kwargs) # this way we can debug the cherry.py traceback in the browser
|
||||
del kwargs["debug"]
|
||||
else: # if debug was not set we wrap the "call_dispatcher" in a try block to assure a json output
|
||||
try:
|
||||
outDict = _call_dispatcher(args, kwargs)
|
||||
outDict = _call_dispatcher(self, args, kwargs)
|
||||
except Exception, e: # real internal error oohhh nooo :(
|
||||
logger.log(u"API :: " + ex(e), logger.ERROR)
|
||||
errorData = {"error_msg": ex(e),
|
||||
|
@ -135,23 +135,22 @@ class Api(webserve.MainHandler):
|
|||
|
||||
t.sortedShowList = sorted(sickbeard.showList, lambda x, y: cmp(titler(x.name), titler(y.name)))
|
||||
|
||||
myDB = db.DBConnection(row_type="dict")
|
||||
seasonSQLResults = {}
|
||||
episodeSQLResults = {}
|
||||
|
||||
for curShow in t.sortedShowList:
|
||||
seasonSQLResults[curShow.indexerid] = myDB.select(
|
||||
"SELECT DISTINCT season FROM tv_episodes WHERE showid = ? ORDER BY season DESC", [curShow.indexerid])
|
||||
with db.DBConnection(row_type="dict") as myDB:
|
||||
for curShow in t.sortedShowList:
|
||||
seasonSQLResults[curShow.indexerid] = myDB.select(
|
||||
"SELECT DISTINCT season FROM tv_episodes WHERE showid = ? ORDER BY season DESC", [curShow.indexerid])
|
||||
|
||||
for curShow in t.sortedShowList:
|
||||
episodeSQLResults[curShow.indexerid] = myDB.select(
|
||||
"SELECT DISTINCT season,episode FROM tv_episodes WHERE showid = ? ORDER BY season DESC, episode DESC",
|
||||
[curShow.indexerid])
|
||||
for curShow in t.sortedShowList:
|
||||
episodeSQLResults[curShow.indexerid] = myDB.select(
|
||||
"SELECT DISTINCT season,episode FROM tv_episodes WHERE showid = ? ORDER BY season DESC, episode DESC",
|
||||
[curShow.indexerid])
|
||||
|
||||
t.seasonSQLResults = seasonSQLResults
|
||||
t.episodeSQLResults = episodeSQLResults
|
||||
t.seasonSQLResults = seasonSQLResults
|
||||
t.episodeSQLResults = episodeSQLResults
|
||||
|
||||
myDB.connection.close()
|
||||
if len(sickbeard.API_KEY) == 32:
|
||||
t.apikey = sickbeard.API_KEY
|
||||
else:
|
||||
|
@ -197,7 +196,7 @@ class Api(webserve.MainHandler):
|
|||
return False, msg, args, kwargs
|
||||
|
||||
|
||||
def call_dispatcher(args, kwargs):
|
||||
def call_dispatcher(handler, args, kwargs):
|
||||
""" calls the appropriate CMD class
|
||||
looks for a cmd in args and kwargs
|
||||
or calls the TVDBShorthandWrapper when the first args element is a number
|
||||
|
@ -230,10 +229,10 @@ def call_dispatcher(args, kwargs):
|
|||
if not (multiCmds and cmd in ('show.getposter', 'show.getbanner')): # skip these cmd while chaining
|
||||
try:
|
||||
if cmd in _functionMaper:
|
||||
curOutDict = _functionMaper.get(cmd)(curArgs,
|
||||
curOutDict = _functionMaper.get(cmd)(handler, curArgs,
|
||||
curKwargs).run() # get the cmd class, init it and run()
|
||||
elif _is_int(cmd):
|
||||
curOutDict = TVDBShorthandWrapper(curArgs, curKwargs, cmd).run()
|
||||
curOutDict = TVDBShorthandWrapper(handler, curArgs, curKwargs, cmd).run()
|
||||
else:
|
||||
curOutDict = _responds(RESULT_ERROR, "No such cmd: '" + cmd + "'")
|
||||
except ApiError, e: # Api errors that we raised, they are harmless
|
||||
|
@ -257,7 +256,7 @@ def call_dispatcher(args, kwargs):
|
|||
if multiCmds: # if we had multiple cmds we have to wrap it in a response dict
|
||||
outDict = _responds(RESULT_SUCCESS, outDict)
|
||||
else: # index / no cmd given
|
||||
outDict = CMD_SickBeard(args, kwargs).run()
|
||||
outDict = CMD_SickBeard(handler, args, kwargs).run()
|
||||
|
||||
return outDict
|
||||
|
||||
|
@ -296,10 +295,10 @@ def filter_params(cmd, args, kwargs):
|
|||
return curArgs, curKwargs
|
||||
|
||||
|
||||
class ApiCall(webserve.MainHandler):
|
||||
class ApiCall(object):
|
||||
_help = {"desc": "No help message available. Please tell the devs that a help msg is missing for this cmd"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
|
||||
# missing
|
||||
try:
|
||||
|
@ -311,6 +310,9 @@ class ApiCall(webserve.MainHandler):
|
|||
if 'help' in kwargs:
|
||||
self.run = self.return_help
|
||||
|
||||
# RequestHandler
|
||||
self.handler = handler
|
||||
|
||||
def run(self):
|
||||
# override with real output function in subclass
|
||||
return {}
|
||||
|
@ -477,7 +479,8 @@ class ApiCall(webserve.MainHandler):
|
|||
class TVDBShorthandWrapper(ApiCall):
|
||||
_help = {"desc": "this is an internal function wrapper. call the help command directly for more information"}
|
||||
|
||||
def __init__(self, args, kwargs, sid):
|
||||
def __init__(self, handler, args, kwargs, sid):
|
||||
self.handler = handler
|
||||
self.origArgs = args
|
||||
self.kwargs = kwargs
|
||||
self.sid = sid
|
||||
|
@ -486,17 +489,17 @@ class TVDBShorthandWrapper(ApiCall):
|
|||
self.e, args = self.check_params(args, kwargs, "e", None, False, "ignore", [])
|
||||
self.args = args
|
||||
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" internal function wrapper """
|
||||
args = (self.sid,) + self.origArgs
|
||||
if self.e:
|
||||
return CMD_Episode(args, self.kwargs).run()
|
||||
return CMD_Episode(self.handler, args, self.kwargs).run()
|
||||
elif self.s:
|
||||
return CMD_ShowSeasons(args, self.kwargs).run()
|
||||
return CMD_ShowSeasons(self.handler, args, self.kwargs).run()
|
||||
else:
|
||||
return CMD_Show(args, self.kwargs).run()
|
||||
return CMD_Show(self.handler, args, self.kwargs).run()
|
||||
|
||||
|
||||
################################
|
||||
|
@ -681,11 +684,11 @@ class CMD_Help(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.subject, args = self.check_params(args, kwargs, "subject", "help", False, "string", _functionMaper.keys())
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display help information for a given subject/command """
|
||||
|
@ -705,7 +708,7 @@ class CMD_ComingEpisodes(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.sort, args = self.check_params(args, kwargs, "sort", "date", False, "string", ["date", "show", "network"])
|
||||
|
@ -714,7 +717,7 @@ class CMD_ComingEpisodes(ApiCall):
|
|||
self.paused, args = self.check_params(args, kwargs, "paused", sickbeard.COMING_EPS_DISPLAY_PAUSED, False, "int",
|
||||
[0, 1])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display the coming episodes """
|
||||
|
@ -817,7 +820,7 @@ class CMD_Episode(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
self.s, args = self.check_params(args, kwargs, "season", None, True, "int", [])
|
||||
|
@ -825,7 +828,7 @@ class CMD_Episode(ApiCall):
|
|||
# optional
|
||||
self.fullPath, args = self.check_params(args, kwargs, "full_path", 0, False, "bool", [])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display detailed info about an episode """
|
||||
|
@ -875,14 +878,14 @@ class CMD_EpisodeSearch(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
self.s, args = self.check_params(args, kwargs, "season", None, True, "int", [])
|
||||
self.e, args = self.check_params(args, kwargs, "episode", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" search for an episode """
|
||||
|
@ -924,7 +927,7 @@ class CMD_EpisodeSetStatus(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
self.s, args = self.check_params(args, kwargs, "season", None, True, "int", [])
|
||||
|
@ -934,7 +937,7 @@ class CMD_EpisodeSetStatus(ApiCall):
|
|||
self.e, args = self.check_params(args, kwargs, "episode", None, False, "int", [])
|
||||
self.force, args = self.check_params(args, kwargs, "force", 0, False, "bool", [])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" set status of an episode or a season (when no ep is provided) """
|
||||
|
@ -1028,14 +1031,14 @@ class CMD_SubtitleSearch(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
self.s, args = self.check_params(args, kwargs, "season", None, True, "int", [])
|
||||
self.e, args = self.check_params(args, kwargs, "episode", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" search episode subtitles """
|
||||
|
@ -1078,12 +1081,12 @@ class CMD_Exceptions(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, False, "int", [])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display scene exceptions for all or a given show """
|
||||
|
@ -1121,13 +1124,13 @@ class CMD_History(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.limit, args = self.check_params(args, kwargs, "limit", 100, False, "int", [])
|
||||
self.type, args = self.check_params(args, kwargs, "type", None, False, "string", ["downloaded", "snatched"])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display sickbeard downloaded/snatched history """
|
||||
|
@ -1179,11 +1182,11 @@ class CMD_HistoryClear(ApiCall):
|
|||
_help = {"desc": "clear sickbeard's history",
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" clear sickbeard's history """
|
||||
|
@ -1198,11 +1201,11 @@ class CMD_HistoryTrim(ApiCall):
|
|||
_help = {"desc": "trim sickbeard's history by removing entries greater than 30 days old"
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" trim sickbeard's history """
|
||||
|
@ -1220,13 +1223,13 @@ class CMD_Logs(ApiCall):
|
|||
"desc": "the minimum level classification of log entries to show, with each level inherting its above level"}}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.min_level, args = self.check_params(args, kwargs, "min_level", "error", False, "string",
|
||||
["error", "warning", "info", "debug"])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" view sickbeard's log """
|
||||
|
@ -1278,11 +1281,11 @@ class CMD_Logs(ApiCall):
|
|||
class CMD_SickBeard(ApiCall):
|
||||
_help = {"desc": "display misc sickbeard related information"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display misc sickbeard related information """
|
||||
|
@ -1299,13 +1302,13 @@ class CMD_SickBeardAddRootDir(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.location, args = self.check_params(args, kwargs, "location", None, True, "string", [])
|
||||
# optional
|
||||
self.default, args = self.check_params(args, kwargs, "default", 0, False, "bool", [])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" add a parent directory to sickbeard's config """
|
||||
|
@ -1352,11 +1355,11 @@ class CMD_SickBeardAddRootDir(ApiCall):
|
|||
class CMD_SickBeardCheckScheduler(ApiCall):
|
||||
_help = {"desc": "query the scheduler"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" query the scheduler """
|
||||
|
@ -1379,12 +1382,12 @@ class CMD_SickBeardDeleteRootDir(ApiCall):
|
|||
"requiredParameters": {"location": {"desc": "the full path to root (parent) directory"}}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.location, args = self.check_params(args, kwargs, "location", None, True, "string", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" delete a parent directory from sickbeard's config """
|
||||
|
@ -1423,11 +1426,11 @@ class CMD_SickBeardDeleteRootDir(ApiCall):
|
|||
class CMD_SickBeardGetDefaults(ApiCall):
|
||||
_help = {"desc": "get sickbeard user defaults"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" get sickbeard user defaults """
|
||||
|
@ -1443,11 +1446,11 @@ class CMD_SickBeardGetDefaults(ApiCall):
|
|||
class CMD_SickBeardGetMessages(ApiCall):
|
||||
_help = {"desc": "get all messages"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
messages = []
|
||||
|
@ -1461,11 +1464,11 @@ class CMD_SickBeardGetMessages(ApiCall):
|
|||
class CMD_SickBeardGetRootDirs(ApiCall):
|
||||
_help = {"desc": "get sickbeard user parent directories"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" get the parent directories defined in sickbeard's config """
|
||||
|
@ -1478,12 +1481,12 @@ class CMD_SickBeardPauseBacklog(ApiCall):
|
|||
"optionalParameters": {"pause ": {"desc": "pause or unpause the global backlog"}}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.pause, args = self.check_params(args, kwargs, "pause", 0, False, "bool", [])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" pause the backlog search """
|
||||
|
@ -1498,15 +1501,15 @@ class CMD_SickBeardPauseBacklog(ApiCall):
|
|||
class CMD_SickBeardPing(ApiCall):
|
||||
_help = {"desc": "check to see if sickbeard is running"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" check to see if sickbeard is running """
|
||||
self.set_header('Cache-Control', "max-age=0,no-cache,no-store")
|
||||
self.handler.set_header('Cache-Control', "max-age=0,no-cache,no-store")
|
||||
if sickbeard.started:
|
||||
return _responds(RESULT_SUCCESS, {"pid": sickbeard.PID}, "Pong")
|
||||
else:
|
||||
|
@ -1516,11 +1519,11 @@ class CMD_SickBeardPing(ApiCall):
|
|||
class CMD_SickBeardRestart(ApiCall):
|
||||
_help = {"desc": "restart sickbeard"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" restart sickbeard """
|
||||
|
@ -1542,7 +1545,7 @@ class CMD_SickBeardSearchIndexers(ApiCall):
|
|||
'de': 14, 'da': 10, 'fi': 11, 'hu': 19, 'ja': 25, 'he': 24, 'ko': 32,
|
||||
'sv': 8, 'sl': 30}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.name, args = self.check_params(args, kwargs, "name", None, False, "string", [])
|
||||
|
@ -1551,7 +1554,7 @@ class CMD_SickBeardSearchIndexers(ApiCall):
|
|||
self.indexer, args = self.check_params(args, kwargs, "indexer", None, False, "string", [])
|
||||
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" search for show at tvdb with a given string and language """
|
||||
|
@ -1624,7 +1627,7 @@ class CMD_SickBeardSetDefaults(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.initial, args = self.check_params(args, kwargs, "initial", None, False, "list",
|
||||
|
@ -1638,7 +1641,7 @@ class CMD_SickBeardSetDefaults(ApiCall):
|
|||
self.status, args = self.check_params(args, kwargs, "status", None, False, "string",
|
||||
["wanted", "skipped", "archived", "ignored"])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" set sickbeard user defaults """
|
||||
|
@ -1693,11 +1696,11 @@ class CMD_SickBeardSetDefaults(ApiCall):
|
|||
class CMD_SickBeardShutdown(ApiCall):
|
||||
_help = {"desc": "shutdown sickbeard"}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" shutdown sickbeard """
|
||||
|
@ -1711,12 +1714,12 @@ class CMD_Show(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display information for a given show """
|
||||
|
@ -1779,7 +1782,7 @@ class CMD_ShowAddExisting(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
if "tvdbid" in args or "tvdbid" in kwargs:
|
||||
_INDEXER_INT = 1
|
||||
_INDEXER = "tvdbid"
|
||||
|
@ -1788,7 +1791,7 @@ class CMD_ShowAddExisting(ApiCall):
|
|||
_INDEXER = "tvrageid"
|
||||
else:
|
||||
_INDEXER_INT = None
|
||||
_INDEXER = None
|
||||
_INDEXER = None
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, _INDEXER, None, True, "int", [])
|
||||
self.indexer = _INDEXER_INT
|
||||
|
@ -1805,7 +1808,7 @@ class CMD_ShowAddExisting(ApiCall):
|
|||
self.subtitles, args = self.check_params(args, kwargs, "subtitles", int(sickbeard.USE_SUBTITLES), False, "int",
|
||||
[])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" add a show in sickbeard with an existing folder """
|
||||
|
@ -1879,7 +1882,7 @@ class CMD_ShowAddNew(ApiCall):
|
|||
'de': 14, 'da': 10, 'fi': 11, 'hu': 19, 'ja': 25, 'he': 24, 'ko': 32,
|
||||
'sv': 8, 'sl': 30}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
if "tvdbid" in args or "tvdbid" in kwargs:
|
||||
_INDEXER_INT = 1
|
||||
_INDEXER = "tvdbid"
|
||||
|
@ -1888,7 +1891,7 @@ class CMD_ShowAddNew(ApiCall):
|
|||
_INDEXER = "tvrageid"
|
||||
else:
|
||||
_INDEXER_INT = None
|
||||
_INDEXER = None
|
||||
_INDEXER = None
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, _INDEXER, None, True, "int", [])
|
||||
self.indexer = _INDEXER_INT
|
||||
|
@ -1908,7 +1911,7 @@ class CMD_ShowAddNew(ApiCall):
|
|||
self.subtitles, args = self.check_params(args, kwargs, "subtitles", int(sickbeard.USE_SUBTITLES), False, "int",
|
||||
[])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" add a show in sickbeard with an existing folder """
|
||||
|
@ -2009,12 +2012,12 @@ class CMD_ShowCache(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" check sickbeard's cache to see if the banner or poster image for a show is valid """
|
||||
|
@ -2044,12 +2047,12 @@ class CMD_ShowDelete(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" delete a show in sickbeard """
|
||||
|
@ -2071,12 +2074,12 @@ class CMD_ShowGetQuality(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" get quality setting for a show in sickbeard """
|
||||
|
@ -2095,12 +2098,12 @@ class CMD_ShowGetPoster(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" get the poster for a show in sickbeard """
|
||||
|
@ -2113,12 +2116,12 @@ class CMD_ShowGetBanner(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" get the banner for a show in sickbeard """
|
||||
|
@ -2133,13 +2136,13 @@ class CMD_ShowPause(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
self.pause, args = self.check_params(args, kwargs, "pause", 0, False, "bool", [])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" set a show's paused state in sickbeard """
|
||||
|
@ -2163,12 +2166,12 @@ class CMD_ShowRefresh(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" refresh a show in sickbeard """
|
||||
|
@ -2192,14 +2195,14 @@ class CMD_ShowSeasonList(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
self.sort, args = self.check_params(args, kwargs, "sort", "desc", False, "string",
|
||||
["asc", "desc"]) # "asc" and "desc" default and fallback is "desc"
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display the season list for a given show """
|
||||
|
@ -2230,13 +2233,13 @@ class CMD_ShowSeasons(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
self.season, args = self.check_params(args, kwargs, "season", None, False, "int", [])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display a listing of episodes for all or a given show """
|
||||
|
@ -2295,7 +2298,7 @@ class CMD_ShowSetQuality(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
|
@ -2308,7 +2311,7 @@ class CMD_ShowSetQuality(ApiCall):
|
|||
["sddvd", "hdtv", "rawhdtv", "fullhdtv", "hdwebdl", "fullhdwebdl",
|
||||
"hdbluray", "fullhdbluray"])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" set the quality for a show in sickbeard by taking in a deliminated
|
||||
|
@ -2355,12 +2358,12 @@ class CMD_ShowStats(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display episode statistics for a given show """
|
||||
|
@ -2460,12 +2463,12 @@ class CMD_ShowUpdate(ApiCall):
|
|||
}
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, True, "int", [])
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" update a show in sickbeard """
|
||||
|
@ -2488,13 +2491,13 @@ class CMD_Shows(ApiCall):
|
|||
},
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
self.sort, args = self.check_params(args, kwargs, "sort", "id", False, "string", ["id", "name"])
|
||||
self.paused, args = self.check_params(args, kwargs, "paused", None, False, "bool", [])
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display_is_int_multi( self.indexerid )shows in sickbeard """
|
||||
|
@ -2533,11 +2536,11 @@ class CMD_ShowsStats(ApiCall):
|
|||
_help = {"desc": "display the global shows and episode stats"
|
||||
}
|
||||
|
||||
def __init__(self, args, kwargs):
|
||||
def __init__(self, handler, args, kwargs):
|
||||
# required
|
||||
# optional
|
||||
# super, missing, help
|
||||
ApiCall.__init__(self, args, kwargs)
|
||||
ApiCall.__init__(self, handler, args, kwargs)
|
||||
|
||||
def run(self):
|
||||
""" display the global shows and episode stats """
|
||||
|
|
|
@ -169,7 +169,7 @@ class MainHandler(RequestHandler):
|
|||
path = self.request.uri.replace(sickbeard.WEB_ROOT, '').split('?')[0]
|
||||
|
||||
method = path.strip('/').split('/')[-1]
|
||||
if path.startswith('/api'):
|
||||
if path.startswith('/api') and method != 'builder':
|
||||
apikey = path.strip('/').split('/')[-1]
|
||||
method = path.strip('/').split('/')[0]
|
||||
self.request.arguments.update({'apikey': [apikey]})
|
||||
|
|
|
@ -73,7 +73,7 @@ def initWebServer(options={}):
|
|||
|
||||
# Main Handler
|
||||
app.add_handlers(".*$", [
|
||||
(r"/", RedirectHandler, {'url': '%s/home/' % options['web_root']}),
|
||||
(r"%s" % options['web_root'], RedirectHandler, {'url': '%s/home/' % options['web_root']}),
|
||||
(r'%s/api/(.*)(/?)' % options['web_root'], webapi.Api),
|
||||
(r'%s/(.*)(/?)' % options['web_root'], webserve.MainHandler)
|
||||
])
|
||||
|
|
Loading…
Reference in a new issue