Last active
January 3, 2016 04:58
-
-
Save daktak/8412182 to your computer and use it in GitHub Desktop.
post processing script for Mylar (after)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#mylar post processing | |
# | |
CALIBRE_PATH=/usr/bin | |
EXPECTED_ARGS=5 | |
PORT="25" | |
SERVER="localhost" | |
ENCRYPTION_METHOD="NONE" | |
KINDLE_EMAIL="[email protected]" | |
FROM_EMAIL="user@email | |
PROFILE="kindle_pw" | |
OUTPUT_FORMAT="mobi" | |
if [ $# -lt $EXPECTED_ARGS ] | |
then | |
echo "Usage: `basename $0` {arg}" | |
cat <<'END_HEREDOC' | |
1 file name nzb | |
2 directory and name of file from nzb | |
3 cbr filename | |
4 cbr directory and name - use this | |
5 metadata | |
END_HEREDOC | |
exit 1 | |
fi | |
# Only process successfully completed downloads | |
if [ $# -gt 4 ] | |
then | |
echo "`basename $0`: Converting $3 to $OUTPUT_FORMAT...." | |
#$CALIBRE_PATH/calibredb add --one-book-per-directory --recurse "$4" | |
in=$4 | |
out=${4%.*}.$OUTPUT_FORMAT | |
xvfb-run $CALIBRE_PATH/ebook-convert "${in}" "${out}" --output-profile $PROFILE | |
RC=$? | |
if [ $RC -eq 0 ] | |
then | |
echo "`basename $0`: Sending to Kindle...." | |
#cd $1; | |
zout=${4%.*}.zip | |
zip "${zout}" "${out}" | |
$CALIBRE_PATH/calibre-smtp -r $SERVER --port $PORT -e $ENCRYPTION_METHOD -v $FROM_EMAIL $KINDLE_EMAIL 'Attached' -a "${zout}" | |
RC=$? | |
if [ $RC -eq 0 ] | |
then | |
echo "`basename $0`: Success!" | |
exit 0 | |
else | |
echo "`basename $0`: Failed to send to Kindle" | |
exit 1 | |
fi | |
else | |
echo "`basename $0`: Failed to convert $1 to $OUTPUT_FORMAT (RC=$RC)...." | |
exit 1 | |
fi | |
fi | |
else | |
echo "`basename $0`: Incomplete download detected (RC=$7 || 0 = OK, 1=failed verification, | |
2=failed unpack, 3=1+21) removing..." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment