From 0d7ff1d31cc8f9ffa2f635bd8f6ce3ecc30eae95 Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Tue, 9 Jan 2024 18:10:37 +0300 Subject: [PATCH] Keep temp directory if live stream ended with error. --- app/Download.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Download.py b/app/Download.py index d4e8246c..323fc2c9 100644 --- a/app/Download.py +++ b/app/Download.py @@ -10,6 +10,7 @@ import yt_dlp from Utils import Notifier, get_format, get_opts, jsonCookie, mergeConfig from ItemDTO import ItemDTO from Config import Config +import hashlib log = logging.getLogger('download') @@ -160,7 +161,11 @@ class Download: self.notifier = notifier # Create temp dir for each download. - self.tempPath = os.path.join(self.temp_dir, self.info._id) + self.tempPath = os.path.join( + self.temp_dir, + hashlib.shake_256(self.info.id.encode('utf-8')).hexdigest(5) + ) + if not os.path.exists(self.tempPath): os.makedirs(self.tempPath, exist_ok=True) @@ -199,6 +204,11 @@ class Download: if self.tempKeep is True or not self.tempPath: return + if self.info.status != 'finished' and (self.info.live_in or self.info.is_live): + log.warning( + f'Keeping live temp directory: {self.tempPath}, as the reported status is not finished [{self.info.status}].') + return + if not os.path.exists(self.tempPath): return