22 lines
562 B
Bash
Executable File
22 lines
562 B
Bash
Executable File
#!/bin/sh
|
|
# 2025 dtb. public domain
|
|
directory="$1"
|
|
alias have='command -v >/dev/null 2>&1'
|
|
xml_url_prefix='https://www.youtube.com/feeds/videos.xml?channel_id='
|
|
if test -z "$2"; then
|
|
printf 'Usage: %s directory channel_id...\n' "$0" >&2
|
|
exit 64 # sysexits(3) EX_USAGE
|
|
fi
|
|
while test -n "$2"; do
|
|
if have curl; then curl=curl
|
|
elif have wget; then curl='wget -O -'
|
|
else curl=false
|
|
fi
|
|
filename="$(printf '%s/%s.xml\n' "$directory" "$2")"
|
|
if ! $curl "$xml_url_prefix""$2" >"$filename"
|
|
then rm -f "$filename"
|
|
else printf '%s\n' "$filename"
|
|
fi
|
|
shift
|
|
done
|