instagram: Änderungen rückgängig geacht

This commit is contained in:
Akamaru 2017-07-21 21:43:06 +02:00
parent 1a98fb1a15
commit 274541c6cd
1 changed files with 12 additions and 29 deletions

View File

@ -8,58 +8,41 @@ end
function instagram:get_instagram(url)
local api_key = cred_data.iframely_api_key
local res, code = https.request('https://iframe.ly/api/iframely?url=https://www.instagram.com/p/'..URL.escape(url)..'&api_key='..api_key)
local res, code = https.request('https://iframe.ly/api/oembed?url=https://www.instagram.com/p/'..URL.escape(url)..'&api_key='..api_key)
if code ~= 200 then return end
local data = json.decode(res)
if data.meta.title then
title = data.meta.title:gsub('"', '\\"')
if data.title then
title = data.title:gsub('"', '\\"')
else
title = 'Kein Titel'
end
if data.meta.description then
description = data.meta.description:gsub('"', '\\"')
description_in_text = description
if data.description then
description = data.description:gsub('"', '\\"')
description_in_text = '\n'..description
else
description_in_text = ''
description = 'Keine Beschreibung verfügbar'
end
if data.links.player then
video = 'https:'..data.links.player[1].href
else
video = 'NOVID'
end
if data.links.image then
pic = '<a href="'..data.links.image[1].href..'"> </a>'
else
pic = '<a href="'..data.links.thumbnail[2].href..'"> </a>'
end
local text = '<b>'..title..'</b> '..pic..'\n<i>'..description_in_text..'</i>'
local pic = data.thumbnail_url
local text = title..'\n'..description_in_text
return video, text
return pic, text
end
function instagram:action(msg, config, matches)
local url = matches[1]
local video, text = instagram:get_instagram(url)
local pic, text = instagram:get_instagram(url)
if not url then
utilities.send_reply(msg, 'Fehler')
return
end
if video == 'NOVID' then
return
else
utilities.send_typing(msg.chat.id, 'upload_video')
utilities.send_video(msg.chat.id, video, nil, msg.message_id)
end
utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html')
utilities.send_typing(msg.chat.id, 'upload_photo')
utilities.send_photo(msg.chat.id, pic, text, msg.message_id)
end
return instagram