Move config files to dot-dir in userhome.

Add notebook supports.
Do not create sub-directories.
This commit is contained in:
Maks Snegov 2012-10-07 15:26:44 +04:00
parent 1fa1606f0d
commit 64fa37f0af

View File

@ -3,10 +3,25 @@
if [ -z "$1" ]; then
exit
fi
URL=$1
TMP_DIR=`mktemp -d /tmp/nevernote.XXXXXX`
NEVERNOTE_DIR="/mnt/tabula/nevernote/read"
if [ -n "$2" ]; then
NOTEBOOK=$2
else
NOTEBOOK='read'
fi
TODO='no'
if [ -n "$3" ]; then
echo $3 | grep todo > /dev/null 2>&1
if [ "$?" -eq 0 ]; then
TODO='yes'
fi
fi
TMP_DIR=`mktemp -d $HOME/.nevernote/nevernote.XXXXXX`
NEVERNOTE_DIR="/mnt/tabula/nevernote/$NOTEBOOK"
TODO_DIR="/mnt/tabula/nevernote/todo"
## Take page title
echo
@ -14,28 +29,28 @@ echo `date '+%H:%M:%S'`
echo $URL
## Check if URL is forbidden to download
grep -x "$URL" /tmp/nevernote-list-excluded > /dev/null 2>&1
grep -x "$URL" $HOME/.nevernote/nevernote-list-excluded > /dev/null 2>&1
if [ "$?" -eq 0 ]; then
echo "exclude"
echo $URL >> /tmp/nevernote-error-excluded
echo $URL >> $HOME/.nevernote/nevernote-error-excluded
rm -r $TMP_DIR
exit
fi
## Check if it is downloading now
ps ax | grep "./scripts/nevernote.sh" | awk '{print($7)}' | grep -x "$URL"
if [ "$?" -eq 0 ]; then
echo "downloading now"
rm -r $TMP_DIR
exit
fi
#ps ax | grep "./scripts/nevernote.sh" | awk '{print($7)}' | grep -x "$URL"
#if [ "$?" -eq 0 ]; then
# echo "downloading now"
# rm -r $TMP_DIR
# exit
#fi
## Check downloaded urls for duplicates
#head -qn 1 ${NEVERNOTE_DIR}/*/wget.log | awk '{print($3)}' | grep -x "$URL" > /dev/null 2>&1
grep -x "$URL" /tmp/nevernote-list-downloaded > /dev/null 2>&1
grep -x "$URL" $HOME/.nevernote/nevernote-list-downloaded > /dev/null 2>&1
if [ "$?" -eq 0 ]; then
echo "dublicate"
echo $URL >> /tmp/nevernote-error-dups
echo $URL >> $HOME/.nevernote/nevernote-error-dups
rm -r $TMP_DIR
exit
fi
@ -44,7 +59,7 @@ wget -T 15 -t 5 --user-agent="" -P $TMP_DIR "$URL" > /dev/null 2>&1
INDEX_PAGE=`ls $TMP_DIR`
if [ "$INDEX_PAGE" = '' ]; then
echo "download error"
echo $URL >> /tmp/nevernote-error-404
echo $URL >> $HOME/.nevernote/nevernote-error-404
rm -r $TMP_DIR
exit
fi
@ -92,10 +107,10 @@ while true; do
done
## Download full page
wget -E -H -k -K -p -e robots=off --user-agent="" -T 15 -t 5 -o $TMP_DIR/wget.log -P $TMP_DIR "$URL"
wget -E -H -k -K -p -e robots=off --user-agent="" -T 15 -t 5 -nd -o $TMP_DIR/wget.log -P $TMP_DIR "$URL"
WGET_EXIT_CODE=$?
if [ "$WGET_EXIT_CODE" -ne 0 ]; then
echo $WGET_EXIT_CODE"|"$URL >> /tmp/nevernote-error-wget
echo $WGET_EXIT_CODE"|"$URL >> $HOME/.nevernote/nevernote-error-wget
fi
## Make link for index.html
@ -104,7 +119,7 @@ fi
#ln -s "${INDEX_PATH%.orig}" "$INDEX_PAGE" > /dev/null 2>&1
#if [ "$?" -ne 0 ]; then
# echo Cant\'t link $URL
# echo $URL >> /tmp/nevernote-errors
# echo $URL >> $HOME/.nevernote/nevernote-errors
# rm -r $TMP_DIR
# exit
#fi
@ -115,4 +130,7 @@ echo $URL > $TMP_DIR/URL
mv $TMP_DIR "$NEVERNOTE_DIR/$PAGE_DIR"
echo "saved in $NEVERNOTE_DIR/$PAGE_DIR"
echo $URL >> /tmp/nevernote-list-downloaded
if [ "$TODO" = "yes" ]; then
ln -s "$NEVERNOTE_DIR/$PAGE_DIR" $TODO_DIR
fi
echo $URL >> $HOME/.nevernote/nevernote-list-downloaded