Created
September 9, 2023 18:27
-
-
Save 0scvr/67ed81503c270e24cd9634b009361c7c to your computer and use it in GitHub Desktop.
Shell script to download a list of songs from Youtube Music. Requires "gytmdl" to function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
FAILCTR=0 | |
# Check if a file argument is provided | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <url_list_file>" | |
exit 1 | |
fi | |
url_list_file="$1" | |
# Check if the file exists | |
if [ ! -f "$url_list_file" ]; then | |
echo "Error: File '$url_list_file' not found." | |
exit 1 | |
fi | |
# Assign file descriptor 3 to read input from input file | |
exec 3< $url_list_file | |
# Read URLs from the file line by line and run gytmdl for each | |
while IFS= read -u 3 -r url; do | |
echo "Downloading: $url" | |
gytmdl "$url" | |
gytmdl_exit_status=$? | |
if [ $gytmdl_exit_status -ne 0 ]; then | |
echo "Error downloading: $url" | |
# Increment the error counter | |
FAILCTR=$((counter + 1)) | |
fi | |
# Sleep for 10s to avoid rate-limiting | |
sleep 10 | |
done | |
echo "Total failed executions: $FAILCTR" | |
echo "All downloads completed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment