From 7082718c148c814f75bc6fff31ceba58fd39d539 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 20 May 2023 20:08:36 +0700 Subject: [PATCH] add days to seconds string converter --- tubearchivist/home/src/index/video_streams.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tubearchivist/home/src/index/video_streams.py b/tubearchivist/home/src/index/video_streams.py index a439716d..7f6f2f22 100644 --- a/tubearchivist/home/src/index/video_streams.py +++ b/tubearchivist/home/src/index/video_streams.py @@ -35,24 +35,27 @@ class DurationConverter: return duration_sec @staticmethod - def get_str(duration_sec): + def get_str(seconds): """takes duration in sec and returns clean string""" - if not duration_sec: + if not seconds: # failed to extract return "NA" - hours = int(duration_sec // 3600) - minutes = int((duration_sec - (hours * 3600)) // 60) - secs = int(duration_sec - (hours * 3600) - (minutes * 60)) + days = int(seconds // (24 * 3600)) + hours = int((seconds % (24 * 3600)) // 3600) + minutes = int((seconds % 3600) // 60) + seconds = int(seconds % 60) duration_str = str() + if days: + duration_str = f"{days}d " if hours: - duration_str = str(hours).zfill(2) + ":" + duration_str = duration_str + str(hours).zfill(2) + ":" if minutes: duration_str = duration_str + str(minutes).zfill(2) + ":" else: duration_str = duration_str + "00:" - duration_str = duration_str + str(secs).zfill(2) + duration_str = duration_str + str(seconds).zfill(2) return duration_str