From 62c378292c92378a5f30f7a2c56b484897a80f73 Mon Sep 17 00:00:00 2001 From: Emeric Date: Fri, 20 Mar 2020 18:56:09 +0100 Subject: [PATCH] Check files in folder recursively ONLY when using the CLI --- OpenSubtitlesDownload.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/OpenSubtitlesDownload.py b/OpenSubtitlesDownload.py index f8b3e76..4d8c770 100755 --- a/OpenSubtitlesDownload.py +++ b/OpenSubtitlesDownload.py @@ -570,10 +570,17 @@ def dependencyChecker(): for i in result.filePathListArg: filePath = os.path.abspath(i) if os.path.isdir(filePath): - # If it is a folder, check all of its files recursively - for root, _, items in os.walk(filePath): - for item in items: - localPath = os.path.join(root, item) + if opt_gui == 'cli': + # If it is a folder, check all of its files recursively + for root, _, items in os.walk(filePath): + for item in items: + localPath = os.path.join(root, item) + if checkFileValidity(localPath): + videoPathList.append(localPath) + else: + # If it is a folder, check all of its files + for item in os.listdir(filePath): + localPath = os.path.join(filePath, item) if checkFileValidity(localPath): videoPathList.append(localPath) elif checkFileValidity(filePath):