mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
[feat] plugins/wallabag: addArticle() method (#4852)
Currently unused, but a prerequisite for dynamically adding links to Wallabag.
This commit is contained in:
@@ -526,6 +526,29 @@ function Wallabag:processLocalFiles( mode )
|
||||
return num_deleted
|
||||
end
|
||||
|
||||
function Wallabag:addArticle(article_url)
|
||||
logger.dbg("Wallabag: adding article ", article_url)
|
||||
|
||||
if not article_url or self:getBearerToken() == false then
|
||||
return false
|
||||
end
|
||||
|
||||
local body = {
|
||||
url = article_url,
|
||||
}
|
||||
|
||||
local body_JSON = JSON.encode(body)
|
||||
|
||||
local headers = {
|
||||
["Content-type"] = "application/json",
|
||||
["Accept"] = "application/json, */*",
|
||||
["Content-Length"] = tostring(#body_JSON),
|
||||
["Authorization"] = "Bearer " .. self.access_token,
|
||||
}
|
||||
|
||||
self:callAPI("POST", "/api/entries.json", headers, body_JSON, "")
|
||||
end
|
||||
|
||||
function Wallabag:deleteArticle( path )
|
||||
logger.dbg("Wallabag: deleting article ", path )
|
||||
local id = self:getArticleID( path )
|
||||
|
||||
Reference in New Issue
Block a user