Skip to content

Instantly share code, notes, and snippets.

@deafmute1
Last active October 26, 2019 06:31
Show Gist options
  • Save deafmute1/31334d5f659b50f48efcd92406a49a8e to your computer and use it in GitHub Desktop.
Save deafmute1/31334d5f659b50f48efcd92406a49a8e to your computer and use it in GitHub Desktop.
automagically handles importing of ebooks from set folders (from deluged) and associated jobs
#!/bin/bash
#automagically handles importing of ebooks from set folders (from deluged)
import=/mnt/media/Media/Calibre/CalibreImport
download=/mnt/data/torrent/download
httplib=http://localhost:8080/#CalibreLib
physlib=/mnt/media/Media/Calibre/CalibreLib
media=/mnt/media/Media
echo stopping calibre-web
systemctl stop calibre-web.service
echo rsync $download/{manga,books} to $import
#rsync -a --progress --ignore-existing --files-from=<(find $download/manga -mmin +60 -type f -exec basename {} \;) $download/manga/ $import
#rsync -a --progress --ignore-existing --files-from=<(find $download/books -mmin +60 -type f -exec basename {} \;) $download/books/ $import
find $download/{manga,books} -type f -mmin +60 -mmin -130 -exec rsync -a --progress --ignore-existing {} $import \;
sleep 10
echo rsync $download/manga to $media/Manga
find $download/manga -type f -mmin +60 -mmin -130 -exec rsync -a --progress --ignore-existing {} $media/Manga \;
sleep 10
echo moving $import/wildcard to $import
cd $import
find . -mindepth 2 -type f -print -exec mv {} . \;
cd /
sleep 10
if [ "$(ls -A $import)" ]; then
echo importing $import via calibredb add
calibredb add -r "$import" --library-path="$physlib"
echo cleaning up $import
rm -rfv $import/*
fi
echo restarting calibre-web
systemctl start calibre-web.service
echo finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment