From 2078028ae0a5f6d7c60ea6365a880cc328ae32a5 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Wed, 21 Sep 2016 00:33:58 +0200 Subject: [PATCH] Twitter: Fixe Videos, da Twitter WebM nicht mehr ausliefert --- otouto/plugins/twitter.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/otouto/plugins/twitter.lua b/otouto/plugins/twitter.lua index 0640f47..e08cf11 100644 --- a/otouto/plugins/twitter.lua +++ b/otouto/plugins/twitter.lua @@ -60,7 +60,6 @@ function twitter:action(msg, config, matches) verified = '' end local header = 'Tweet von '..full_name..' (@' ..user_name..''..verified..'):' - local text = response.text -- favorites & retweets @@ -100,18 +99,18 @@ function twitter:action(msg, config, matches) if response.entities.media and response.extended_entities.media then for k, v in pairs(response.extended_entities.media) do local url = v.url - local pic = v.media_url_https if v.video_info then - if not v.video_info.variants[3] then - local vid = v.video_info.variants[1].url + if v.video_info.variants[#v.video_info.variants].bitrate == 2176000 then + local vid = v.video_info.variants[#v.video_info.variants].url videos[#videos+1] = vid else - local vid = v.video_info.variants[3].url + local vid = v.video_info.variants[1].url videos[#videos+1] = vid end - end - text = text:gsub(url, "") - images[#images+1] = pic + else + images[#images+1] = v.media_url_https + end + text = text:gsub(url, '') end end @@ -130,8 +129,7 @@ function twitter:action(msg, config, matches) end -- send the parts - utilities.send_reply(msg, header .. "\n" .. text.."\n"..footer, 'HTML') - if videos[1] then images = {} end + utilities.send_reply(msg, header .. "\n" .. utilities.trim(text).."\n"..footer, 'HTML') for k, v in pairs(images) do local file = download_to_file(v) utilities.send_photo(msg.chat.id, file, nil, msg.message_id)