From 90a6b4e0c1d0f94c87a2441a2db5ee22a3e4d0c1 Mon Sep 17 00:00:00 2001 From: OleSTEEP Date: Wed, 4 Sep 2024 03:25:43 +0300 Subject: [PATCH] vnrecode: add re to duplicate check --- vnrecode/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vnrecode/utils.py b/vnrecode/utils.py index ec5c2c5..58cf962 100644 --- a/vnrecode/utils.py +++ b/vnrecode/utils.py @@ -2,6 +2,7 @@ from shutil import copyfile from glob import glob import sys import os +import re class Utils: @@ -63,7 +64,10 @@ class Utils: self.printer.info(f"File {filename} copied to compressed folder.") def check_duplicates(self, source: str, output: str, filename: str) -> str: - duplicates = glob(os.path.join(source, os.path.splitext(filename)[0]+".*")) + files = glob(os.path.join(source, os.path.splitext(filename)[0])+".*") + re_pattern = re.compile(os.path.join(source, os.path.splitext(filename)[0])+r".[a-zA-Z0-9]+$") + duplicates = [f for f in files if re_pattern.match(f)] + if len(duplicates) > 1: if filename not in self.duplicates: self.duplicates.append(filename)