forked from HelpSeeker/CoubDownloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave
More file actions
executable file
·31 lines (30 loc) · 1020 Bytes
/
save
File metadata and controls
executable file
·31 lines (30 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
CMDDIR="$(cd "$(dirname "$0")" && pwd)"
SUBDIR="$1"
if [ -e "$SUBDIR" ]; then
echo "$SUBDIR already exists (completely downloaded, but when?)"
else
if [ -e "~$SUBDIR" ]; then
echo "Saving to ~$SUBDIR"
else
mkdir "~$SUBDIR"
fi
cd "~$SUBDIR"
LIST="../$1.txt"
LOGFILE="../$1.log"
cat "$LIST" | xargs -L1 $CMDDIR/wget_page 2>&1 | tee -a "$LOGFILE" #TODO: optimize it, xargs works slowly
FILESCOUNT=$(ls *.htm* | wc -l)
RECORDSCOUNT=$(cat "$LIST" | wc -l)
echo "$FILESCOUNT/$RECORDSCOUNT files" | tee -a "$LOGFILE"
$CMDDIR/coub.py -k -n -r 1 -l "$LIST" --use-archive saved.txt 2>&1 | tee -a "$LOGFILE"
torsocks $CMDDIR/coub.py -k -n -r 1 -l "$LIST" --use-archive saved.txt 2>&1 | tee -a "$LOGFILE"
if [ $? -eq 0 ]
then
cd ..
mv "~$SUBDIR" "$SUBDIR"
echo "$SUBDIR downloaded successfully (perhaps)"
else
cd ..
echo "~$SUBDIR downloaded partially (check if sufficient disk space)"
exit 1
fi
fi