|
|
- #!/bin/bash
-
- # Check if the user provided a URL as an argument
- if [ $# -eq 0 ]; then
- echo "Usage: $0 <youtube_url> <song_name>"
- exit 1
- fi
-
-
- # Assign the YouTube URL to a variable
- youtube_url="$1"
- shift
-
- # Download the audio using youtube-dl
- youtube_file="$2"
- yt-dlp --extract-audio --audio-format mp3 "$youtube_url" -o "$youtube_file"
-
- # Play the audio using ffmpeg
- vlc "$youtube_file"
-
- # Remove the downloaded file
- rm "$youtube_file"
|