Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

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

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx openvpn pfsense php Postfix powerdns Proxmox RDP SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin Windows 10 XCP-NG zimbra

Topics

Recent Posts

  • “অমুক মাছ কেটে দিনে দশ হাজার কামাচ্ছে”- এসব গল্প এখন অনেকেই শোনায় November 22, 2025
  • Proxmox VM with NAT using Host Server November 21, 2025
  • Torrent Download Script with Aria2C on Debian 12 using Command Line Interface November 7, 2025
  • Install phpsysinfo on Debain Linux November 7, 2025
  • Delete OpenVPN Access Server Logs November 1, 2025
  • Install Monitorix on CentOS 7 October 3, 2025
  • Configure Centos 7 with multiple ip in bridge mode br0 October 3, 2025
  • 1:1 NAT using Iptables on an OpenVPN Server October 2, 2025
  • Openvpn autostart on debian 12 cli client October 2, 2025
  • Site to Site (site 2 site a.k.a S2S) VPN using OpenVPN October 2, 2025

Archives

Top Posts & Pages

  • "অমুক মাছ কেটে দিনে দশ হাজার কামাচ্ছে"- এসব গল্প এখন অনেকেই শোনায়
©2025 Bots! | WordPress Theme by SuperbThemes