Prep for logging and safe filenames
This commit is contained in:
parent
296e2ca7e5
commit
25d0059f14
15
mvw-dl.py
15
mvw-dl.py
@ -345,6 +345,19 @@ def handle_sigint(signum, frame):
|
||||
signal.signal(signal.SIGINT, handle_sigint)
|
||||
|
||||
|
||||
def get_safe_filename(
|
||||
dirty_filename: str) -> str:
|
||||
"""https://stackoverflow.com/a/71199182"""
|
||||
|
||||
clean_filename = re.sub(r"[/\\?%*:|\"<>\x7F\x00-\x1F]", "-", dirty_filename)
|
||||
return clean_filename
|
||||
|
||||
|
||||
def log_successful_download(
|
||||
show: type_def.mvw_json_response.Show) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def copy_url(
|
||||
section_name: str,
|
||||
config_obj: configparser.ConfigParser(),
|
||||
@ -365,6 +378,7 @@ def copy_url(
|
||||
dest_path = os.path.expanduser(dest_path)
|
||||
dest_path = os.path.expandvars(dest_path)
|
||||
show_name = f"{show.topic} - {show.title}"
|
||||
publish_date = d.datetime.utcfromtimestamp(show.timestamp).strftime('%Y%m%d')
|
||||
|
||||
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
|
||||
with open(dest_path, "wb") as dest_file:
|
||||
@ -388,6 +402,7 @@ def copy_url(
|
||||
log.info(f"""Download of "{show_name}" interrupted""")
|
||||
return
|
||||
log.info(f"""Download of "{show_name}" done""")
|
||||
log_successful_download(show)
|
||||
|
||||
|
||||
def get_max_quality_url(
|
||||
|
Loading…
x
Reference in New Issue
Block a user