diff --git a/README.md b/README.md index ae159c0..45621bd 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,20 @@ Arguments: output_directory Directory where the resulting MP3 will be saved. ``` +### tdl +Automates downloading a list of URLs from a text file using tiddl. + +```text +Usage: ./tdl [FILE] + +Arguments: + FILE Path to a text file containing one URL per line. + +Options: + --help Display this help message and exit. +``` + ## Requirements - ffmpeg (with libmp3lame support) - bash +- [tiddl](https://github.com/oskvr37/tiddl) (for tdl script) diff --git a/tdl b/tdl new file mode 100755 index 0000000..af1b150 --- /dev/null +++ b/tdl @@ -0,0 +1,32 @@ +`#!/bin/bash + +show_help() { + echo "Usage: tdl [FILE]" + echo "Download a list of URLs from a file using tiddl." + echo "" + echo "Arguments:" + echo " FILE Path to a text file containing one URL per line." + echo "" + echo "Options:" + echo " --help Display this help message and exit." +} + +if [[ $# -eq 0 ]] || [[ "$1" == "--help" ]]; then + show_help + exit 0 +fi + +INPUT_FILE="$1" + +if [[ ! -f "$INPUT_FILE" ]]; then + echo "Error: File '$INPUT_FILE' not found." + exit 1 +fi + +while IFS= read -r url || [[ -n "$url" ]]; do + # Skip empty lines and comments + [[ -z "$url" || "$url" =~ ^[[:space:]]*# ]] && continue + # Trim whitespace + url=$(echo "$url" | xargs) + tiddl download url "$url" +done < "$INPUT_FILE"