#!/bin/bash # Libgen EN-download queue for a section (sec08 pattern, 2026-09-26). # Usage: tools/lgdl-queue.sh # e.g. downloads/09- # lines: " " # 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 "; 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"