27 lines
1.2 KiB
Bash
Executable file
27 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
# Libgen EN-download queue for a section (sec08 pattern, 2026-09-26).
|
|
# Usage: tools/lgdl-queue.sh <section-dir> <queue-file>
|
|
# <section-dir> e.g. downloads/09-<name>
|
|
# <queue-file> lines: "<f_id> <edition_id> <file-name-base>"
|
|
# Per-file: skip-if-exists, timeout 1500, tries=3 (fast-fail under ads.php throttle),
|
|
# unbuffered logs. Pair with lgdl-rounds.sh for cooldown rounds.
|
|
cd /home/dima/jung
|
|
D="$1"; Q="$2"; LOG="$D/queue.log"
|
|
[ -z "$D" ] || [ -z "$Q" ] && { echo "usage: lgdl-queue.sh <section-dir> <queue-file>"; exit 1; }
|
|
echo "=== queue start $(date)" >> "$LOG"
|
|
while read -r f_id ed_id name; do
|
|
[ -z "$f_id" ] && continue
|
|
if ls "$D/$name"*.pdf "$D/$name"*.epub "$D/$name"*.fb2 "$D/$name"*.doc "$D/$name"*.rtf "$D/$name"*.djvu >/dev/null 2>&1; then
|
|
echo "SKIP (exists): $name" >> "$LOG"
|
|
continue
|
|
fi
|
|
rm -f "$D/$name"*.part
|
|
echo "=== $name (f/$f_id) $(date)" >> "$LOG"
|
|
timeout 1500 python3 -u -c "
|
|
import sys; sys.path.insert(0,'tools'); import lgdl
|
|
r = lgdl.download(sys.argv[1], sys.argv[2], sys.argv[3], tries=3)
|
|
sys.exit(0 if r else 1)" "$f_id" "$D" "$name" >> "$LOG" 2>&1
|
|
echo "rc=$? $name" >> "$LOG"
|
|
sleep 2
|
|
done < "$Q"
|
|
echo "=== queue round DONE $(date)" >> "$LOG"
|