aboutsummaryrefslogtreecommitdiffstats
path: root/ytapi.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2019-01-08 20:29:22 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2019-01-08 20:29:22 +0000
commit7937aadec4389bfe96d3d80cfad50312efa2e5d9 (patch)
treef13a2acf402872cf3937bceaf92505cf4fe2afcc /ytapi.py
parentd6477e138753d8d1534faae3c23406ed6e4d6714 (diff)
downloadSmallYTChannelBot-7937aadec4389bfe96d3d80cfad50312efa2e5d9.tar.gz
SmallYTChannelBot-7937aadec4389bfe96d3d80cfad50312efa2e5d9.zip
fixed a but with dates and fixed memory leak
Diffstat (limited to 'ytapi.py')
-rw-r--r--ytapi.py19
1 files changed, 13 insertions, 6 deletions
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):