This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/disabled_stuff/vimeo.py

21 lines
859 B
Python
Raw Permalink Normal View History

from util import hook, http, timeformat
2011-11-20 10:23:31 +01:00
@hook.regex(r'vimeo.com/([0-9]+)')
def vimeo_url(match):
2013-09-04 12:30:04 +02:00
"""vimeo <url> -- returns information on the Vimeo video at <url>"""
info = http.get_json('http://vimeo.com/api/v2/video/%s.json'
% match.group(1))
2011-11-20 10:23:31 +01:00
if info:
info[0]["duration"] = timeformat.format_time(info[0]["duration"])
info[0]["stats_number_of_likes"] = format(
2013-09-04 12:30:04 +02:00
info[0]["stats_number_of_likes"], ",d")
info[0]["stats_number_of_plays"] = format(
2013-09-04 12:30:04 +02:00
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"
% info[0])