exit if results list is empty (or is cleared during filtering)
This commit is contained in:
parent
32932fe803
commit
0f68ef558e
16
mvw-dl.py
16
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
|
# Exit codes
|
||||||
# 1: Config file invalid, it has no sections
|
# 1: Config file invalid, it has no sections
|
||||||
# 2: Config file invalid, sections must define at least CONST.CFG_MANDATORY
|
# 2: Config file invalid, sections must define at least CONST.CFG_MANDATORY
|
||||||
|
# 3: No search results to download
|
||||||
|
|
||||||
|
|
||||||
class CONST(object):
|
class CONST(object):
|
||||||
@ -204,12 +205,20 @@ def get_json_response(
|
|||||||
return got_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(
|
def remove_result(
|
||||||
json_obj: MVWJSONResponse,
|
json_obj: MVWJSONResponse,
|
||||||
result_obj: type_def.mvw_json_response.Show) -> MVWJSONResponse:
|
result_obj: type_def.mvw_json_response.Show) -> MVWJSONResponse:
|
||||||
json_obj.result.results.remove(result_obj)
|
json_obj.result.results.remove(result_obj)
|
||||||
json_obj.result.queryInfo.resultCount -= 1
|
json_obj.result.queryInfo.resultCount -= 1
|
||||||
|
if json_obj.result.queryInfo.resultCount:
|
||||||
return json_obj
|
return json_obj
|
||||||
|
else:
|
||||||
|
no_downloads_needed()
|
||||||
|
|
||||||
|
|
||||||
def log_result_count(result_count: int, pre_filter: bool = True) -> None:
|
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 ...")
|
log.debug(f"Deduplicating results by title where needed ...")
|
||||||
if config.has_option(section, "title_not_regex"):
|
if config.has_option(section, "title_not_regex"):
|
||||||
json_response = dedup_json_titles(section, config, json_response)
|
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