This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/otouto/plugins/vimeo.lua
Andreas Bielawski f3c841fb90 - Portierung folgender Plugins:
+ Clypit
+ Dailymotion
+ DeviantArt
+ DHL
+ Dropbox
+ Vimeo
+ Vine
- Fixe einige, kleine Bugs
2016-06-18 15:18:42 +02:00

39 lines
1.1 KiB
Lua

local vimeo = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
vimeo.triggers = {
"vimeo.com/(%d+)"
}
local BASE_URL = 'https://vimeo.com/api/v2'
function vimeo:send_vimeo_data (vimeo_code)
local url = BASE_URL..'/video/'..vimeo_code..'.json'
local res,code = https.request(url)
if code ~= 200 then return "HTTP FEHLER" end
local data = json.decode(res)
local title = '*'..data[1].title..'*'
local uploader = data[1].user_name
local totalseconds = data[1].duration
local duration = makeHumanTime(totalseconds)
if not data[1].stats_number_of_plays then
return title..'\n_(Hochgeladen von: '..uploader..', '..duration..')_'
else
local viewCount = ', '..comma_value(data[1].stats_number_of_plays)..' mal angsehen)' or ""
return title..'\n_(Hochgeladen von: '..uploader..', '..duration..viewCount..'_'
end
end
function vimeo:action(msg, config, matches)
local text = vimeo:send_vimeo_data(matches[1])
if not text then utilities.send_reply(self, msg, config.errors.connection) return end
utilities.send_reply(self, msg, text, true)
end
return vimeo