Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 08-14-2025, 02:41 PM   #1
sup
Zealot
sup began at the beginning.
 
Posts: 106
Karma: 10
Join Date: Sep 2013
Device: Kindle Paperwhite (2012)
How to download news automatically even when you do not keep Calibre always running

The scheduled news downloads only really works when you keep Calibre and your computer running all the time. I do not so until now I would always have to trigger the downloads manually. No more!

This guide assumes you are running linux and systemd. It downloads The Economist, adjust for your recipes.

1) First in calibre, go to Preferences>Sharing>Sharing over the net and
a) check "Run server automatically when calibre starts"
b) in Advanced tab, check "Allow un-authenticated local connections to make changes". Not that this allows any local programs to delete your library over HTTPS (they are allowed to do that already by running something like "rm ~/Library", so not a security hole).

This will ensure a calibre web server is running whenever calibre is running. Calibre does not allow books to be added to it via command line when it is running, unless it is done through the server. This protects the database from corruption.

2) In ~/.config/systemd/user/, create "download_economist.timer"

Code:
[Unit]
Description="Download the economist once a week"

[Timer]
OnCalendar=Thu 18:00:00
Persistent=true

[Install]
WantedBy=timers.target
This will cause the download to occur every week on Thursday at 6 PM. Adjust for your timezone. When your computer is off at that time, it will automatically run when you turn it off.

3) In ~/.config/systemd/user/, create "download_economist.service" (the name before ".service" must be the same as for the timer in step 2))
Code:
[Unit]
Description=Script that downloads the economist into Calibre 

[Service]
Type=oneshot
ExecStart=~/.local/bin/download_economist.sh
Restart=on-failure
RestartSec=900
This will run "~/.local/bin/download_economist.sh" and when there is a failure (economist servers are sometimes overloaded, or if you were offline), it will try again in fifteen minutes until it suceeds (or you turn off the computer, in which case it will not download, but that is unlikely in my setup).

4) The script to download ~/.local/bin/download_economist.sh
Code:
#!/bin/bash
TMP_FILE=/tmp/economist$(date +%Y-%m-%d).kepub.epub
echo $TMP_FILE
if ebook-convert "The Economist".recipe $TMP_FILE --output-profile kobo ; then
        if pgrep -f "/usr/bin/python3 /usr/bin/calibre" >/dev/null; then
                calibredb add $TMP_FILE  --with-library http://127.0.0.1:8080#E-knihy --authors "The Economist"
        else
        calibredb add $TMP_FILE --authors "The Economist"
        fi
        rm $TMP_FILE 
else
    exit 1
fi
This tries to download the news, when it suceeds, checks whether calibre is running. If yes, it uses the server, if not, it adds to the database directly (I have only one database, so I do not specify it). When it does not suceed, it emits an error telling systemd to start again in 15 minutes as per step 3.

If you want another recipe, list them with "ebook-convert --list-recipes", the ebook-convert command needs them to be in the form listed by this command.

It changes the author field to "The Economist". I love calibre, but I just do not understand why it insists it is the author of the news when it is not.

My Library is called E-knihy. Find out what is the name of yours by "calibredb add --with-library http://127.0.0.1:8080#-"

Do not forget to make the file executable (chmod +x).

5) Enable and start everything:
Code:
systemctl --user enable --now download_economist.timer
"systemctl --user list-timers" should now list your unit and tell you how long before it is run. "journalctl --user -u download_economist.service" is useful for debugging as it will show output of your command.

Last edited by sup; Yesterday at 05:06 AM. Reason: add that it will run even when the computer is off at the given time
sup is offline   Reply With Quote
Old 08-14-2025, 11:17 PM   #2
mkgtu
Zealot
mkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolate
 
