diff --git a/plugins/util/timeformat.py b/plugins/util/timeformat.py new file mode 100644 index 0000000..185fd36 --- /dev/null +++ b/plugins/util/timeformat.py @@ -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) diff --git a/plugins/vimeo.py b/plugins/vimeo.py index 6edb990..479a544 100755 --- a/plugins/vimeo.py +++ b/plugins/vimeo.py @@ -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"