From 08db864ae72d0bd01a833e1dee4677c519d6bfad Mon Sep 17 00:00:00 2001 From: Audionut Date: Sat, 28 Sep 2024 21:18:17 +1000 Subject: [PATCH] Fixed torrent creation with keep folder --- src/prep.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/prep.py b/src/prep.py index 2df9bc8a..4c8e3a54 100644 --- a/src/prep.py +++ b/src/prep.py @@ -2458,17 +2458,14 @@ def validate_piece_size(self): def create_torrent(self, meta, path, output_filename): # Handle directories and file inclusion logic if meta['isdir']: - if meta['keep_folder']: - cli_ui.info('--keep-folder was specified. Using complete folder for torrent creation.') - else: - os.chdir(path) - globs = glob.glob1(path, "*.mkv") + glob.glob1(path, "*.mp4") + glob.glob1(path, "*.ts") - no_sample_globs = [] - for file in globs: - if not file.lower().endswith('sample.mkv') or "!sample" in file.lower(): - no_sample_globs.append(os.path.abspath(f"{path}{os.sep}{file}")) - if len(no_sample_globs) == 1: - path = meta['filelist'][0] + os.chdir(path) + globs = glob.glob1(path, "*.mkv") + glob.glob1(path, "*.mp4") + glob.glob1(path, "*.ts") + no_sample_globs = [] + for file in globs: + if not file.lower().endswith('sample.mkv') or "!sample" in file.lower(): + no_sample_globs.append(os.path.abspath(f"{path}{os.sep}{file}")) + if len(no_sample_globs) == 1: + path = meta['filelist'][0] if meta['is_disc']: include, exclude = "", "" else: