From 9135a13d1bed6f0920da3b7325b387fb9433d849 Mon Sep 17 00:00:00 2001 From: mugoh Date: Mon, 5 Aug 2019 15:30:00 +0300 Subject: [PATCH] fix option passing in play --- convertor/cli.py | 5 ++--- convertor/formats.py | 6 +++++- run.py | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 run.py diff --git a/convertor/cli.py b/convertor/cli.py index 0b85973..49f51b4 100644 --- a/convertor/cli.py +++ b/convertor/cli.py @@ -134,6 +134,7 @@ def load_audio(ctx, playlist, recursive, player): click.echo(click.style('Specify the file playlist location', fg='red')) return + playlist = playlist[0] if not isinstance(playlist, str) else playlist if recursive: try: @@ -152,6 +153,7 @@ def load_audio(ctx, playlist, recursive, player): return if not convertor_instance.is_video(playlist): + playlist = playlist[0] if not isinstance(playlist, str) else playlist click.echo(click.style( playlist + " is not a supported media type", fg='red')) return @@ -176,6 +178,3 @@ def flatten(iterable): convertor_instance = Convertor() - -if __name__ == '__main__': - main() diff --git a/convertor/formats.py b/convertor/formats.py index 2049388..a9c503a 100644 --- a/convertor/formats.py +++ b/convertor/formats.py @@ -89,6 +89,11 @@ def is_video(self, given_file): """ video_extensions = ['mp4', 'flv', 'avi', 'mp3', 'flaac'] + if not isinstance(given_file, str): + try: # iter in play cmd + given_file = given_file[0] + except TypeError: + given_file = given_file return any([ext for ext in video_extensions if given_file.endswith(ext)]) @@ -152,7 +157,6 @@ def open_player(self, cmd=[], play_items=[]): system architecture. """ commands = [cmd] + play_items - try: subprocess.check_call(commands) except subprocess.CalledProcessError as er: diff --git a/run.py b/run.py new file mode 100644 index 0000000..8d844c3 --- /dev/null +++ b/run.py @@ -0,0 +1,4 @@ +from convertor.cli import main + +if __name__ == '__main__': + main()