exit if results list is empty (or is cleared during filtering)
This commit is contained in:
parent
32932fe803
commit
0f68ef558e
18
mvw-dl.py
18
mvw-dl.py
@ -29,6 +29,7 @@ JSONType = t.Union[str, int, float, bool, None, t.Dict[str, t.Any], t.List[t.Any
|
||||
# Exit codes
|
||||
# 1: Config file invalid, it has no sections
|
||||
# 2: Config file invalid, sections must define at least CONST.CFG_MANDATORY
|
||||
# 3: No search results to download
|
||||
|
||||
|
||||
class CONST(object):
|
||||
@ -204,12 +205,20 @@ def get_json_response(
|
||||
return got_json_response
|
||||
|
||||
|
||||
def no_downloads_needed() -> None:
|
||||
log.info(f"No search results to download, exiting 3 ...")
|
||||
sys.exit(3)
|
||||
|
||||
|
||||
def remove_result(
|
||||
json_obj: MVWJSONResponse,
|
||||
result_obj: type_def.mvw_json_response.Show) -> MVWJSONResponse:
|
||||
json_obj.result.results.remove(result_obj)
|
||||
json_obj.result.queryInfo.resultCount -= 1
|
||||
return json_obj
|
||||
if json_obj.result.queryInfo.resultCount:
|
||||
return json_obj
|
||||
else:
|
||||
no_downloads_needed()
|
||||
|
||||
|
||||
def log_result_count(result_count: int, pre_filter: bool = True) -> None:
|
||||
@ -309,4 +318,9 @@ if __name__ == '__main__':
|
||||
log.debug(f"Deduplicating results by title where needed ...")
|
||||
if config.has_option(section, "title_not_regex"):
|
||||
json_response = dedup_json_titles(section, config, json_response)
|
||||
# console.print_json(json_response.json())
|
||||
|
||||
#if json_response.result.queryInfo.resultCount:
|
||||
# log.debug(f"Downloading shows ...")
|
||||
#else
|
||||
#
|
||||
# # console.print_json(json_response.json())
|
||||
|
Loading…
x
Reference in New Issue
Block a user