From 6a6561717929039c9733806ef712d46f84682f9f Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Wed, 1 Mar 2023 08:55:40 +0000 Subject: [PATCH] Reduce the download stop check to one if check in dl --- devine/commands/dl.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/devine/commands/dl.py b/devine/commands/dl.py index 5af9eea..ced2866 100644 --- a/devine/commands/dl.py +++ b/devine/commands/dl.py @@ -754,11 +754,6 @@ class dl: proxy=proxy, license_widevine=prepare_drm ) - - if self.DL_POOL_STOP.is_set(): - # we stopped during the download, let's exit - return - # no else-if as DASH may convert the track to URL descriptor if track.descriptor == track.Descriptor.URL: if not track.drm and isinstance(track, (Video, Audio)): @@ -781,10 +776,6 @@ class dl: progress=progress ) - if self.DL_POOL_STOP.is_set(): - # we stopped during the download, let's exit - return - track.path = save_path if track.drm: @@ -794,6 +785,10 @@ class dl: if callable(track.OnDecrypted): track.OnDecrypted(track) + if self.DL_POOL_STOP.is_set(): + # we stopped during the download, let's exit + return + if track.path.stat().st_size <= 3: # Empty UTF-8 BOM == 3 bytes raise IOError( "Download failed, the downloaded file is empty. "