[READ-ONLY] Mirror of https://github.com/mrgnw/scripts.
1#!/usr/bin/env zsh
2
3local input_file=${1:-inputs.txt}
4
5# Check if input file exists
6if [[ ! -f "$input_file" ]]; then
7 echo "Input file '$input_file' not found."
8 return 1
9fi
10
11# Read URLs and count them
12local urls=("${(@f)"$(<"$input_file")"}")
13local num_urls=${#urls[@]}
14
15# Set concurrency to the number of URLs
16local concurrency=$num_urls
17
18# Determine the output filename from the first URL (default to basename of the URL)
19local output_file="${urls[1]##*/}"
20
21# Run aria2c with parallel downloads
22aria2c -j "$concurrency" -i "$input_file" -o "$output_file" \
23 --allow-overwrite=true --file-allocation=none
24
25return 0