From de818c42049d9a88c0e4c0d4a4612181c6a0b8e9 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 20 Nov 2023 10:19:45 +0000 Subject: [PATCH 1/2] better error for failed imports --- pandora/archive/external.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora/archive/external.py b/pandora/archive/external.py index be0b0a39..5f4ac3fd 100644 --- a/pandora/archive/external.py +++ b/pandora/archive/external.py @@ -205,6 +205,7 @@ def download(item_id, url, referer=None): f.extract_stream() status = True else: + logger.error("failed to import %s file already exists %s", url, oshash) status = 'file exists' if len(parts) == 1: add_subtitles(f.item, media, tmp) From 4794c0f68a4384fbced9f182290b0928e84a5909 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 20 Nov 2023 20:58:58 +0000 Subject: [PATCH 2/2] fix remux --- pandora/archive/extract.py | 15 ++++++++++----- pandora/archive/models.py | 5 ++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index 2765f0f0..6bb3acc1 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -733,19 +733,24 @@ def remux_stream(src, dst): cmd = [ settings.FFMPEG, '-nostats', '-loglevel', 'error', - '-map_metadata', '-1', '-sn', '-i', src, + '-map_metadata', '-1', '-sn', ] + video + [ ] + audio + [ '-movflags', '+faststart', dst ] + print(cmd) p = subprocess.Popen(cmd, stdin=subprocess.PIPE, - stdout=open('/dev/null', 'w'), - stderr=open('/dev/null', 'w'), + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, close_fds=True) - p.wait() - return True, None + stdout, stderr = p.communicate() + if stderr: + logger.error("failed to remux %s %s", cmd, stderr) + return False, stderr + else: + return True, None def ffprobe(path, *args): diff --git a/pandora/archive/models.py b/pandora/archive/models.py index e5f0a1e6..70077cfa 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -821,7 +821,10 @@ class Stream(models.Model): done = True elif self.file.can_remux(): ok, error = extract.remux_stream(media, target) - done = True + if ok: + self.available = True + self.save() + done = True if not done: ok, error = extract.stream(media, target, self.name(), info, flags=self.flags)