Posts: 143
Karma: 33000
Join Date: Feb 2010
Device: Currently:Voyage, Oasis 3, Kindle mobile apps, andKindle Fire
I'm on Windows, not Linux, so all this wouldn't work for me anyway. But it all looks a bit complicated. But I'm just curious, as you say, normally you'd have to have your computer on and calibre running in order for news to download. However, even with the above script you'd still have to at least have your computer running. So if the computer is running, why can't you also have calibre running? In my windows setup, I have calibre set to automatically run on Windows startup. And even if the app window itself is not open on the desktop it's still running in the background.

I use a laptop at home and it's always on and hooked up to a monitor. I rarely "take it with me." My problem, and it's probably just a Windows problem, is that Microsoft automatically installs updates once a week and when the computer restarts it doesn't fully load till you enter your password on the welcome screen. So if I'm away for a few days and there's an update my computer is basically locked/disbaled. So I won't get any news downloads.

My dream, unrealistc as it is, would be that one day there'd be a calibre app for android and/or iOS. Even if it weren't a full blown editor, maybe it could at least convert books and fetch news. The point being that my phone is "always on" and always with me. Just a dream, I know.

My secondary wish would be for MIcrosoft to let Windows fully load after an automatic, unattended update without having to re-enter a password or PIN. I've searched for a way to do that but haven't found one. There's nobody at home but me, so I don't have Windows set the ever lock on its own; it only re-locks after an update.

Last edited by mkgtu; 08-14-2025 at 11:22 PM.
mkgtu is offline   Reply With Quote
Advert
Old Yesterday, 12:00 AM   #3
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,784
Karma: 30237628
Join Date: Mar 2012
Location: Sydney Australia
Device: none
These maybe Windows Pro features:
  • I don't enter a password/pin/whatever when Windows boots or restarts - only if I do a Switch User or Sign off
  • I get a notify that updates are ready but they don't get installed until I initiate the restart
Pretty sure I didn't have to install any 'extras' - might have been GPEdit tweaks.

BR
BetterRed is offline   Reply With Quote
Old Yesterday, 02:13 AM   #4
mkgtu
Zealot
mkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolatemkgtu is generous with chocolate
 
Posts: 143
Karma: 33000
Join Date: Feb 2010
Device: Currently:Voyage, Oasis 3, Kindle mobile apps, andKindle Fire
I also get notified about updates and will usually install them manually while I'm present to unlock the computer after the update. But if I don't do that the update will install automatically in the middle of the night. I think you can set it to ignore updates for x number of days but not indefinitely.

As to the pro thing I have a pro license from previous installations but I don't know if I applied it to the current installation. I'll have to check that.


Sent from my SM-G986U1 using Tapatalk
mkgtu is offline   Reply With Quote
Old Yesterday, 05:35 AM   #5
sup
Zealot
sup began at the beginning.
 
Posts: 106
Karma: 10
Join Date: Sep 2013
Device: Kindle Paperwhite (2012)
Quote:
Originally Posted by mkgtu View Post
I'm on Windows, not Linux, so all this wouldn't work for me anyway. But it all looks a bit complicated. But I'm just curious, as you say, normally you'd have to have your computer on and calibre running in order for news to download. However, even with the above script you'd still have to at least have your computer running.
Ah, sorry, I was not clear. I*edited the post to make it clear that it will run on startup even when the computer is turned off at the given time. That is the magic of the systemd timer file (the persisten directive).
sup is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why news-download scheduling requires calibre running non-stop? sup Calibre 11 08-14-2025 02:42 PM
Calibre news automatically deleting kidblue Amazon Kindle 44 10-30-2016 01:39 PM
KindleEar, the Calibre running on GAE, deliver RSS to your kindle automatically. cdhigh Kindle Developer's Corner 15 12-27-2015 08:01 AM
How can you automatically send an scheduled news download to more than one device laridae2 Calibre 1 02-26-2012 10:38 PM
Frequent News Download when calibre is not running Moik Calibre 4 10-14-2010 12:16 PM


All times are GMT -4. The time now is 04:02 PM.


MobileRead.com is a privately owned, operated and funded community.