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/dailymotion.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

32 lines
887 B
Lua

local dailymotion = {}
local https = require('ssl.https')
local json = require('dkjson')
local utilities = require('otouto.utilities')
dailymotion.triggers = {
"dailymotion.com/video/([A-Za-z0-9-_-]+)"
}
local BASE_URL = 'https://api.dailymotion.com'
function dailymotion:send_dailymotion_info (dm_code)
local url = BASE_URL..'/video/'..dm_code
local res,code = https.request(url)
if code ~= 200 then return nil end
local data = json.decode(res)
local title = data.title
local channel = data.channel
local text = '*'..title..'*\nHochgeladen in die Kategorie *'..channel..'*'
return text
end
function dailymotion:action(msg, config, matches)
local text = dailymotion:send_dailymotion_info(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 dailymotion