rss.lua: cleanRSS gefixt

This commit is contained in:
Akamaru 2016-07-20 21:01:08 +02:00
parent 47fbddf281
commit dff2efba46

View File

@ -78,17 +78,17 @@ function unescape_for_rss(str)
return str return str
end end
function cleanRSS(cleantext) function cleanRSS(str)
cleantext = string.gsub(cleantext, '%[mehr%]', '') str = string.gsub(str, '%[mehr%]', '')
cleantext = string.gsub(cleantext, '%[video%]', '') str = string.gsub(str, '%[video%]', '')
cleantext = string.gsub(cleantext, '...%[more%]', '') str = string.gsub(str, '...%[more%]', '')
cleantext = string.gsub(cleantext, '%[more%]', '') str = string.gsub(str, '%[more%]', '')
cleantext = string.gsub(cleantext, '%[phoenix%]', '') str = string.gsub(str, '%[phoenix%]', '')
cleantext = string.gsub(cleantext, 'Click for full.', '') str = string.gsub(str, 'Click for full.', '')
cleantext = string.gsub(cleantext, 'Read more »', '') str = string.gsub(str, 'Read more »', '')
cleantext = string.gsub(cleantext, 'Meldung bei www.tagesschau.de lesen', '') str = string.gsub(str, 'Read more', '')
str = string.gsub(str, 'Meldung bei www.tagesschau.de lesen', '')
return cleantext return str
end end
function get_base_redis(id, option, extra) function get_base_redis(id, option, extra)
@ -344,20 +344,20 @@ function rss:cron(self_plz)
local link = v2.link or v2.id or 'Kein Link' local link = v2.link or v2.id or 'Kein Link'
if v2.content then if v2.content then
if string.len(v2.content) > 250 then if string.len(v2.content) > 250 then
content = string.sub(unescape_for_rss(v2.content:gsub("%b<>", "")), 1, 250) .. '...' content = string.sub(unescape_for_rss(cleanRSS(v2.content):gsub("%b<>", "")), 1, 250) .. '...'
else else
content = unescape_for_rss(v2.content:gsub("%b<>", "")) content = unescape_for_rss(cleanRSS(v2.content):gsub("%b<>", ""))
end end
elseif v2.summary then elseif v2.summary then
if string.len(v2.summary) > 250 then if string.len(v2.summary) > 250 then
content = string.sub(unescape_for_rss(v2.summary:gsub("%b<>", "")), 1, 250) .. '...' content = string.sub(unescape_for_rss(cleanRSS(v2.summary):gsub("%b<>", "")), 1, 250) .. '...'
else else
content = unescape_for_rss(v2.summary:gsub("%b<>", "")) content = unescape_for_rss(cleanRSS(v2.summary):gsub("%b<>", ""))
end end
else else
content = '' content = ''
end end
content = cleanRSS(content)
text = text..'\n*[*#RSS*] '..title..'*\n'..utilities.trim(utilities.md_escape(content))..' [Weiterlesen]('..link..')\n' text = text..'\n*[*#RSS*] '..title..'*\n'..utilities.trim(utilities.md_escape(content))..' [Weiterlesen]('..link..')\n'
end end
if text ~= '' then if text ~= '' then