Fix duration, add new function for timestamp formatting
This commit is contained in:
parent
32593e3be8
commit
9356e4e9ca
1 changed files with 14 additions and 8 deletions
|
@ -1,15 +1,21 @@
|
||||||
from util import hook, http
|
from util import hook, http, timeformat
|
||||||
|
|
||||||
|
|
||||||
@hook.regex(r'vimeo.com/([0-9]+)')
|
@hook.regex(r'vimeo.com/([0-9]+)')
|
||||||
def vimeo_url(match):
|
def vimeo_url(match):
|
||||||
"vimeo <url> -- returns information on the Vimeo video at <url>"
|
"vimeo <url> -- returns information on the Vimeo video at <url>"
|
||||||
info = http.get_json('http://vimeo.com/api/v2/video/%s.json'
|
info = http.get_json('http://vimeo.com/api/v2/video/%s.json' % match.group(1))
|
||||||
% match.group(1))
|
|
||||||
|
|
||||||
if info:
|
if info:
|
||||||
return ("\x02%(title)s\x02 - length \x02%(duration)ss\x02 - "
|
info = info[0]
|
||||||
"\x02%(stats_number_of_likes)s\x02 likes - "
|
return ("\x02{title}\x02 - length \x02{duration}\x02 - "
|
||||||
"\x02%(stats_number_of_plays)s\x02 plays - "
|
"\x02{likes}\x02 likes - "
|
||||||
"\x02%(user_name)s\x02 on \x02%(upload_date)s\x02"
|
"\x02{plays}\x02 plays - "
|
||||||
% info[0])
|
"\x02{username}\x02 on \x02{uploaddate}\x02".format(
|
||||||
|
title=info["title"],
|
||||||
|
duration=timeformat.timeformat(info["duration"]),
|
||||||
|
likes=info["stats_number_of_likes"],
|
||||||
|
plays=info["stats_number_of_plays"],
|
||||||
|
username=info["user_name"],
|
||||||
|
uploaddate=info["upload_date"])
|
||||||
|
)
|
||||||
|
|
Reference in a new issue