
With the advent of the e-book, I wanted to receive a bundle of news on it every day in order to read them on the way to work. It would seem that the tools are already there: take it and use it. But, as always, the difficulties in the details:
- Articles should be sent on schedule
- Only new articles should be sent.
- Different sites need different settings.
- Pictures are not only in jpeg
- For xkcd you need to be able to render latex
- There are a lot of articles on Habré, and only favorites are sent to the book.
Existing solutions
Pluses: simplicity. One click puts the addition to the browser. The second click send the page to the reader.
Disadvantages: simplicity. Well, it is impossible to explain to these utilities that comments are also interesting to read and should be included in the article. There is also no periodic collection of articles.
Pros: Powerful configurable open source tool. You can get him to do exactly what you need.
Disadvantages: in order for him to do exactly what is needed, revision with a rasp is required. About this article.
Requirements
- Once a day it is necessary to collect the accumulated articles and send to the reader.
- Many rss feeds have few entries, so the option with a separate book for each feed was not considered. Moreover, in kindle a convenient two-level table of contents was discovered.
- Modern readers support not only jpeg. Black-and-white png comics do not have to be clamped, especially it’s not necessary to change the transparent background to black: rectangles are conceptually and stylish, but not quite what I want to consider every morning.
- I need the opportunity to mark the articles that I want to read on the book. They and only they must be transferred.
- It is advisable to download articles immediately before submitting so that more comments have accumulated on them.
- Latex formulas should be rendered in png, not drawn using JavaScript
Decision
Conversion
To download and convert articles, use the command-line version of
caliber . You must use a version of at least 0.8.51, since it supports the option
--mobi-keep-original-images . Unfortunately, the conversion to mobi is not the only place where images are forcibly saved in jpeg. We need to wean RecursiveFetcher, loading news feeds from this bad habit. Another problem is that the unit of configuration in caliber is the entire book. I also had to have different conversion settings for different tapes. This is solved by creating a new FeedFetchSettings entity and writing a special MultiFeedRecipe configured by these settings. All these modifications
can be found on the githaba . Also, MultiFeedRecipe can remember which articles it has already downloaded, and the next time it starts, it skips them.
latex
I like to read
What If , but for drawing formulas, the author uses the JavaScript library, which, of course, does not work in the reader. Therefore, instead of it, I use the texvc utility from the mediawiki-math-texvc package, which generates html for simple formulas and images for complex ones. Therefore, for the If If export to work, this library must be installed.
Articles from Habr
Pumping out all the habrahabr on the reading room is not what I would like. I need to postpone individual long articles, so that later, when there is a mood, read them. To do this, I installed on my hosting the simplest script, giving the rss feed to the GET request and adding links to it via the POST request. The number of results issued is limited, old records are discarded. There is no authorization, but I will not say the address of the script either. Those interested can install it in their own, renaming.
Greasemonkey userscript is attached to the server script, it works in firefox and opera and adds the
2kindle button to the posts:

When you click on it, the post is added to the tape and in the morning, before I leave the house, caliber will download the articles to the device.
Delivery to the reading room
In caliber there is a utility caliber-smtp, which I use to send ready-made books to kindle. And amazon, having received this email, sends the file via WiFi to the reader.
Customization
Take
example.recipe , copy to a secluded place. Configure restrictions on the number and age of articles, as well as the path to the file in which to save the list of downloaded articles. The feed_settings property lists settings for each of the sources of articles. You can specify extra settings. And in the feeds property lists the names of sources and addresses of the tapes in the order in which they should be in the table of contents.
Depending on your preferences, you can either set up periodic generation of books in caliber, or do it from the command line:
ebook-convert example.recipe news.mobi --no-inline-toc --mobi-keep-original-images --output-profile=kindle
Unrealized Wishlist
Of course, the script is not universal and can be expanded. So, by analogy with Habr, I want to be able to send posts from LJ, arbitrary pages or selected fragments. But I'm not sure that I need it so much to start doing it.