From 80c9be0bafee5b6958960f8e5d7d54ca42ad4875 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Thu, 2 Nov 2023 09:32:22 +1100 Subject: [PATCH] cutter: Get archive cut working --- common/common/segments.py | 4 ++-- cutter/cutter/upload_backends.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/common/segments.py b/common/common/segments.py index 68bfeb5..adb0dfe 100644 --- a/common/common/segments.py +++ b/common/common/segments.py @@ -665,7 +665,7 @@ def archive_cut_segments(segment_ranges, ranges, tempdir): which the caller should then do something with (probably either read then delete, or rename). """ # don't re-encode anything, just put it into an MKV container - encode_args = ["-c", "copy", "-f", "mkv"] + encode_args = ["-c", "copy", "-f", "matroska"] # We treat multiple segment ranges as having an explicit discontinuity between them. # So we apply split_contiguous() to each range, then flatten. contiguous_ranges = [] @@ -705,7 +705,7 @@ def archive_cut_segments(segment_ranges, ranges, tempdir): raise else: # Success, inform caller of tempfile. It's now their responsibility to delete. - yield tempfile + yield tempfile_name @timed('waveform') diff --git a/cutter/cutter/upload_backends.py b/cutter/cutter/upload_backends.py index 5787102..31124a3 100644 --- a/cutter/cutter/upload_backends.py +++ b/cutter/cutter/upload_backends.py @@ -353,7 +353,8 @@ class LocalArchive(Local): """Similar to Local() but does archive cuts. See archive_cut_segments().""" encoding_settings = "archive" - def upload_video(self, title, description, tags, public, tempfiles): + def upload_video(self, title, description, tags, public, data): + tempfiles = data # make title safe by removing offending characters, replacing with '-' safe_title = re.sub('[^A-Za-z0-9_]', '-', title) # To aid in finding the "latest" version if re-edited, prefix with current time. @@ -362,6 +363,7 @@ class LocalArchive(Local): common.ensure_directory(os.path.join(self.path, video_dir)) for n, tempfile in enumerate(tempfiles): filepath = os.path.join(self.path, video_dir, "{}-{}.mkv".format(safe_title, n)) + common.ensure_directory(filepath) # We're assuming these are on the same filesystem. This may not always be true # but it will be in our normal setup. If we ever need this in the future, we'll fix it then. os.rename(tempfile, filepath)