vnrecode: add re to duplicate check

This commit is contained in:
OleSTEEP 2024-09-04 03:25:43 +03:00
parent 7433027cf3
commit 90a6b4e0c1

View file

@ -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)