Skip to content

Commit

Permalink
test: terminate download process if video is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
qx6ghqkz committed Dec 5, 2024
1 parent f093036 commit 966c399
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gallery-dl-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ def download(url, request_options):

while True:
output = process.stdout.readline()

if output == "" and process.poll() is not None:
break

if output:
formatted_output = remove_ansi_escape_sequences(output.strip())

if formatted_output.startswith("#"):
logger.warning(
"File already exists and/or its ID is in a download archive."
Expand All @@ -234,6 +237,10 @@ def download(url, request_options):
else:
logger.info(formatted_output)

if "Video should already be available" in formatted_output:
process.kill()
logger.info("Terminating process as video is not available.")

exit_code = process.wait()
if exit_code == 0:
logger.info("Download task completed with exit code: 0")
Expand Down

0 comments on commit 966c399

Please sign in to comment.