Merge pull request #119 from blha303/patch-7

Fix duration, add new function for timestamp formatting
This commit is contained in:
Luke Rogers 2013-08-24 02:24:43 -07:00
commit 7e8b53d17a
2 changed files with 21 additions and 2 deletions

View file

@ -0,0 +1,14 @@
def timeformat(seconds):
days = seconds / 86400
seconds -= 86400 * days
hours = seconds / 3600
seconds -= 3600 * hours
minutes = seconds / 60
seconds -= 60 * minutes
if days != 0:
return "%sd %sh %sm %ss" % (days, hours, minutes, seconds)
elif hours == 0 and minutes != 0:
return "%sm %ss" % (minutes, seconds)
elif hours == 0 and minutes == 0:
return "%ss" % seconds
return "%sh %sm %ss" % (hours, minutes, seconds)

View file

@ -1,4 +1,4 @@
from util import hook, http
from util import hook, http, timeformat
@hook.regex(r'vimeo.com/([0-9]+)')
@ -8,7 +8,12 @@ def vimeo_url(match):
% match.group(1))
if info:
return ("\x02%(title)s\x02 - length \x02%(duration)ss\x02 - "
info[0]["duration"] = timeformat.timeformat(info[0]["duration"])
info[0]["stats_number_of_likes"] = format(
info[0]["stats_number_of_likes"], ",d")
info[0]["stats_number_of_plays"] = format(
info[0]["stats_number_of_plays"], ",d")
return ("\x02%(title)s\x02 - length \x02%(duration)s\x02 - "
"\x02%(stats_number_of_likes)s\x02 likes - "
"\x02%(stats_number_of_plays)s\x02 plays - "
"\x02%(user_name)s\x02 on \x02%(upload_date)s\x02"