Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 08-21-2020, 09:00 PM   #1
shoelesshunter
copyleft librarian
shoelesshunter began at the beginning.
 
shoelesshunter's Avatar
 
Posts: 58
Karma: 10
Join Date: Nov 2015
Device: KV
script to auto-add books to a secondary library

My workflow covers two essential libraries. "Top Calibre" contains all the hand-tagged and curated books I actually read (or intend to read). The other "Calibre Trunk" is a staging library for everything I download from various sources. All books go to the trunk library where they are scanned for eligible placement into Top Calibre.

I tried to use Calibre's built-in auto-add feature, but it threw two snags.

First, Calibre must be running for it to work. This is a problem for me as I don't even use a GUI on this laptop which has only 2G RAM. Launching Calibre is a resource intensive task for me, especially when the first thing it tries to do is import a hundred books at once.

Second, there is no option to select which library one would like the books added to. Actually, when the feature was enabled, the books were added to whichever library I was using at the time. No good.

Here is a simple script to automate this via a simple cron job which runs every 20 minutes (on my system).

Code:
#!/bin/bash

# This script adds books downloaded by autodl-irssi into a
# secondary Calibre Library then cleans up after itself.
# Meant to be run as a cron replacement to Calibre's import/delete functionality.
# Note-- the files in the target directories are  copies of what is still seeding.
# Do not run this script against seeding files if you care about ratio. 

# First we define our download directories
MAM=~/torrents/rtorrent/complete/MAM-Books
IPT=~/torrents/rtorrent/complete/IPT-Books
TD=~/torrents/rtorrent/complete/TD-Books
TL=~/torrents/rtorrent/complete/TL-Books
AR=~/torrents/rtorrent/complete/AR-Books

# We check to see if Calibre is running and abort if it is.

if pgrep -f "calibre" > /dev/null

then
       :
else

# We import and delete our books

find $MAM $IPT $TD $AR $TL -regextype posix-extended -regex \
                '.*\.(epub|epub3|mobi|azw|azw3|azw4|pdf|chm|djvu|lrf|fb2|lit|pdb)$' \
                -exec calibredb --library-path=~/Books/CalibreTrunk add --duplicates {} \; \
                -exec rm -rf {} \; &&

# We take out the trash

find $MAM $IPT $TD $AR $TL -regextype posix-extended -regex \
                '.*\.(txt|kfx|jpg|jpeg|opf|cbz|cbr|rar|zip|png)$' \
                -exec rm -rf {} \; &&

# We clean up after ourselves

find $MAM $IPT $TD $AR $TL -mindepth 1 -type d -empty -delete

fi

exit

Improve and/or enjoy.
shoelesshunter is offline   Reply With Quote
Old 08-21-2020, 09:41 PM   #2
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,190
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
I'm tempted to ask what type of public domain or freely distributable books you are downloading using BitTorrent but sadly, the answer to that is very few are available.

Taking a look at the script, it would appear that MAM is short for MyAnonymouse, IPT is short for IPTorrents, TD is short for Torrent Day, TL is short for Torrent Leech and AR is short for Alpha Ratio.

Hoist the sails, run out the guns and run up the Jolly Roger.

Hmmm... @shoelesshunter's avatar is a skull with crossed quills. Honesty in advertising.
DNSB is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vanishing auto add books during import, books left behind in auto add folder jataadroid Library Management 9 01-14-2018 11:43 PM
calibre library is the same with direcotry to auto add angarato_surion Library Management 13 06-30-2017 11:59 AM
Auto Add Books Paltieldav Library Management 6 03-04-2016 12:53 PM
Auto-Add Metadata When Adding Books pghaworth Calibre 8 11-11-2014 01:59 PM
Trying to add large library of books - add books seems to have hung nicknefarious Library Management 1 06-18-2012 09:32 AM


All times are GMT -4. The time now is 09:21 PM.


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