diff --git a/plugins/plex.lua b/plugins/plex.lua index 033fe24..8db13ac 100644 --- a/plugins/plex.lua +++ b/plugins/plex.lua @@ -27,6 +27,8 @@ local function get_plex(query) local ok, response_code, response_headers, response_status_line = http.request(request_constructor) local data = json:decode(table.concat(response_body))._children[1] + if not data then return 'Nichts gefunden!' end + local title = data.title if data.parentIndex then @@ -77,17 +79,29 @@ local data = json:decode(table.concat(response_body))._children[1] rating = '' end - local desc = '\n\nBeschreibung: '..data.summary - local pic = baseurl..data.thumb + if data.summary then + desc = '\n\nBeschreibung: '..string.gsub(data.summary, 'EditBackgroundNo(.*)', '') + else + desc = '' + end + + if data.thumb then + pic = baseurl..data.thumb + end local text = title..from..origtitle..studio..date..fsk..rating..desc..'\n' - return text, pic + + if data.thumb then + return text, pic + else + return text + end + end local function run(msg, matches) - local query = matches[1] - local query = string.gsub(query, ":", '%%3A' ) + local query = URL.escape(matches[1]) local query = string.gsub(query, " ", '+' ) local text, pic = get_plex(query) local receiver = get_receiver(msg)