Keep temp directory if live stream ended with error.
This commit is contained in:
parent
c932c8deb6
commit
0d7ff1d31c
1 changed files with 11 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ import yt_dlp
|
||||||
from Utils import Notifier, get_format, get_opts, jsonCookie, mergeConfig
|
from Utils import Notifier, get_format, get_opts, jsonCookie, mergeConfig
|
||||||
from ItemDTO import ItemDTO
|
from ItemDTO import ItemDTO
|
||||||
from Config import Config
|
from Config import Config
|
||||||
|
import hashlib
|
||||||
|
|
||||||
log = logging.getLogger('download')
|
log = logging.getLogger('download')
|
||||||
|
|
||||||
|
|
@ -160,7 +161,11 @@ class Download:
|
||||||
self.notifier = notifier
|
self.notifier = notifier
|
||||||
|
|
||||||
# Create temp dir for each download.
|
# 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):
|
if not os.path.exists(self.tempPath):
|
||||||
os.makedirs(self.tempPath, exist_ok=True)
|
os.makedirs(self.tempPath, exist_ok=True)
|
||||||
|
|
||||||
|
|
@ -199,6 +204,11 @@ class Download:
|
||||||
if self.tempKeep is True or not self.tempPath:
|
if self.tempKeep is True or not self.tempPath:
|
||||||
return
|
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):
|
if not os.path.exists(self.tempPath):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue