|
@ -86,7 +86,7 @@ _MSG_BAD_SERVER_PARMS = "Incorrect server settings" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def api_handler(kwargs): |
|
|
def api_handler(kwargs): |
|
|
""" API Dispatcher """ |
|
|
"""API Dispatcher""" |
|
|
# Clean-up the arguments |
|
|
# Clean-up the arguments |
|
|
for vr in ("mode", "output", "name"): |
|
|
for vr in ("mode", "output", "name"): |
|
|
if vr in kwargs and isinstance(kwargs[vr], list): |
|
|
if vr in kwargs and isinstance(kwargs[vr], list): |
|
@ -101,13 +101,13 @@ def api_handler(kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_get_config(name, output, kwargs): |
|
|
def _api_get_config(name, output, kwargs): |
|
|
""" API: accepts output, keyword, section """ |
|
|
"""API: accepts output, keyword, section""" |
|
|
_, data = config.get_dconfig(kwargs.get("section"), kwargs.get("keyword")) |
|
|
_, data = config.get_dconfig(kwargs.get("section"), kwargs.get("keyword")) |
|
|
return report(output, keyword="config", data=data) |
|
|
return report(output, keyword="config", data=data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_set_config(name, output, kwargs): |
|
|
def _api_set_config(name, output, kwargs): |
|
|
""" API: accepts output, keyword, section """ |
|
|
"""API: accepts output, keyword, section""" |
|
|
if cfg.configlock(): |
|
|
if cfg.configlock(): |
|
|
return report(output, _MSG_CONFIG_LOCKED) |
|
|
return report(output, _MSG_CONFIG_LOCKED) |
|
|
if kwargs.get("section") == "servers": |
|
|
if kwargs.get("section") == "servers": |
|
@ -126,7 +126,7 @@ def _api_set_config(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_set_config_default(name, output, kwargs): |
|
|
def _api_set_config_default(name, output, kwargs): |
|
|
""" API: Reset requested config variables back to defaults. Currently only for misc-section """ |
|
|
"""API: Reset requested config variables back to defaults. Currently only for misc-section""" |
|
|
if cfg.configlock(): |
|
|
if cfg.configlock(): |
|
|
return report(output, _MSG_CONFIG_LOCKED) |
|
|
return report(output, _MSG_CONFIG_LOCKED) |
|
|
keywords = kwargs.get("keyword", []) |
|
|
keywords = kwargs.get("keyword", []) |
|
@ -141,7 +141,7 @@ def _api_set_config_default(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_del_config(name, output, kwargs): |
|
|
def _api_del_config(name, output, kwargs): |
|
|
""" API: accepts output, keyword, section """ |
|
|
"""API: accepts output, keyword, section""" |
|
|
if cfg.configlock(): |
|
|
if cfg.configlock(): |
|
|
return report(output, _MSG_CONFIG_LOCKED) |
|
|
return report(output, _MSG_CONFIG_LOCKED) |
|
|
if del_from_section(kwargs): |
|
|
if del_from_section(kwargs): |
|
@ -151,13 +151,13 @@ def _api_del_config(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue(name, output, kwargs): |
|
|
def _api_queue(name, output, kwargs): |
|
|
""" API: Dispatcher for mode=queue """ |
|
|
"""API: Dispatcher for mode=queue""" |
|
|
value = kwargs.get("value", "") |
|
|
value = kwargs.get("value", "") |
|
|
return _api_queue_table.get(name, (_api_queue_default, 2))[0](output, value, kwargs) |
|
|
return _api_queue_table.get(name, (_api_queue_default, 2))[0](output, value, kwargs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_delete(output, value, kwargs): |
|
|
def _api_queue_delete(output, value, kwargs): |
|
|
""" API: accepts output, value """ |
|
|
"""API: accepts output, value""" |
|
|
if value.lower() == "all": |
|
|
if value.lower() == "all": |
|
|
removed = sabnzbd.NzbQueue.remove_all(kwargs.get("search")) |
|
|
removed = sabnzbd.NzbQueue.remove_all(kwargs.get("search")) |
|
|
return report(output, keyword="", data={"status": bool(removed), "nzo_ids": removed}) |
|
|
return report(output, keyword="", data={"status": bool(removed), "nzo_ids": removed}) |
|
@ -171,7 +171,7 @@ def _api_queue_delete(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_delete_nzf(output, value, kwargs): |
|
|
def _api_queue_delete_nzf(output, value, kwargs): |
|
|
""" API: accepts value(=nzo_id), value2(=nzf_id) """ |
|
|
"""API: accepts value(=nzo_id), value2(=nzf_id)""" |
|
|
value2 = kwargs.get("value2") |
|
|
value2 = kwargs.get("value2") |
|
|
if value and value2: |
|
|
if value and value2: |
|
|
removed = sabnzbd.NzbQueue.remove_nzf(value, value2, force_delete=True) |
|
|
removed = sabnzbd.NzbQueue.remove_nzf(value, value2, force_delete=True) |
|
@ -181,7 +181,7 @@ def _api_queue_delete_nzf(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_rename(output, value, kwargs): |
|
|
def _api_queue_rename(output, value, kwargs): |
|
|
""" API: accepts output, value(=old name), value2(=new name), value3(=password) """ |
|
|
"""API: accepts output, value(=old name), value2(=new name), value3(=password)""" |
|
|
value2 = kwargs.get("value2") |
|
|
value2 = kwargs.get("value2") |
|
|
value3 = kwargs.get("value3") |
|
|
value3 = kwargs.get("value3") |
|
|
if value and value2: |
|
|
if value and value2: |
|
@ -192,19 +192,19 @@ def _api_queue_rename(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_change_complete_action(output, value, kwargs): |
|
|
def _api_queue_change_complete_action(output, value, kwargs): |
|
|
""" API: accepts output, value(=action) """ |
|
|
"""API: accepts output, value(=action)""" |
|
|
sabnzbd.change_queue_complete_action(value) |
|
|
sabnzbd.change_queue_complete_action(value) |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_purge(output, value, kwargs): |
|
|
def _api_queue_purge(output, value, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
removed = sabnzbd.NzbQueue.remove_all(kwargs.get("search")) |
|
|
removed = sabnzbd.NzbQueue.remove_all(kwargs.get("search")) |
|
|
return report(output, keyword="", data={"status": bool(removed), "nzo_ids": removed}) |
|
|
return report(output, keyword="", data={"status": bool(removed), "nzo_ids": removed}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_pause(output, value, kwargs): |
|
|
def _api_queue_pause(output, value, kwargs): |
|
|
""" API: accepts output, value(=list of nzo_id) """ |
|
|
"""API: accepts output, value(=list of nzo_id)""" |
|
|
if value: |
|
|
if value: |
|
|
items = value.split(",") |
|
|
items = value.split(",") |
|
|
handled = sabnzbd.NzbQueue.pause_multiple_nzo(items) |
|
|
handled = sabnzbd.NzbQueue.pause_multiple_nzo(items) |
|
@ -214,7 +214,7 @@ def _api_queue_pause(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_resume(output, value, kwargs): |
|
|
def _api_queue_resume(output, value, kwargs): |
|
|
""" API: accepts output, value(=list of nzo_id) """ |
|
|
"""API: accepts output, value(=list of nzo_id)""" |
|
|
if value: |
|
|
if value: |
|
|
items = value.split(",") |
|
|
items = value.split(",") |
|
|
handled = sabnzbd.NzbQueue.resume_multiple_nzo(items) |
|
|
handled = sabnzbd.NzbQueue.resume_multiple_nzo(items) |
|
@ -224,7 +224,7 @@ def _api_queue_resume(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_priority(output, value, kwargs): |
|
|
def _api_queue_priority(output, value, kwargs): |
|
|
""" API: accepts output, value(=nzo_id), value2(=priority) """ |
|
|
"""API: accepts output, value(=nzo_id), value2(=priority)""" |
|
|
value2 = kwargs.get("value2") |
|
|
value2 = kwargs.get("value2") |
|
|
if value and value2: |
|
|
if value and value2: |
|
|
try: |
|
|
try: |
|
@ -242,7 +242,7 @@ def _api_queue_priority(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_sort(output, value, kwargs): |
|
|
def _api_queue_sort(output, value, kwargs): |
|
|
""" API: accepts output, sort, dir """ |
|
|
"""API: accepts output, sort, dir""" |
|
|
sort = kwargs.get("sort") |
|
|
sort = kwargs.get("sort") |
|
|
direction = kwargs.get("dir", "") |
|
|
direction = kwargs.get("dir", "") |
|
|
if sort: |
|
|
if sort: |
|
@ -253,7 +253,7 @@ def _api_queue_sort(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_default(output, value, kwargs): |
|
|
def _api_queue_default(output, value, kwargs): |
|
|
""" API: accepts output, sort, dir, start, limit """ |
|
|
"""API: accepts output, sort, dir, start, limit""" |
|
|
start = int_conv(kwargs.get("start")) |
|
|
start = int_conv(kwargs.get("start")) |
|
|
limit = int_conv(kwargs.get("limit")) |
|
|
limit = int_conv(kwargs.get("limit")) |
|
|
search = kwargs.get("search") |
|
|
search = kwargs.get("search") |
|
@ -264,7 +264,7 @@ def _api_queue_default(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_queue_rating(output, value, kwargs): |
|
|
def _api_queue_rating(output, value, kwargs): |
|
|
""" API: accepts output, value(=nzo_id), type, setting, detail """ |
|
|
"""API: accepts output, value(=nzo_id), type, setting, detail""" |
|
|
vote_map = {"up": sabnzbd.Rating.VOTE_UP, "down": sabnzbd.Rating.VOTE_DOWN} |
|
|
vote_map = {"up": sabnzbd.Rating.VOTE_UP, "down": sabnzbd.Rating.VOTE_DOWN} |
|
|
flag_map = { |
|
|
flag_map = { |
|
|
"spam": sabnzbd.Rating.FLAG_SPAM, |
|
|
"spam": sabnzbd.Rating.FLAG_SPAM, |
|
@ -296,17 +296,17 @@ def _api_queue_rating(output, value, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_options(name, output, kwargs): |
|
|
def _api_options(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
return options_list(output) |
|
|
return options_list(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_translate(name, output, kwargs): |
|
|
def _api_translate(name, output, kwargs): |
|
|
""" API: accepts output, value(=acronym) """ |
|
|
"""API: accepts output, value(=acronym)""" |
|
|
return report(output, keyword="value", data=T(kwargs.get("value", ""))) |
|
|
return report(output, keyword="value", data=T(kwargs.get("value", ""))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_addfile(name, output, kwargs): |
|
|
def _api_addfile(name, output, kwargs): |
|
|
""" API: accepts name, output, pp, script, cat, priority, nzbname """ |
|
|
"""API: accepts name, output, pp, script, cat, priority, nzbname""" |
|
|
# Normal upload will send the nzb in a kw arg called name or nzbfile |
|
|
# Normal upload will send the nzb in a kw arg called name or nzbfile |
|
|
if not name or isinstance(name, str): |
|
|
if not name or isinstance(name, str): |
|
|
name = kwargs.get("nzbfile", None) |
|
|
name = kwargs.get("nzbfile", None) |
|
@ -332,7 +332,7 @@ def _api_addfile(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_retry(name, output, kwargs): |
|
|
def _api_retry(name, output, kwargs): |
|
|
""" API: accepts name, output, value(=nzo_id), nzbfile(=optional NZB), password (optional) """ |
|
|
"""API: accepts name, output, value(=nzo_id), nzbfile(=optional NZB), password (optional)""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
# Normal upload will send the nzb in a kw arg called nzbfile |
|
|
# Normal upload will send the nzb in a kw arg called nzbfile |
|
|
if name is None or isinstance(name, str): |
|
|
if name is None or isinstance(name, str): |
|
@ -348,7 +348,7 @@ def _api_retry(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_cancel_pp(name, output, kwargs): |
|
|
def _api_cancel_pp(name, output, kwargs): |
|
|
""" API: accepts name, output, value(=nzo_id) """ |
|
|
"""API: accepts name, output, value(=nzo_id)""" |
|
|
nzo_id = kwargs.get("value") |
|
|
nzo_id = kwargs.get("value") |
|
|
if sabnzbd.PostProcessor.cancel_pp(nzo_id): |
|
|
if sabnzbd.PostProcessor.cancel_pp(nzo_id): |
|
|
return report(output, keyword="", data={"status": True, "nzo_id": nzo_id}) |
|
|
return report(output, keyword="", data={"status": True, "nzo_id": nzo_id}) |
|
@ -357,7 +357,7 @@ def _api_cancel_pp(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_addlocalfile(name, output, kwargs): |
|
|
def _api_addlocalfile(name, output, kwargs): |
|
|
""" API: accepts name, output, pp, script, cat, priority, nzbname """ |
|
|
"""API: accepts name, output, pp, script, cat, priority, nzbname""" |
|
|
if name: |
|
|
if name: |
|
|
if os.path.exists(name): |
|
|
if os.path.exists(name): |
|
|
pp = kwargs.get("pp") |
|
|
pp = kwargs.get("pp") |
|
@ -395,7 +395,7 @@ def _api_addlocalfile(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_switch(name, output, kwargs): |
|
|
def _api_switch(name, output, kwargs): |
|
|
""" API: accepts output, value(=first id), value2(=second id) """ |
|
|
"""API: accepts output, value(=first id), value2(=second id)""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
value2 = kwargs.get("value2") |
|
|
value2 = kwargs.get("value2") |
|
|
if value and value2: |
|
|
if value and value2: |
|
@ -407,7 +407,7 @@ def _api_switch(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_change_cat(name, output, kwargs): |
|
|
def _api_change_cat(name, output, kwargs): |
|
|
""" API: accepts output, value(=nzo_id), value2(=category) """ |
|
|
"""API: accepts output, value(=nzo_id), value2(=category)""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
value2 = kwargs.get("value2") |
|
|
value2 = kwargs.get("value2") |
|
|
if value and value2: |
|
|
if value and value2: |
|
@ -422,7 +422,7 @@ def _api_change_cat(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_change_script(name, output, kwargs): |
|
|
def _api_change_script(name, output, kwargs): |
|
|
""" API: accepts output, value(=nzo_id), value2(=script) """ |
|
|
"""API: accepts output, value(=nzo_id), value2(=script)""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
value2 = kwargs.get("value2") |
|
|
value2 = kwargs.get("value2") |
|
|
if value and value2: |
|
|
if value and value2: |
|
@ -437,7 +437,7 @@ def _api_change_script(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_change_opts(name, output, kwargs): |
|
|
def _api_change_opts(name, output, kwargs): |
|
|
""" API: accepts output, value(=nzo_id), value2(=pp) """ |
|
|
"""API: accepts output, value(=nzo_id), value2(=pp)""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
value2 = kwargs.get("value2") |
|
|
value2 = kwargs.get("value2") |
|
|
result = 0 |
|
|
result = 0 |
|
@ -447,13 +447,13 @@ def _api_change_opts(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_fullstatus(name, output, kwargs): |
|
|
def _api_fullstatus(name, output, kwargs): |
|
|
""" API: full history status""" |
|
|
"""API: full history status""" |
|
|
status = build_status(skip_dashboard=kwargs.get("skip_dashboard", 1), output=output) |
|
|
status = build_status(skip_dashboard=kwargs.get("skip_dashboard", 1), output=output) |
|
|
return report(output, keyword="status", data=status) |
|
|
return report(output, keyword="status", data=status) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_history(name, output, kwargs): |
|
|
def _api_history(name, output, kwargs): |
|
|
""" API: accepts output, value(=nzo_id), start, limit, search, nzo_ids """ |
|
|
"""API: accepts output, value(=nzo_id), start, limit, search, nzo_ids""" |
|
|
value = kwargs.get("value", "") |
|
|
value = kwargs.get("value", "") |
|
|
start = int_conv(kwargs.get("start")) |
|
|
start = int_conv(kwargs.get("start")) |
|
|
limit = int_conv(kwargs.get("limit")) |
|
|
limit = int_conv(kwargs.get("limit")) |
|
@ -517,7 +517,7 @@ def _api_history(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_get_files(name, output, kwargs): |
|
|
def _api_get_files(name, output, kwargs): |
|
|
""" API: accepts output, value(=nzo_id) """ |
|
|
"""API: accepts output, value(=nzo_id)""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
if value: |
|
|
if value: |
|
|
return report(output, keyword="files", data=build_file_list(value)) |
|
|
return report(output, keyword="files", data=build_file_list(value)) |
|
@ -526,7 +526,7 @@ def _api_get_files(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_addurl(name, output, kwargs): |
|
|
def _api_addurl(name, output, kwargs): |
|
|
""" API: accepts name, output, pp, script, cat, priority, nzbname """ |
|
|
"""API: accepts name, output, pp, script, cat, priority, nzbname""" |
|
|
pp = kwargs.get("pp") |
|
|
pp = kwargs.get("pp") |
|
|
script = kwargs.get("script") |
|
|
script = kwargs.get("script") |
|
|
cat = kwargs.get("cat") |
|
|
cat = kwargs.get("cat") |
|
@ -544,27 +544,27 @@ def _api_addurl(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_pause(name, output, kwargs): |
|
|
def _api_pause(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sabnzbd.Scheduler.plan_resume(0) |
|
|
sabnzbd.Scheduler.plan_resume(0) |
|
|
sabnzbd.Downloader.pause() |
|
|
sabnzbd.Downloader.pause() |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_resume(name, output, kwargs): |
|
|
def _api_resume(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sabnzbd.Scheduler.plan_resume(0) |
|
|
sabnzbd.Scheduler.plan_resume(0) |
|
|
sabnzbd.unpause_all() |
|
|
sabnzbd.unpause_all() |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_shutdown(name, output, kwargs): |
|
|
def _api_shutdown(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sabnzbd.shutdown_program() |
|
|
sabnzbd.shutdown_program() |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_warnings(name, output, kwargs): |
|
|
def _api_warnings(name, output, kwargs): |
|
|
""" API: accepts name, output """ |
|
|
"""API: accepts name, output""" |
|
|
if name == "clear": |
|
|
if name == "clear": |
|
|
return report(output, keyword="warnings", data=sabnzbd.GUIHANDLER.clear()) |
|
|
return report(output, keyword="warnings", data=sabnzbd.GUIHANDLER.clear()) |
|
|
elif name == "show": |
|
|
elif name == "show": |
|
@ -575,22 +575,22 @@ def _api_warnings(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_get_cats(name, output, kwargs): |
|
|
def _api_get_cats(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
return report(output, keyword="categories", data=list_cats(False)) |
|
|
return report(output, keyword="categories", data=list_cats(False)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_get_scripts(name, output, kwargs): |
|
|
def _api_get_scripts(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
return report(output, keyword="scripts", data=list_scripts()) |
|
|
return report(output, keyword="scripts", data=list_scripts()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_version(name, output, kwargs): |
|
|
def _api_version(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
return report(output, keyword="version", data=sabnzbd.__version__) |
|
|
return report(output, keyword="version", data=sabnzbd.__version__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_auth(name, output, kwargs): |
|
|
def _api_auth(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
auth = "None" |
|
|
auth = "None" |
|
|
if not cfg.disable_key(): |
|
|
if not cfg.disable_key(): |
|
|
auth = "badkey" |
|
|
auth = "badkey" |
|
@ -608,7 +608,7 @@ def _api_auth(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_restart(name, output, kwargs): |
|
|
def _api_restart(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
logging.info("Restart requested by API") |
|
|
logging.info("Restart requested by API") |
|
|
# Do the shutdown async to still send goodbye to browser |
|
|
# Do the shutdown async to still send goodbye to browser |
|
|
Thread(target=sabnzbd.trigger_restart, kwargs={"timeout": 1}).start() |
|
|
Thread(target=sabnzbd.trigger_restart, kwargs={"timeout": 1}).start() |
|
@ -616,7 +616,7 @@ def _api_restart(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_restart_repair(name, output, kwargs): |
|
|
def _api_restart_repair(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
logging.info("Queue repair requested by API") |
|
|
logging.info("Queue repair requested by API") |
|
|
sabnzbd.request_repair() |
|
|
sabnzbd.request_repair() |
|
|
# Do the shutdown async to still send goodbye to browser |
|
|
# Do the shutdown async to still send goodbye to browser |
|
@ -625,26 +625,26 @@ def _api_restart_repair(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_disconnect(name, output, kwargs): |
|
|
def _api_disconnect(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sabnzbd.Downloader.disconnect() |
|
|
sabnzbd.Downloader.disconnect() |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_osx_icon(name, output, kwargs): |
|
|
def _api_osx_icon(name, output, kwargs): |
|
|
""" API: accepts output, value """ |
|
|
"""API: accepts output, value""" |
|
|
value = kwargs.get("value", "1").strip() |
|
|
value = kwargs.get("value", "1").strip() |
|
|
cfg.osx_menu.set(value != "0") |
|
|
cfg.osx_menu.set(value != "0") |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_rescan(name, output, kwargs): |
|
|
def _api_rescan(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sabnzbd.NzbQueue.scan_jobs(all_jobs=False, action=True) |
|
|
sabnzbd.NzbQueue.scan_jobs(all_jobs=False, action=True) |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_eval_sort(name, output, kwargs): |
|
|
def _api_eval_sort(name, output, kwargs): |
|
|
""" API: evaluate sorting expression """ |
|
|
"""API: evaluate sorting expression""" |
|
|
name = kwargs.get("name", "") |
|
|
name = kwargs.get("name", "") |
|
|
value = kwargs.get("value", "") |
|
|
value = kwargs.get("value", "") |
|
|
title = kwargs.get("title") |
|
|
title = kwargs.get("title") |
|
@ -657,43 +657,43 @@ def _api_eval_sort(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_watched_now(name, output, kwargs): |
|
|
def _api_watched_now(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sabnzbd.DirScanner.scan() |
|
|
sabnzbd.DirScanner.scan() |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_resume_pp(name, output, kwargs): |
|
|
def _api_resume_pp(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sabnzbd.PostProcessor.paused = False |
|
|
sabnzbd.PostProcessor.paused = False |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_pause_pp(name, output, kwargs): |
|
|
def _api_pause_pp(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sabnzbd.PostProcessor.paused = True |
|
|
sabnzbd.PostProcessor.paused = True |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_rss_now(name, output, kwargs): |
|
|
def _api_rss_now(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
# Run RSS scan async, because it can take a long time |
|
|
# Run RSS scan async, because it can take a long time |
|
|
sabnzbd.Scheduler.force_rss() |
|
|
sabnzbd.Scheduler.force_rss() |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_retry_all(name, output, kwargs): |
|
|
def _api_retry_all(name, output, kwargs): |
|
|
""" API: Retry all failed items in History """ |
|
|
"""API: Retry all failed items in History""" |
|
|
return report(output, keyword="status", data=retry_all_jobs()) |
|
|
return report(output, keyword="status", data=retry_all_jobs()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_reset_quota(name, output, kwargs): |
|
|
def _api_reset_quota(name, output, kwargs): |
|
|
""" Reset quota left """ |
|
|
"""Reset quota left""" |
|
|
sabnzbd.BPSMeter.reset_quota(force=True) |
|
|
sabnzbd.BPSMeter.reset_quota(force=True) |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_test_email(name, output, kwargs): |
|
|
def _api_test_email(name, output, kwargs): |
|
|
""" API: send a test email, return result """ |
|
|
"""API: send a test email, return result""" |
|
|
logging.info("Sending test email") |
|
|
logging.info("Sending test email") |
|
|
pack = {"download": ["action 1", "action 2"], "unpack": ["action 1", "action 2"]} |
|
|
pack = {"download": ["action 1", "action 2"], "unpack": ["action 1", "action 2"]} |
|
|
res = sabnzbd.emailer.endjob( |
|
|
res = sabnzbd.emailer.endjob( |
|
@ -715,61 +715,61 @@ def _api_test_email(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_test_windows(name, output, kwargs): |
|
|
def _api_test_windows(name, output, kwargs): |
|
|
""" API: send a test to Windows, return result """ |
|
|
"""API: send a test to Windows, return result""" |
|
|
logging.info("Sending test notification") |
|
|
logging.info("Sending test notification") |
|
|
res = sabnzbd.notifier.send_windows("SABnzbd", T("Test Notification"), "other") |
|
|
res = sabnzbd.notifier.send_windows("SABnzbd", T("Test Notification"), "other") |
|
|
return report(output, error=res) |
|
|
return report(output, error=res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_test_notif(name, output, kwargs): |
|
|
def _api_test_notif(name, output, kwargs): |
|
|
""" API: send a test to Notification Center, return result """ |
|
|
"""API: send a test to Notification Center, return result""" |
|
|
logging.info("Sending test notification") |
|
|
logging.info("Sending test notification") |
|
|
res = sabnzbd.notifier.send_notification_center("SABnzbd", T("Test Notification"), "other") |
|
|
res = sabnzbd.notifier.send_notification_center("SABnzbd", T("Test Notification"), "other") |
|
|
return report(output, error=res) |
|
|
return report(output, error=res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_test_osd(name, output, kwargs): |
|
|
def _api_test_osd(name, output, kwargs): |
|
|
""" API: send a test OSD notification, return result """ |
|
|
"""API: send a test OSD notification, return result""" |
|
|
logging.info("Sending OSD notification") |
|
|
logging.info("Sending OSD notification") |
|
|
res = sabnzbd.notifier.send_notify_osd("SABnzbd", T("Test Notification")) |
|
|
res = sabnzbd.notifier.send_notify_osd("SABnzbd", T("Test Notification")) |
|
|
return report(output, error=res) |
|
|
return report(output, error=res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_test_prowl(name, output, kwargs): |
|
|
def _api_test_prowl(name, output, kwargs): |
|
|
""" API: send a test Prowl notification, return result """ |
|
|
"""API: send a test Prowl notification, return result""" |
|
|
logging.info("Sending Prowl notification") |
|
|
logging.info("Sending Prowl notification") |
|
|
res = sabnzbd.notifier.send_prowl("SABnzbd", T("Test Notification"), "other", force=True, test=kwargs) |
|
|
res = sabnzbd.notifier.send_prowl("SABnzbd", T("Test Notification"), "other", force=True, test=kwargs) |
|
|
return report(output, error=res) |
|
|
return report(output, error=res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_test_pushover(name, output, kwargs): |
|
|
def _api_test_pushover(name, output, kwargs): |
|
|
""" API: send a test Pushover notification, return result """ |
|
|
"""API: send a test Pushover notification, return result""" |
|
|
logging.info("Sending Pushover notification") |
|
|
logging.info("Sending Pushover notification") |
|
|
res = sabnzbd.notifier.send_pushover("SABnzbd", T("Test Notification"), "other", force=True, test=kwargs) |
|
|
res = sabnzbd.notifier.send_pushover("SABnzbd", T("Test Notification"), "other", force=True, test=kwargs) |
|
|
return report(output, error=res) |
|
|
return report(output, error=res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_test_pushbullet(name, output, kwargs): |
|
|
def _api_test_pushbullet(name, output, kwargs): |
|
|
""" API: send a test Pushbullet notification, return result """ |
|
|
"""API: send a test Pushbullet notification, return result""" |
|
|
logging.info("Sending Pushbullet notification") |
|
|
logging.info("Sending Pushbullet notification") |
|
|
res = sabnzbd.notifier.send_pushbullet("SABnzbd", T("Test Notification"), "other", force=True, test=kwargs) |
|
|
res = sabnzbd.notifier.send_pushbullet("SABnzbd", T("Test Notification"), "other", force=True, test=kwargs) |
|
|
return report(output, error=res) |
|
|
return report(output, error=res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_test_nscript(name, output, kwargs): |
|
|
def _api_test_nscript(name, output, kwargs): |
|
|
""" API: execute a test notification script, return result """ |
|
|
"""API: execute a test notification script, return result""" |
|
|
logging.info("Executing notification script") |
|
|
logging.info("Executing notification script") |
|
|
res = sabnzbd.notifier.send_nscript("SABnzbd", T("Test Notification"), "other", force=True, test=kwargs) |
|
|
res = sabnzbd.notifier.send_nscript("SABnzbd", T("Test Notification"), "other", force=True, test=kwargs) |
|
|
return report(output, error=res) |
|
|
return report(output, error=res) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_undefined(name, output, kwargs): |
|
|
def _api_undefined(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
return report(output, _MSG_NOT_IMPLEMENTED) |
|
|
return report(output, _MSG_NOT_IMPLEMENTED) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_browse(name, output, kwargs): |
|
|
def _api_browse(name, output, kwargs): |
|
|
""" Return tree of local path """ |
|
|
"""Return tree of local path""" |
|
|
compact = kwargs.get("compact") |
|
|
compact = kwargs.get("compact") |
|
|
|
|
|
|
|
|
if compact and compact == "1": |
|
|
if compact and compact == "1": |
|
@ -783,14 +783,14 @@ def _api_browse(name, output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config(name, output, kwargs): |
|
|
def _api_config(name, output, kwargs): |
|
|
""" API: Dispatcher for "config" """ |
|
|
"""API: Dispatcher for "config" """ |
|
|
if cfg.configlock(): |
|
|
if cfg.configlock(): |
|
|
return report(output, _MSG_CONFIG_LOCKED) |
|
|
return report(output, _MSG_CONFIG_LOCKED) |
|
|
return _api_config_table.get(name, (_api_config_undefined, 2))[0](output, kwargs) |
|
|
return _api_config_table.get(name, (_api_config_undefined, 2))[0](output, kwargs) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config_speedlimit(output, kwargs): |
|
|
def _api_config_speedlimit(output, kwargs): |
|
|
""" API: accepts output, value(=speed) """ |
|
|
"""API: accepts output, value(=speed)""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
if not value: |
|
|
if not value: |
|
|
value = "0" |
|
|
value = "0" |
|
@ -799,12 +799,12 @@ def _api_config_speedlimit(output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config_get_speedlimit(output, kwargs): |
|
|
def _api_config_get_speedlimit(output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
return report(output, keyword="speedlimit", data=sabnzbd.Downloader.get_limit()) |
|
|
return report(output, keyword="speedlimit", data=sabnzbd.Downloader.get_limit()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config_set_colorscheme(output, kwargs): |
|
|
def _api_config_set_colorscheme(output, kwargs): |
|
|
""" API: accepts output""" |
|
|
"""API: accepts output""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
if value: |
|
|
if value: |
|
|
cfg.web_color.set(value) |
|
|
cfg.web_color.set(value) |
|
@ -814,21 +814,21 @@ def _api_config_set_colorscheme(output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config_set_pause(output, kwargs): |
|
|
def _api_config_set_pause(output, kwargs): |
|
|
""" API: accepts output, value(=pause interval) """ |
|
|
"""API: accepts output, value(=pause interval)""" |
|
|
value = kwargs.get("value") |
|
|
value = kwargs.get("value") |
|
|
sabnzbd.Scheduler.plan_resume(int_conv(value)) |
|
|
sabnzbd.Scheduler.plan_resume(int_conv(value)) |
|
|
return report(output) |
|
|
return report(output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config_set_apikey(output, kwargs): |
|
|
def _api_config_set_apikey(output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
cfg.api_key.set(config.create_api_key()) |
|
|
cfg.api_key.set(config.create_api_key()) |
|
|
config.save_config() |
|
|
config.save_config() |
|
|
return report(output, keyword="apikey", data=cfg.api_key()) |
|
|
return report(output, keyword="apikey", data=cfg.api_key()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config_set_nzbkey(output, kwargs): |
|
|
def _api_config_set_nzbkey(output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
cfg.nzb_key.set(config.create_api_key()) |
|
|
cfg.nzb_key.set(config.create_api_key()) |
|
|
config.save_config() |
|
|
config.save_config() |
|
|
return report(output, keyword="nzbkey", data=cfg.nzb_key()) |
|
|
return report(output, keyword="nzbkey", data=cfg.nzb_key()) |
|
@ -849,7 +849,7 @@ def _api_config_regenerate_certs(output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config_test_server(output, kwargs): |
|
|
def _api_config_test_server(output, kwargs): |
|
|
""" API: accepts output, server-params """ |
|
|
"""API: accepts output, server-params""" |
|
|
result, msg = test_nntp_server_dict(kwargs) |
|
|
result, msg = test_nntp_server_dict(kwargs) |
|
|
response = {"result": result, "message": msg} |
|
|
response = {"result": result, "message": msg} |
|
|
if output: |
|
|
if output: |
|
@ -859,12 +859,12 @@ def _api_config_test_server(output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_config_undefined(output, kwargs): |
|
|
def _api_config_undefined(output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
return report(output, _MSG_NOT_IMPLEMENTED) |
|
|
return report(output, _MSG_NOT_IMPLEMENTED) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _api_server_stats(name, output, kwargs): |
|
|
def _api_server_stats(name, output, kwargs): |
|
|
""" API: accepts output """ |
|
|
"""API: accepts output""" |
|
|
sum_t, sum_m, sum_w, sum_d = sabnzbd.BPSMeter.get_sums() |
|
|
sum_t, sum_m, sum_w, sum_d = sabnzbd.BPSMeter.get_sums() |
|
|
stats = {"total": sum_t, "month": sum_m, "week": sum_w, "day": sum_d, "servers": {}} |
|
|
stats = {"total": sum_t, "month": sum_m, "week": sum_w, "day": sum_d, "servers": {}} |
|
|
|
|
|
|
|
@ -974,7 +974,7 @@ _api_config_table = { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def api_level(mode: str, name: str) -> int: |
|
|
def api_level(mode: str, name: str) -> int: |
|
|
""" Return access level required for this API call """ |
|
|
"""Return access level required for this API call""" |
|
|
if mode == "queue" and name in _api_queue_table: |
|
|
if mode == "queue" and name in _api_queue_table: |
|
|
return _api_queue_table[name][1] |
|
|
return _api_queue_table[name][1] |
|
|
if mode == "config" and name in _api_config_table: |
|
|
if mode == "config" and name in _api_config_table: |
|
@ -1091,7 +1091,7 @@ class xml_factory: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_server_api(output, kwargs): |
|
|
def handle_server_api(output, kwargs): |
|
|
""" Special handler for API-call 'set_config' [servers] """ |
|
|
"""Special handler for API-call 'set_config' [servers]""" |
|
|
name = kwargs.get("keyword") |
|
|
name = kwargs.get("keyword") |
|
|
if not name: |
|
|
if not name: |
|
|
name = kwargs.get("name") |
|
|
name = kwargs.get("name") |
|
@ -1109,7 +1109,7 @@ def handle_server_api(output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_rss_api(output, kwargs): |
|
|
def handle_rss_api(output, kwargs): |
|
|
""" Special handler for API-call 'set_config' [rss] """ |
|
|
"""Special handler for API-call 'set_config' [rss]""" |
|
|
name = kwargs.get("keyword") |
|
|
name = kwargs.get("keyword") |
|
|
if not name: |
|
|
if not name: |
|
|
name = kwargs.get("name") |
|
|
name = kwargs.get("name") |
|
@ -1143,7 +1143,7 @@ def handle_rss_api(output, kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_cat_api(output, kwargs): |
|
|
def handle_cat_api(output, kwargs): |
|
|
""" Special handler for API-call 'set_config' [categories] """ |
|
|
"""Special handler for API-call 'set_config' [categories]""" |
|
|
name = kwargs.get("keyword") |
|
|
name = kwargs.get("keyword") |
|
|
if not name: |
|
|
if not name: |
|
|
name = kwargs.get("name") |
|
|
name = kwargs.get("name") |
|
@ -1387,7 +1387,7 @@ def build_queue(start=0, limit=0, trans=False, output=None, search=None, nzo_ids |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def fast_queue() -> Tuple[bool, int, float, str]: |
|
|
def fast_queue() -> Tuple[bool, int, float, str]: |
|
|
""" Return paused, bytes_left, bpsnow, time_left """ |
|
|
"""Return paused, bytes_left, bpsnow, time_left""" |
|
|
bytes_left = sabnzbd.sabnzbd.NzbQueue.remaining() |
|
|
bytes_left = sabnzbd.sabnzbd.NzbQueue.remaining() |
|
|
paused = sabnzbd.Downloader.paused |
|
|
paused = sabnzbd.Downloader.paused |
|
|
bpsnow = sabnzbd.BPSMeter.bps |
|
|
bpsnow = sabnzbd.BPSMeter.bps |
|
@ -1467,7 +1467,7 @@ def options_list(output): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def retry_job(job, new_nzb=None, password=None): |
|
|
def retry_job(job, new_nzb=None, password=None): |
|
|
""" Re enter failed job in the download queue """ |
|
|
"""Re enter failed job in the download queue""" |
|
|
if job: |
|
|
if job: |
|
|
history_db = sabnzbd.get_db_connection() |
|
|
history_db = sabnzbd.get_db_connection() |
|
|
futuretype, url, pp, script, cat = history_db.get_other(job) |
|
|
futuretype, url, pp, script, cat = history_db.get_other(job) |
|
@ -1484,7 +1484,7 @@ def retry_job(job, new_nzb=None, password=None): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def retry_all_jobs(): |
|
|
def retry_all_jobs(): |
|
|
""" Re enter all failed jobs in the download queue """ |
|
|
"""Re enter all failed jobs in the download queue""" |
|
|
# Fetch all retryable folders from History |
|
|
# Fetch all retryable folders from History |
|
|
items = sabnzbd.api.build_history()[0] |
|
|
items = sabnzbd.api.build_history()[0] |
|
|
nzo_ids = [] |
|
|
nzo_ids = [] |
|
@ -1495,14 +1495,14 @@ def retry_all_jobs(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def del_job_files(job_paths): |
|
|
def del_job_files(job_paths): |
|
|
""" Remove files of each path in the list """ |
|
|
"""Remove files of each path in the list""" |
|
|
for path in job_paths: |
|
|
for path in job_paths: |
|
|
if path and clip_path(path).lower().startswith(cfg.download_dir.get_clipped_path().lower()): |
|
|
if path and clip_path(path).lower().startswith(cfg.download_dir.get_clipped_path().lower()): |
|
|
remove_all(path, recursive=True) |
|
|
remove_all(path, recursive=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def del_hist_job(job, del_files): |
|
|
def del_hist_job(job, del_files): |
|
|
""" Remove history element """ |
|
|
"""Remove history element""" |
|
|
if job: |
|
|
if job: |
|
|
path = sabnzbd.PostProcessor.get_path(job) |
|
|
path = sabnzbd.PostProcessor.get_path(job) |
|
|
if path: |
|
|
if path: |
|
@ -1514,7 +1514,7 @@ def del_hist_job(job, del_files): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def Tspec(txt): |
|
|
def Tspec(txt): |
|
|
""" Translate special terms """ |
|
|
"""Translate special terms""" |
|
|
if txt == "None": |
|
|
if txt == "None": |
|
|
return T("None") |
|
|
return T("None") |
|
|
elif txt in ("Default", "*"): |
|
|
elif txt in ("Default", "*"): |
|
@ -1543,14 +1543,14 @@ def Ttemplate(txt): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clear_trans_cache(): |
|
|
def clear_trans_cache(): |
|
|
""" Clean cache for skin translations """ |
|
|
"""Clean cache for skin translations""" |
|
|
global _SKIN_CACHE |
|
|
global _SKIN_CACHE |
|
|
_SKIN_CACHE = {} |
|
|
_SKIN_CACHE = {} |
|
|
sabnzbd.WEBUI_READY = True |
|
|
sabnzbd.WEBUI_READY = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_header(webdir="", output=None, trans_functions=True): |
|
|
def build_header(webdir="", output=None, trans_functions=True): |
|
|
""" Build the basic header """ |
|
|
"""Build the basic header""" |
|
|
try: |
|
|
try: |
|
|
uptime = calc_age(sabnzbd.START) |
|
|
uptime = calc_age(sabnzbd.START) |
|
|
except: |
|
|
except: |
|
@ -1628,7 +1628,7 @@ def build_header(webdir="", output=None, trans_functions=True): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_queue_header(search=None, nzo_ids=None, start=0, limit=0, output=None): |
|
|
def build_queue_header(search=None, nzo_ids=None, start=0, limit=0, output=None): |
|
|
""" Build full queue header """ |
|
|
"""Build full queue header""" |
|
|
|
|
|
|
|
|
header = build_header(output=output) |
|
|
header = build_header(output=output) |
|
|
|
|
|
|
|
@ -1782,7 +1782,7 @@ def build_history( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_active_history(queue, items): |
|
|
def get_active_history(queue, items): |
|
|
""" Get the currently in progress and active history queue. """ |
|
|
"""Get the currently in progress and active history queue.""" |
|
|
for nzo in queue: |
|
|
for nzo in queue: |
|
|
item = {} |
|
|
item = {} |
|
|
( |
|
|
( |
|
@ -1825,7 +1825,7 @@ def get_active_history(queue, items): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def calc_timeleft(bytesleft, bps): |
|
|
def calc_timeleft(bytesleft, bps): |
|
|
""" Calculate the time left in the format HH:MM:SS """ |
|
|
"""Calculate the time left in the format HH:MM:SS""" |
|
|
try: |
|
|
try: |
|
|
if bytesleft <= 0: |
|
|
if bytesleft <= 0: |
|
|
return "0:00:00" |
|
|
return "0:00:00" |
|
@ -1877,7 +1877,7 @@ def plural_to_single(kw, def_kw=""): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def del_from_section(kwargs): |
|
|
def del_from_section(kwargs): |
|
|
""" Remove keyword in section """ |
|
|
"""Remove keyword in section""" |
|
|
section = kwargs.get("section", "") |
|
|
section = kwargs.get("section", "") |
|
|
if section in ("servers", "rss", "categories"): |
|
|
if section in ("servers", "rss", "categories"): |
|
|
keyword = kwargs.get("keyword") |
|
|
keyword = kwargs.get("keyword") |
|
@ -1895,7 +1895,7 @@ def del_from_section(kwargs): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def history_remove_failed(): |
|
|
def history_remove_failed(): |
|
|
""" Remove all failed jobs from history, including files """ |
|
|
"""Remove all failed jobs from history, including files""" |
|
|
logging.info("Scheduled removal of all failed jobs") |
|
|
logging.info("Scheduled removal of all failed jobs") |
|
|
with HistoryDB() as history_db: |
|
|
with HistoryDB() as history_db: |
|
|
del_job_files(history_db.get_failed_paths()) |
|
|
del_job_files(history_db.get_failed_paths()) |
|
@ -1903,7 +1903,7 @@ def history_remove_failed(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def history_remove_completed(): |
|
|
def history_remove_completed(): |
|
|
""" Remove all completed jobs from history """ |
|
|
"""Remove all completed jobs from history""" |
|
|
logging.info("Scheduled removal of all completed jobs") |
|
|
logging.info("Scheduled removal of all completed jobs") |
|
|
with HistoryDB() as history_db: |
|
|
with HistoryDB() as history_db: |
|
|
history_db.remove_completed() |
|
|
history_db.remove_completed() |
|
|