Commenting the code and improved the detect_ffmpeg function

This commit is contained in:
Fabrice Quenneville 2020-11-20 00:26:39 -05:00
parent 05a60c278c
commit 11e39cab08
2 changed files with 9 additions and 3 deletions

View File

@ -30,7 +30,7 @@ def main():
if not ffmpeg_version: if not ffmpeg_version:
print(f"{BColors.FAIL}No ffmpeg version detected{BColors.ENDC}") print(f"{BColors.FAIL}No ffmpeg version detected{BColors.ENDC}")
exit() 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 # Get/load command parameters
directories = [] directories = []

View File

@ -9,13 +9,18 @@ from .bcolors import BColors
def detect_ffmpeg(): def detect_ffmpeg():
'''Returns the version of ffmpeg that is installed or false'''
try: try:
txt = subprocess.check_output(['ffmpeg', '-version'], stderr=subprocess.STDOUT).decode() 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: except:
return False pass
return False
def user_confirm(question): def user_confirm(question):
'''Returns the user answer to a yes or no question'''
answer = input(question) answer = input(question)
if answer.lower() in ["y","yes"]: if answer.lower() in ["y","yes"]:
return True return True
@ -25,6 +30,7 @@ def user_confirm(question):
return user_confirm(question) return user_confirm(question)
def deletefile(filename): def deletefile(filename):
'''Delete a file, Returns a boolean'''
try: try:
os.remove(filename) os.remove(filename)
except OSError: except OSError: