Plex: Inline
Upstream-Merge
This commit is contained in:
commit
1fc4941604
@ -2,6 +2,9 @@ local plex = {}
|
|||||||
|
|
||||||
function plex:init(config)
|
function plex:init(config)
|
||||||
plex.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('plex', true).table
|
plex.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('plex', true).table
|
||||||
|
plex.inline_triggers = {
|
||||||
|
"^plex (.+)"
|
||||||
|
}
|
||||||
plex.doc = '\n*/plex* _<Suchbegriff>_'
|
plex.doc = '\n*/plex* _<Suchbegriff>_'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -33,7 +36,7 @@ function plex:get_plex(query)
|
|||||||
Accept = "application/json"
|
Accept = "application/json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
local ok, response_code, response_headers, response_status_line = http.request(request_constructor)
|
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
|
||||||
if not ok then return 'NOTOK' end
|
if not ok then return 'NOTOK' end
|
||||||
local data = json.decode(table.concat(response_body))._children[1]
|
local data = json.decode(table.concat(response_body))._children[1]
|
||||||
|
|
||||||
@ -58,7 +61,7 @@ function plex:get_plex(query)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if data.parentTitle then
|
if data.parentTitle then
|
||||||
artist = ' von <b>'..data.parentTitle..'</b>'
|
artist = '<b>'..data.parentTitle..'</b>'
|
||||||
else
|
else
|
||||||
artist = ''
|
artist = ''
|
||||||
end
|
end
|
||||||
@ -83,18 +86,15 @@ function plex:get_plex(query)
|
|||||||
|
|
||||||
if data.originallyAvailableAt then
|
if data.originallyAvailableAt then
|
||||||
date = makeOurDate(data.originallyAvailableAt)
|
date = makeOurDate(data.originallyAvailableAt)
|
||||||
date1 = '\n<b>Ausstrahlung:</b> '..date
|
|
||||||
date2 = '\n<b>Veröffentlicht:</b> '..date
|
|
||||||
elseif data.year then
|
elseif data.year then
|
||||||
date = data.year
|
date = data.year
|
||||||
date1 = '\n<b>Ausstrahlung:</b> '..date
|
|
||||||
date2 = '\n<b>Veröffentlicht:</b> '..date
|
|
||||||
else
|
else
|
||||||
date = ''
|
date = ''
|
||||||
date1 = date
|
|
||||||
date2 = date
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local date1 = '\n<b>Ausstrahlung:</b> '..date
|
||||||
|
local date2 = '\n<b>Veröffentlicht:</b> '..date
|
||||||
|
|
||||||
if data.leafCount then
|
if data.leafCount then
|
||||||
if data.leafCount > 1 then
|
if data.leafCount > 1 then
|
||||||
episodes = ' ('..data.leafCount..' Episoden) '
|
episodes = ' ('..data.leafCount..' Episoden) '
|
||||||
@ -149,7 +149,7 @@ function plex:get_plex(query)
|
|||||||
elseif data.librarySectionTitle == 'Filme' then
|
elseif data.librarySectionTitle == 'Filme' then
|
||||||
text = title..tag..origtitle..studio..date2..fsk..duration..rating..desc
|
text = title..tag..origtitle..studio..date2..fsk..duration..rating..desc
|
||||||
elseif data.librarySectionTitle == 'Musik' then
|
elseif data.librarySectionTitle == 'Musik' then
|
||||||
text = title..artist..date2..desc
|
text = title..' von '..artist..date2
|
||||||
elseif data.librarySectionTitle == 'Serien' then
|
elseif data.librarySectionTitle == 'Serien' then
|
||||||
text = title..from..studio..date1..episodes..fsk..duration..rating..desc
|
text = title..from..studio..date1..episodes..fsk..duration..rating..desc
|
||||||
elseif data.librarySectionTitle == 'YouTube Serien' then
|
elseif data.librarySectionTitle == 'YouTube Serien' then
|
||||||
@ -159,11 +159,20 @@ function plex:get_plex(query)
|
|||||||
if string.match(title, 'Local Network') then
|
if string.match(title, 'Local Network') then
|
||||||
return 'Nichts gefunden!'
|
return 'Nichts gefunden!'
|
||||||
else
|
else
|
||||||
return text, pic
|
return text, pic, data.title
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function plex:inline_callback(inline_query, config, matches)
|
||||||
|
local input = string.gsub(URL.escape(matches[1]), '&', '+')
|
||||||
|
local text, _, title = plex:get_plex(input)
|
||||||
|
if not text or not title then abort_inline_query(inline_query) return end
|
||||||
|
local text = text:gsub('"', '\\"')
|
||||||
|
local results = '[{"type":"article","id":"PLEX","title":"'..title..'","thumb_url":"https://anditest.perseus.uberspace.de/inlineQuerys/plex/plex.jpg","thumb_width":150,"thumb_height":150,"input_message_content":{"message_text":"'..text..'","parse_mode":"HTML"}}]'
|
||||||
|
utilities.answer_inline_query(inline_query, results, 3600)
|
||||||
|
end
|
||||||
|
|
||||||
function plex:action(msg, config)
|
function plex:action(msg, config)
|
||||||
local input = utilities.input_from_msg(msg)
|
local input = utilities.input_from_msg(msg)
|
||||||
if not input then
|
if not input then
|
||||||
|
@ -42,13 +42,17 @@ function preview:inline_callback(inline_query, config, matches)
|
|||||||
|
|
||||||
if data.thumbnail_url then
|
if data.thumbnail_url then
|
||||||
thumb = data.thumbnail_url
|
thumb = data.thumbnail_url
|
||||||
|
width = data.thumbnail_width
|
||||||
|
height = data.thumbnail_height
|
||||||
else
|
else
|
||||||
thumb = 'https://anditest.perseus.uberspace.de/inlineQuerys/generic/internet.jpg'
|
thumb = 'https://anditest.perseus.uberspace.de/inlineQuerys/generic/internet.jpg'
|
||||||
|
width = 150
|
||||||
|
height = 150
|
||||||
end
|
end
|
||||||
|
|
||||||
local message_text = '<b>'..title..'</b>'..description_in_text..'\n<i>- '..provider_name..'</i>'
|
local message_text = '<b>'..title..'</b>'..description_in_text..'\n<i>- '..provider_name..'</i>'
|
||||||
|
|
||||||
local results = '[{"type":"article","id":"77","title":"'..title..'","description":"'..description..'","url":"'..preview_url..'","thumb_url":"'..thumb..'","thumb_width":150,"thumb_height":150,"hide_url":true,"reply_markup":{"inline_keyboard":[[{"text":"Webseite aufrufen","url":"'..preview_url..'"}]]},"input_message_content":{"message_text":"'..message_text..'","parse_mode":"HTML","disable_web_page_preview":true}}]'
|
local results = '[{"type":"article","id":"77","title":"'..title..'","description":"'..description..'","url":"'..preview_url..'","thumb_url":"'..thumb..'","thumb_width":'..width..',"thumb_height":'..height..',"hide_url":true,"reply_markup":{"inline_keyboard":[[{"text":"Webseite aufrufen","url":"'..preview_url..'"}]]},"input_message_content":{"message_text":"'..message_text..'","parse_mode":"HTML","disable_web_page_preview":true}}]'
|
||||||
utilities.answer_inline_query(inline_query, results, data.cache_age)
|
utilities.answer_inline_query(inline_query, results, data.cache_age)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user