mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05:00
Merge pull request #949 from frdfsnlght/api-fixes
Added features for web api
This commit is contained in:
commit
431f9506cf
@ -51,6 +51,8 @@ addList("Command", "Scene Exceptions", "?cmd=exceptions", "exceptions");
|
|||||||
addList("Command", "History", "?cmd=history", "history");
|
addList("Command", "History", "?cmd=history", "history");
|
||||||
addOption("Command", "History.Clear", "?cmd=history.clear", "", "", "action");
|
addOption("Command", "History.Clear", "?cmd=history.clear", "", "", "action");
|
||||||
addOption("Command", "History.Trim", "?cmd=history.trim", "", "", "action");
|
addOption("Command", "History.Trim", "?cmd=history.trim", "", "", "action");
|
||||||
|
addList("Command", "Failed", "?cmd=failed", "failed");
|
||||||
|
addOption("Command", "Backlog", "?cmd=backlog");
|
||||||
addList("Command", "PostProcess", "?cmd=postprocess", "postprocess", "", "","action");
|
addList("Command", "PostProcess", "?cmd=postprocess", "postprocess", "", "","action");
|
||||||
|
|
||||||
addList("Command", "Logs", "?cmd=logs", "logs");
|
addList("Command", "Logs", "?cmd=logs", "logs");
|
||||||
@ -321,6 +323,15 @@ addOption("history-limit", "Optional Param", "", 1);
|
|||||||
addOption("history-limit", "Show Only Downloaded", "&type=downloaded");
|
addOption("history-limit", "Show Only Downloaded", "&type=downloaded");
|
||||||
addOption("history-limit", "Show Only Snatched", "&type=snatched");
|
addOption("history-limit", "Show Only Snatched", "&type=snatched");
|
||||||
|
|
||||||
|
addOption("failed", "Optional Param", "", 1);
|
||||||
|
//addOptGroup("failed", "Limit Results");
|
||||||
|
addList("failed", "Limit Results (2)", "&limit=2", "failed-limit");
|
||||||
|
addList("failed", "Limit Results (25)", "&limit=25", "failed-limit");
|
||||||
|
addList("failed", "Limit Results (50)", "&limit=50", "failed-limit");
|
||||||
|
//endOptGroup("failed");
|
||||||
|
|
||||||
|
addOption("failed-limit", "Optional Param", "", 1);
|
||||||
|
|
||||||
addOption("exceptions", "Optional Param", "", 1);
|
addOption("exceptions", "Optional Param", "", 1);
|
||||||
#for $curShow in $sortedShowList:
|
#for $curShow in $sortedShowList:
|
||||||
addOption("exceptions", "$curShow.name", "&indexerid=$curShow.indexerid");
|
addOption("exceptions", "$curShow.name", "&indexerid=$curShow.indexerid");
|
||||||
|
@ -37,7 +37,7 @@ from sickbeard import processTV
|
|||||||
from sickbeard import network_timezones, sbdatetime
|
from sickbeard import network_timezones, sbdatetime
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
from sickbeard.common import SNATCHED, SNATCHED_PROPER, DOWNLOADED, SKIPPED, UNAIRED, IGNORED, ARCHIVED, WANTED, UNKNOWN
|
from sickbeard.common import SNATCHED, SNATCHED_PROPER, DOWNLOADED, SKIPPED, UNAIRED, IGNORED, ARCHIVED, WANTED, UNKNOWN
|
||||||
from common import Quality, qualityPresetStrings, statusStrings
|
from common import Quality, Overview, qualityPresetStrings, statusStrings
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
@ -1260,6 +1260,70 @@ class CMD_HistoryTrim(ApiCall):
|
|||||||
|
|
||||||
return _responds(RESULT_SUCCESS, msg="Removed history entries greater than 30 days old")
|
return _responds(RESULT_SUCCESS, msg="Removed history entries greater than 30 days old")
|
||||||
|
|
||||||
|
class CMD_Failed(ApiCall):
|
||||||
|
_help = {"desc": "display failed downloads",
|
||||||
|
"optionalParameters": {"limit": {"desc": "limit returned results"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, handler, args, kwargs):
|
||||||
|
# required
|
||||||
|
# optional
|
||||||
|
self.limit, args = self.check_params(args, kwargs, "limit", 100, False, "int", [])
|
||||||
|
# super, missing, help
|
||||||
|
ApiCall.__init__(self, handler, args, kwargs)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
""" display failed downloads """
|
||||||
|
|
||||||
|
myDB = db.DBConnection('failed.db', row_type="dict")
|
||||||
|
|
||||||
|
ulimit = min(int(self.limit), 100)
|
||||||
|
if ulimit == 0:
|
||||||
|
sqlResults = myDB.select("SELECT * FROM failed")
|
||||||
|
else:
|
||||||
|
sqlResults = myDB.select("SELECT * FROM failed LIMIT ?", [ulimit])
|
||||||
|
|
||||||
|
return _responds(RESULT_SUCCESS, sqlResults)
|
||||||
|
|
||||||
|
class CMD_Backlog(ApiCall):
|
||||||
|
_help = {"desc": "display backlogged episodes"}
|
||||||
|
|
||||||
|
def __init__(self, handler, args, kwargs):
|
||||||
|
# required
|
||||||
|
# optional
|
||||||
|
# super, missing, help
|
||||||
|
ApiCall.__init__(self, handler, args, kwargs)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
""" display backlogged episodes """
|
||||||
|
|
||||||
|
shows = []
|
||||||
|
|
||||||
|
myDB = db.DBConnection(row_type="dict")
|
||||||
|
for curShow in sickbeard.showList:
|
||||||
|
|
||||||
|
showEps = []
|
||||||
|
|
||||||
|
sqlResults = myDB.select(
|
||||||
|
"SELECT * FROM tv_episodes WHERE showid = ? ORDER BY season DESC, episode DESC",
|
||||||
|
[curShow.indexerid])
|
||||||
|
|
||||||
|
for curResult in sqlResults:
|
||||||
|
|
||||||
|
curEpCat = curShow.getOverview(int(curResult["status"]))
|
||||||
|
if curEpCat and curEpCat in (Overview.WANTED, Overview.QUAL):
|
||||||
|
showEps.append(curResult)
|
||||||
|
|
||||||
|
if showEps:
|
||||||
|
shows.append({
|
||||||
|
"indexerid": curShow.indexerid,
|
||||||
|
"show_name": curShow.name,
|
||||||
|
"status": curShow.status,
|
||||||
|
"episodes": showEps
|
||||||
|
})
|
||||||
|
|
||||||
|
return _responds(RESULT_SUCCESS, shows)
|
||||||
|
|
||||||
class CMD_Logs(ApiCall):
|
class CMD_Logs(ApiCall):
|
||||||
_help = {"desc": "view sickrage's log",
|
_help = {"desc": "view sickrage's log",
|
||||||
@ -2724,6 +2788,8 @@ class CMD_Shows(ApiCall):
|
|||||||
if self.paused != None and bool(self.paused) != bool(curShow.paused):
|
if self.paused != None and bool(self.paused) != bool(curShow.paused):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
indexerShow = helpers.mapIndexersToShow(curShow)
|
||||||
|
|
||||||
showDict = {
|
showDict = {
|
||||||
"paused": curShow.paused,
|
"paused": curShow.paused,
|
||||||
"quality": _get_quality_string(curShow.quality),
|
"quality": _get_quality_string(curShow.quality),
|
||||||
@ -2732,8 +2798,8 @@ class CMD_Shows(ApiCall):
|
|||||||
"sports": curShow.sports,
|
"sports": curShow.sports,
|
||||||
"anime": curShow.anime,
|
"anime": curShow.anime,
|
||||||
"indexerid": curShow.indexerid,
|
"indexerid": curShow.indexerid,
|
||||||
"tvdbid": helpers.mapIndexersToShow(curShow)[1],
|
"tvdbid": indexerShow[1],
|
||||||
"tvrage_id": helpers.mapIndexersToShow(curShow)[2],
|
"tvrage_id": indexerShow[2],
|
||||||
"tvrage_name": curShow.name,
|
"tvrage_name": curShow.name,
|
||||||
"network": curShow.network,
|
"network": curShow.network,
|
||||||
"show_name": curShow.name,
|
"show_name": curShow.name,
|
||||||
@ -2805,6 +2871,8 @@ _functionMaper = {"help": CMD_Help,
|
|||||||
"history": CMD_History,
|
"history": CMD_History,
|
||||||
"history.clear": CMD_HistoryClear,
|
"history.clear": CMD_HistoryClear,
|
||||||
"history.trim": CMD_HistoryTrim,
|
"history.trim": CMD_HistoryTrim,
|
||||||
|
"failed": CMD_Failed,
|
||||||
|
"backlog": CMD_Backlog,
|
||||||
"logs": CMD_Logs,
|
"logs": CMD_Logs,
|
||||||
"sb": CMD_SickBeard,
|
"sb": CMD_SickBeard,
|
||||||
"postprocess": CMD_PostProcess,
|
"postprocess": CMD_PostProcess,
|
||||||
|
Loading…
Reference in New Issue
Block a user