mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
[feat, plugin] NewsDownloader: continue processing feed on download error (#14650)
This commit is contained in:
@@ -695,26 +695,36 @@ function NewsDownloader:processFeed(feed_type, feeds, cookies, http_auth, limit,
|
||||
feed_description = feed.summary
|
||||
end
|
||||
-- Download the article.
|
||||
local download_full_failed = false
|
||||
if download_full_article then
|
||||
self:downloadFeed(
|
||||
feed,
|
||||
cookies,
|
||||
http_auth,
|
||||
feed_output_dir,
|
||||
include_images,
|
||||
article_message,
|
||||
enable_filter,
|
||||
filter_element,
|
||||
block_element
|
||||
)
|
||||
else
|
||||
local ok, error = pcall(function()
|
||||
self:downloadFeed(
|
||||
feed,
|
||||
cookies,
|
||||
http_auth,
|
||||
feed_output_dir,
|
||||
include_images,
|
||||
article_message,
|
||||
enable_filter,
|
||||
filter_element,
|
||||
block_element
|
||||
)
|
||||
end)
|
||||
if not ok then
|
||||
local link = self.getFeedLink(feed.link)
|
||||
logger.warn("NewsDownloader: failed to download full article from", link, ":", error)
|
||||
download_full_failed = true
|
||||
end
|
||||
end
|
||||
if not download_full_article or download_full_failed then
|
||||
self:createFromDescription(
|
||||
feed,
|
||||
feed_title,
|
||||
feed_description or "",
|
||||
feed_output_dir,
|
||||
include_images,
|
||||
article_message
|
||||
article_message,
|
||||
download_full_failed
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -766,7 +776,7 @@ function NewsDownloader:downloadFeed(feed, cookies, http_auth, feed_output_dir,
|
||||
end
|
||||
end
|
||||
|
||||
function NewsDownloader:createFromDescription(feed, title, content, feed_output_dir, include_images, message)
|
||||
function NewsDownloader:createFromDescription(feed, title, content, feed_output_dir, include_images, message, download_full_failed)
|
||||
local title_with_date = getTitleWithDate(feed)
|
||||
local news_file_path = ("%s%s%s"):format(feed_output_dir,
|
||||
title_with_date,
|
||||
@@ -778,7 +788,12 @@ function NewsDownloader:createFromDescription(feed, title, content, feed_output_
|
||||
logger.dbg("NewsDownloader: News file will be stored to :", news_file_path)
|
||||
local article_message = T(_("%1\n%2"), message, title_with_date)
|
||||
local byline = getByline(feed)
|
||||
local footer = _("If this is only a summary, the full article can be downloaded by going to the News Downloader settings and changing 'Download full article' to 'true'.")
|
||||
local footer
|
||||
if download_full_failed then
|
||||
footer = _("Downloading the full article failed. To retry, delete this file and sync again.")
|
||||
else
|
||||
footer = _("If this is only a summary, the full article can be downloaded by going to the News Downloader settings and changing 'Download full article' to 'true'.")
|
||||
end
|
||||
|
||||
local base_url = self.getFeedLink(feed.link)
|
||||
if base_url then
|
||||
|
||||
Reference in New Issue
Block a user