Module koplugin.wallabag
This plugin downloads a set number of the newest arcticles in your Wallabag "Unread" list.
As epubs, or in their original formats. It can archive or delete articles from Wallabag when you finish them in KOReader. And it will delete or archive them locally when you finish them elsewhere.
Functions
Wallabag:addToMainMenu (menu_items) | Add Wallabag to the Tools menu in both the file manager and the reader. |
Wallabag:getBearerToken () | Validate server settings and request an OAuth bearer token. |
Wallabag:getArticleList () | Get a JSON formatted list of articles from the server. |
Wallabag:filterIgnoredTags (article_list) | Remove all the articles from the list containing one of the ignored tags. |
Wallabag:downloadArticle (A) | Download a single article from the Wallabag server given by id in the article table. |
Wallabag:callAPI (method, url[, headers[, body[, filepath[, quiet=false]]]]) | Call the Wallabag API. |
Wallabag:downloadArticles () | Add articles from local queue to Wallabag, then download new articles. |
Wallabag:uploadQueue ([quiet=true]) | Upload any articles that were added to the queue. |
Wallabag:processRemoteDeletes (remote_article_ids) | Compare local IDs with remotearticleids and delete or archive any that are missing. |
Wallabag:uploadStatuses ([quiet]) | Archive (or delete) locally finished articles on the Wallabag server. |
Wallabag:addArticle (article_url) | Add a new article (including any auto_tags) to the Wallabag server. |
Wallabag:addTagsFromReview (path) | Add tags from the local review to the article on Wallabag. |
Wallabag:archiveArticle (path) | Archive an article on Wallabag, or if delete_instead, then delete. |
Wallabag:archiveLocalArticle (path) | Move an article and its sidecar to archive_directory. |
Wallabag:deleteLocalArticle (path) | Delete an article and its sidecar locally. |
Wallabag:getArticleID (path) | Extract the Wallabag ID from the file name. |
Wallabag:setTagsDialog (touchmenu_instance, title, description, value, callback) | A dialog used for setting filtertag, ignoretags and auto_tags. |
Wallabag:editServerSettings () | The dialog shown when clicking "Configure Wallabag server". |
Wallabag:setArticlesPerSync (touchmenu_instance) | The dialog shown when clicking "Number of articles to keep locally". |
Wallabag:setDownloadDirectory (touchmenu_instance) | The dialog shown when clicking "Download folder". |
Wallabag:setArchiveDirectory (touchmenu_instance) | The dialog shown when clicking "Archive folder" |
Wallabag:onAddWallabagArticle (article_url) | Handler for addWallabagArticle event. |
Wallabag:getLastPercent () | Get percent read of the opened article. |
Wallabag:onCloseDocument () | Handler for the CloseDocument event. |
Issues
Wallabag:uploadQueue-todo15 | Add error handling |
Functions
- Wallabag:addToMainMenu (menu_items)
-
Add Wallabag to the Tools menu in both the file manager and the reader.
Parameters:
- menu_items
- Wallabag:getBearerToken ()
- Validate server settings and request an OAuth bearer token. Do not request a new token if the saved one is valid for more than 5 minutes.
- Wallabag:getArticleList ()
-
Get a JSON formatted list of articles from the server.
The list should have self.articlepersync item, or less if an error occurred.
If filtertag is set, only articles containing this tag are queried.
If ignoretags is defined, articles containing any of the tags are skipped.
Returns:
-
table
List of article tables
- Wallabag:filterIgnoredTags (article_list)
-
Remove all the articles from the list containing one of the ignored tags.
Parameters:
- article_list table Array containing a JSON formatted list of articles
Returns:
-
table
Same array, but without any articles that contain an ignored tag.
- Wallabag:downloadArticle (A)
-
Download a single article from the Wallabag server given by id in the article table.
Parameters:
- A table list of article tables, see https://doc.wallabag.org/developer/api/methods/#getting-existing-entries
Returns:
-
int
1 failed, 2 skipped, 3 downloaded
- Wallabag:callAPI (method, url[, headers[, body[, filepath[, quiet=false]]]])
-
Call the Wallabag API.
See https://app.wallabag.it/api/doc/ for methods and parameters.
Parameters:
- method GET, POST, DELETE, PATCH, etc…
- url URL endpoint on Wallabag server without hostname, or full URL for external link
- headers Defaults to Authorization for API endpoints, none for external (optional)
- body Body to include in the request, if needed (optional)
- filepath Downloads the file if provided, returns JSON otherwise (optional)
- quiet (default false)
Returns:
- bool Whether the request was successful
- string Error type if unsuccessful, filepath if success with path, JSON if without
- int HTTP response code if unsuccessful (e.g. 404, 503, …)
- Wallabag:downloadArticles ()
-
Add articles from local queue to Wallabag, then download new articles.
If self.auto_archive is true, then local article statuses are uploaded before downloading.
Returns:
-
bool
Whether the synchronization process reached the end (with or without errors)
- Wallabag:uploadQueue ([quiet=true])
-
Upload any articles that were added to the queue.
In case there was no network connection to upload them at the time.
Parameters:
- quiet bool Whether to supress the info message or not (default true)
Returns:
-
int
Number of article URLs added to the server
- Wallabag:processRemoteDeletes (remote_article_ids)
-
Compare local IDs with remotearticleids and delete or archive any that are missing.
Parameters:
- remote_article_ids table Article IDs of articles downloaded this sync run
Returns:
-
int
Number of locally deleted or archived articles
- Wallabag:uploadStatuses ([quiet])
-
Archive (or delete) locally finished articles on the Wallabag server.
Parameters:
- quiet bool Whether to supress the info message or not (optional)
- Wallabag:addArticle (article_url)
-
Add a new article (including any auto_tags) to the Wallabag server.
Parameters:
- article_url string Full URL of the article
Returns:
-
bool
Whether the API call could be made successfully
- Wallabag:addTagsFromReview (path)
-
Add tags from the local review to the article on Wallabag.
Parameters:
- path string Local path of the article
Returns:
-
nil
- Wallabag:archiveArticle (path)
-
Archive an article on Wallabag, or if delete_instead, then delete.
Parameters:
- path string Local path of the article
Returns:
-
bool
Whether archiving or deleting was completed
- Wallabag:archiveLocalArticle (path)
-
Move an article and its sidecar to archive_directory.
Parameters:
- path string Local path of the article
Returns:
-
int
1 if successful, 0 if not
- Wallabag:deleteLocalArticle (path)
-
Delete an article and its sidecar locally.
Parameters:
- path string Local path of the article
Returns:
-
int
1 if successful, 0 if not
- Wallabag:getArticleID (path)
-
Extract the Wallabag ID from the file name.
Parameters:
- path string Local path of the article
Returns:
-
ID as string if successful, nil if not
- Wallabag:setTagsDialog (touchmenu_instance, title, description, value, callback)
-
A dialog used for setting filtertag, ignoretags and auto_tags.
Parameters:
- touchmenu_instance
- title
- description
- value
- callback
- Wallabag:editServerSettings ()
- The dialog shown when clicking "Configure Wallabag server". Or automatically, when getBearerToken is run with an incomplete server configuration.
- Wallabag:setArticlesPerSync (touchmenu_instance)
-
The dialog shown when clicking "Number of articles to keep locally".
Parameters:
- touchmenu_instance
- Wallabag:setDownloadDirectory (touchmenu_instance)
-
The dialog shown when clicking "Download folder".
Or automatically, when getBearerToken is run with an incomplete server configuration.
Parameters:
- touchmenu_instance
- Wallabag:setArchiveDirectory (touchmenu_instance)
-
The dialog shown when clicking "Archive folder"
Parameters:
- touchmenu_instance
- Wallabag:onAddWallabagArticle (article_url)
-
Handler for addWallabagArticle event.
Uploads a new article to Wallabag directly if there is a network connection, or add it to the
local upload queue.
Parameters:
- article_url
- Wallabag:getLastPercent ()
- Get percent read of the opened article.
- Wallabag:onCloseDocument ()
- Handler for the CloseDocument event. If the opened article/book is saved in the Wallabag directory, and if any of the removefromhistory settings are set and matching, then remove it from history