Check if file was previously downloaded

This commit is contained in:
hygienic-books 2022-03-19 16:58:27 +01:00
parent dd6464de5d
commit d0552f9e67

View File

@ -639,6 +639,24 @@ def get_content_length(
return 0 return 0
def is_already_downloaded(
show: type_def.mvw_json_response.Show,
state_file_abs_path: str,
show_name: str) -> bool:
with open(state_file_abs_path, "r") as state_file:
try:
json_state = json.load(state_file)
for log_entry in json_state:
for log_data in [key for key in log_entry]:
if show.topic == log_entry[log_data]["topic"] and show.title == log_entry[log_data]["title"]:
log.debug(f"""Show "{show_name}" already downloaded, won't queue""")
return True
except json.JSONDecodeError:
return False
return False
def download_media( def download_media(
section_name: str, section_name: str,
config_obj: configparser.ConfigParser(), config_obj: configparser.ConfigParser(),