Initial commit

This commit is contained in:
wn6
2026-05-31 13:41:47 +07:00
commit e424b0ed36
3 changed files with 164 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
BASE_URL="${1}"
OUTPUT_DIR="${2:-.}"
if [ -z "$BASE_URL" ]; then
echo "Usage: $0 <base_url> [output_dir]"
exit 1
fi
# Скачиваем базовый файл
echo "Downloading base file..."
curl -L -f -o "${OUTPUT_DIR}/$(basename "$BASE_URL")" "$BASE_URL"
if [ $? -ne 0 ]; then
echo "Failed to download base file."
exit 1
fi
# Скачиваем части, пока они существуют
i=1
while true; do
PART_URL="${BASE_URL}.${i}"
# Проверяем существование файла через HEAD-запрос
HTTP_CODE=$(curl -L -s -o /dev/null -w "%{http_code}" -I "$PART_URL")
if [ "$HTTP_CODE" -ne 200 ]; then
echo "No more parts found (last checked: ${PART_URL}). Download complete."
break
fi
OUTPUT_FILE="${OUTPUT_DIR}/$(basename "$PART_URL")"
echo "Downloading part ${i}: ${PART_URL}..."
curl -L -f -o "$OUTPUT_FILE" "$PART_URL"
if [ $? -ne 0 ]; then
echo "Failed to download part ${i}: ${PART_URL}"
exit 1
fi
i=$((i + 1))
done
echo "All files downloaded successfully."