aboutsummaryrefslogtreecommitdiffstats
path: root/ytapi.py
diff options
context:
space:
mode:
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):