From 9d87424860566083da5c3fb82f493956a8a4ae07 Mon Sep 17 00:00:00 2001 From: vn-ki Date: Tue, 23 Jan 2018 04:12:42 +0530 Subject: [PATCH 1/2] Beautify videotime_from_seconds func --- core/internals.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/internals.py b/core/internals.py index 8cd5203..b64e4d0 100755 --- a/core/internals.py +++ b/core/internals.py @@ -101,11 +101,11 @@ def filter_path(path): def videotime_from_seconds(time): - if time<60: + if time < 60: return str(time) - if time<3600: - return '{}:{}'.format(str(time//60), str(time%60).zfill(2)) + if time < 3600: + return '{0}:{1:02}'.format(time//60, time % 60) - return '{}:{}:{}'.format(str(time//60), - str((time%60)//60).zfill(2), - str((time%60)%60).zfill(2)) + return '{0}:{1:02}:{2:02}'.format((time//60)//60, + (time//60) % 60, + time % 60) From 8dae25fb428ba4991271c30958fc43f2c0c4e9c4 Mon Sep 17 00:00:00 2001 From: Nitesh Sawant Date: Tue, 23 Jan 2018 22:10:03 +0530 Subject: [PATCH 2/2] Tell the user to install `unicode-slugify` in case of ImportError #176 (#206) --- core/internals.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/internals.py b/core/internals.py index b64e4d0..99e29e3 100755 --- a/core/internals.py +++ b/core/internals.py @@ -1,10 +1,17 @@ -from slugify import SLUG_OK, slugify +import sys from core import const -import os - log = const.log +try: + from slugify import SLUG_OK, slugify +except ImportError: + log.error('Oops! `unicode-slugify` was not found.') + log.info('Please remove any other slugify library and install `unicode-slugify`') + sys.exit(5) + +import os + formats = { 0 : 'track_name', 1 : 'artist', 2 : 'album', @@ -100,6 +107,7 @@ def filter_path(path): os.remove(os.path.join(path, temp)) + def videotime_from_seconds(time): if time < 60: return str(time)