From 28a35f6cd0fb48a673ff9cef823ad184b9651e78 Mon Sep 17 00:00:00 2001 From: Michel Faria <36249770+michelfaria@users.noreply.github.com> Date: Mon, 28 Sep 2020 10:41:41 -0300 Subject: [PATCH] Program should refuse to run with an informative error message if ffmpeg is not found in PATH (#350) Co-authored-by: Michel --- scdl/scdl.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scdl/scdl.py b/scdl/scdl.py index 3104490..e931d2e 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -67,6 +67,7 @@ import re import tempfile import codecs import shlex +import shutil import configparser import mutagen @@ -341,6 +342,10 @@ def download(user, dl_type, name): """ Download user items of dl_type (ie. all, playlists, liked, commented, etc.) """ + if not is_ffmpeg_available(): + logger.error('ffmpeg is not available and download cannot continue. Please install ffmpeg and re-run the program.') + return + username = user['username'] user_id = user['id'] logger.info( @@ -765,6 +770,11 @@ def signal_handler(signal, frame): logger.info('\nGood bye!') sys.exit(0) +def is_ffmpeg_available(): + """ + Returns true if ffmpeg is available in the operating system + """ + return shutil.which('ffmpeg') is not None if __name__ == '__main__': main()