Torrent Download Script with Aria2C on Debian 12 using Command Line Interface Rumi, November 7, 2025 Script Generated using DeepSeek and ChatGPT ============================== aria2_torrent_downloader_v1.0.1-stable.sh ============================== ###################### Script beginging #!/usr/bin/env bash # aria2_torrent_downloader_v1.0.1-stable.sh # Version: 1.0.1-stable # Description: Batch torrent downloader using aria2c with progress and verbose logging. set -euo pipefail VERSION="1.0.1-stable" CONF_FILE="$HOME/.aria2_torrent_downloader.conf" LOG_DIR="${HOME}/.aria2_torrent_downloader_logs" mkdir -p "$LOG_DIR" LOGFILE="${LOG_DIR}/aria2_torrent_downloader_${VERSION}_$(date +%Y%m%d_%H%M%S).log" TMP_URI_LIST="$(mktemp /tmp/aria2_uri_list.XXXXXX)" trap 'rm -f "$TMP_URI_LIST"' EXIT # Check aria2c if ! command -v aria2c >/dev/null 2>&1; then echo "❌ Error: aria2c is not installed or not in PATH." exit 1 fi echo "▶ aria2 Torrent Downloader — version: $VERSION" echo " Verbose log: $LOGFILE" echo # Load / Ask for download directory if [[ -f "$CONF_FILE" ]]; then # shellcheck disable=SC1090 source "$CONF_FILE" fi if [[ -z "${DOWNLOAD_DIR:-}" ]]; then echo "Enter full path for default download folder (e.g. /home/$USER/Downloads/torrents)" read -r -p "Download directory: " user_dir if [[ -z "$user_dir" ]]; then echo "No directory provided. Exiting." exit 1 fi DOWNLOAD_DIR="$(cd "$(dirname "$user_dir")" && pwd)/$(basename "$user_dir")" mkdir -p "$DOWNLOAD_DIR" echo "DOWNLOAD_DIR=\"$DOWNLOAD_DIR\"" > "$CONF_FILE" echo "Saved to config: $CONF_FILE" else echo "Using saved download directory: $DOWNLOAD_DIR" fi echo # Collect torrent URLs declare -a URLS echo "Enter torrent URLs or magnet links one by one." echo "Press Enter on an empty line when done (default = No more)." count=0 while true; do count=$((count + 1)) read -r -p "[$count] Torrent/Magnet URL: " uri [[ -z "$uri" ]] && break URLS+=("$uri") done if [[ ${#URLS[@]} -eq 0 ]]; then echo "No URLs provided. Exiting." exit 0 fi for u in "${URLS[@]}"; do echo "$u" >> "$TMP_URI_LIST" done # Aria2 options ARIA2_OPTS=( --input-file="$TMP_URI_LIST" --dir="$DOWNLOAD_DIR" --max-concurrent-downloads=50 --max-overall-download-limit=0 --max-connection-per-server=16 --split=16 --min-split-size=1M --continue=true --enable-dht=true --bt-enable-lpd=true --seed-time=0 --summary-interval=1 --console-log-level=info --log="${LOGFILE}" --log-level=debug --allow-overwrite=true --no-conf=true ) echo echo "🚀 Starting aria2c download..." echo " Concurrent downloads: 50" echo " Speed limit: Unlimited" echo " Download folder: $DOWNLOAD_DIR" echo aria2c "${ARIA2_OPTS[@]}" EXIT_CODE=$? if [[ $EXIT_CODE -ne 0 ]]; then echo "⚠️ aria2c exited with code $EXIT_CODE. Check log: $LOGFILE" exit $EXIT_CODE fi echo echo "✅ Downloads completed. Creating '.stopped' markers..." for u in "${URLS[@]}"; do if [[ "$u" =~ ^magnet: ]]; then base=$(echo "$u" | sed -n 's/.*dn=\([^&]*\).*/\1/p' | sed 's/%20/ /g') [[ -z "$base" ]] && base=$(echo "$u" | sed -n 's/.*btih:\([A-Za-z0-9]*\).*/\1/p' | cut -c1-10) else base=$(basename "${u%%\?*}") fi [[ -z "$base" ]] && base="unknown_${RANDOM}" match=$(find "$DOWNLOAD_DIR" -maxdepth 1 -iname "*$base*" | head -n1 || true) if [[ -n "$match" ]]; then touch "${match}.stopped" echo "Marked stopped: ${match}.stopped" else touch "${DOWNLOAD_DIR}/${base}.stopped" echo "Marked fallback: ${DOWNLOAD_DIR}/${base}.stopped" fi done echo echo "🎯 All done!" echo "Downloads: $DOWNLOAD_DIR" echo "Logs: $LOGFILE" echo "Change default folder? Edit $CONF_FILE" echo ################## Script Ending Administrations Scripts Aria2DebianDebian 12Torrent