From 11e39cab087e15c978a9f1d8756e48f6425d28d7 Mon Sep 17 00:00:00 2001 From: Fabrice Quenneville Date: Fri, 20 Nov 2020 00:26:39 -0500 Subject: [PATCH] Commenting the code and improved the detect_ffmpeg function --- mediacurator/curator.py | 2 +- mediacurator/library/tools.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mediacurator/curator.py b/mediacurator/curator.py index 730bec5..d01d1e2 100755 --- a/mediacurator/curator.py +++ b/mediacurator/curator.py @@ -30,7 +30,7 @@ def main(): if not ffmpeg_version: print(f"{BColors.FAIL}No ffmpeg version detected{BColors.ENDC}") exit() - print(f"{BColors.OKBLUE}ffmpeg detected: {ffmpeg_version}{BColors.ENDC}") + print(f"{BColors.OKBLUE}ffmpeg version detected: {ffmpeg_version}{BColors.ENDC}") # Get/load command parameters directories = [] diff --git a/mediacurator/library/tools.py b/mediacurator/library/tools.py index 1c0b3c0..b3c05de 100644 --- a/mediacurator/library/tools.py +++ b/mediacurator/library/tools.py @@ -9,13 +9,18 @@ from .bcolors import BColors def detect_ffmpeg(): + '''Returns the version of ffmpeg that is installed or false''' try: txt = subprocess.check_output(['ffmpeg', '-version'], stderr=subprocess.STDOUT).decode() - return txt.partition('\n')[0] + if "ffmpeg version" in txt: + # Strip the useless text and + return txt.split(' ')[2] except: - return False + pass + return False def user_confirm(question): + '''Returns the user answer to a yes or no question''' answer = input(question) if answer.lower() in ["y","yes"]: return True @@ -25,6 +30,7 @@ def user_confirm(question): return user_confirm(question) def deletefile(filename): + '''Delete a file, Returns a boolean''' try: os.remove(filename) except OSError: