rsslair/scripts/godot.lua

40 lines
1.2 KiB
Lua

local WEBSITE_NAME = "Godot"
local WEBSITE_HOME = "https://godotengine.org"
add_route('godot', '/godot')
godot = {}
function godot.route(args)
local xml = get("https://godotengine.org/rss.xml")
local rss_parser = Feed()
local feed = rss_parser:new(xml)
local articles = feed.channel.articles
local existing_articles = db:check_if_articles_in_feed_exist(feed)
log:debug("Fetching missing articles from the database")
for _, article in ipairs(articles) do
if existing_articles[article.guid.value] then
log:debug("Article already exists in the database: " .. article.title)
article.description = existing_articles[article.guid.value]
goto continue
end
log:debug("Getting article: " .. article.title .. " from " .. article.link)
local article_content = get(article.link)
local html_parser = HtmlParser()
html_parser:parse(article_content)
local elements = html_parser:select_element('.article-body')
local element = elements
[1]
article.description =
element
sleep(500)
::continue::
end
return feed:render(), feed
end