Skip to content

Commit

Permalink
Add arguement to show version
Browse files Browse the repository at this point in the history
  • Loading branch information
mohi7solanki committed Apr 2, 2018
1 parent 84d0214 commit 42ed180
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion playlist_length/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
__version__ = '1.3'
from .__version__ import __version__

__version__ = __version__
__author__ = 'Karan Suthar, Mohit Solanki'
__license__ = 'MIT License'
__description__ = 'A command-line tool to calculate the length of vidoes in a directory'
1 change: 1 addition & 0 deletions playlist_length/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '1.3'
19 changes: 16 additions & 3 deletions playlist_length/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from huepy import bold, green, red
from tqdm import tqdm

from __version__ import __version__


def probe(vid_file_path):
'''
Expand All @@ -31,8 +33,8 @@ def probe(vid_file_path):

pipe = sp.Popen(command, stdout=sp.PIPE, stderr=sp.STDOUT)
out, error = pipe.communicate()
if not error:
return json.loads(out.decode('utf-8'))
result = {} if error else json.loads(out.decode('utf-8'))
return result


def duration(vid_file_path):
Expand Down Expand Up @@ -119,7 +121,7 @@ def video_len_calculator(BASE_PATH, no_subdir):
return bold(green(result))


def main():
def get_parser():
parser = argparse.ArgumentParser(
description='''
Output the total duration of all the videos in given directory.
Expand All @@ -137,6 +139,17 @@ def main():
help='Don\'t look for videos in sub directories.',
action='store_true',
)
parser.add_argument(
'-v',
'--version',
action='version',
version='%(prog)s {version}'.format(version=__version__)
)
return parser


def main():
parser = get_parser()
args = parser.parse_args()
result = video_len_calculator(args.path, args.no_subdir)
sys.stdout.write('\n{}\n\n'.format(result))
Expand Down

0 comments on commit 42ed180

Please sign in to comment.