temporary files are now properly deleted on exit. fixes #2.
This commit is contained in:
parent
0543e295ff
commit
e4283ee3b7
19
coub-dl.py
19
coub-dl.py
@ -7,6 +7,7 @@ from datetime import timedelta
|
||||
from math import floor
|
||||
from argparse import ArgumentParser
|
||||
from functools import wraps
|
||||
from atexit import register
|
||||
|
||||
|
||||
|
||||
@ -95,6 +96,15 @@ def mux_streams():
|
||||
stdout=DEVNULL, stderr=DEVNULL)
|
||||
|
||||
|
||||
def cleanup():
|
||||
try:
|
||||
for key in FILES:
|
||||
if key not in OUTPUT_KEYS:
|
||||
remove(FILES[key])
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
def yes_no_question(question, default):
|
||||
valid = {"yes": True, "y": True, "ye": True,
|
||||
"no": False, "n": False}
|
||||
@ -119,6 +129,10 @@ def yes_no_question(question, default):
|
||||
|
||||
|
||||
|
||||
# clean up on exit
|
||||
register(cleanup)
|
||||
|
||||
|
||||
# parse arguments
|
||||
parser = ArgumentParser(description='Download player-looped videos with youtube-dl & ffmpeg.')
|
||||
parser.add_argument('-nv', '--nonverbose', action='store_true', help='Turn off non-critical messages to user.')
|
||||
@ -185,8 +199,3 @@ with open(FILES[File.LIST], 'w') as f:
|
||||
|
||||
loop_shorter_stream()
|
||||
mux_streams()
|
||||
|
||||
# cleanup
|
||||
for key in FILES:
|
||||
if key not in OUTPUT_KEYS:
|
||||
remove(FILES[key])
|
||||
|
Loading…
Reference in New Issue
Block a user