From 7937aadec4389bfe96d3d80cfad50312efa2e5d9 Mon Sep 17 00:00:00 2001 From: jwansek Date: Tue, 8 Jan 2019 20:29:22 +0000 Subject: fixed a but with dates and fixed memory leak --- ytapi.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'ytapi.py') diff --git a/ytapi.py b/ytapi.py index b472b7e..267449b 100644 --- a/ytapi.py +++ b/ytapi.py @@ -33,17 +33,24 @@ get_videoId_from_url = js2py.eval_js(r"""function $(url){ }""") def _yt_time_to_norm(time): + origtime = time if time == "ERROR Video deleted?": return time - time = time.replace("M", ":")[2:].replace("S", "") + time = time[2:].replace("H", ":").replace("M", ":").replace("S", "") + + out = "" + for i in time.split(":"): + if len(i) == 1: + out += "0" + i + ":" + elif len(i) == 0: + out += "00:" + else: + out += i + ":" + + return out[:-1] - s = time.split(":") - if len(s) > 1: - if len(s[1]) < 2: - time = s[0] + ":" + s[1] + "0" - return time #this would be better as a class but I can't be bothered so dictionary it is def get_video_data(videoId): -- cgit v1.2.3