In order to use this script, you need to do certain things in advance –
1. Download youtube-dl, a script which allows you to download videos
https://github.com/rg3/youtube-dl
2. Install ffmpet: an audio/video conversion tool.
Ubuntu users can run the following commands –
1 | apt-get install ffmpeg libavcodec-extra-53 |
Note: More details can be found here.
Usage Example: –
1 | . /musicdownloader .sh http: //www .youtube.com /watch ? v =8tHu-OwzwPg BereketMengstead-mizerey.mp3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #!/bin/bash downloader=` which youtube-dl` ffmpeg=` which ffmpeg` bitrate=192000 ARGC=$ # LINK=$1 FILENAME=$2 SAVEDFILE=$( basename $0)_mymusic123.mp4 if [ $ARGC - ne 2 ]; then echo "Usage: $(basename $0) url-link output-file" exit fi $downloader -f 18 $LINK -o $SAVEDFILE && $ffmpeg -i $SAVEDFILE -f mp3 -ab $bitrate -vn $FILENAME if [ $? - eq 0 ]; then echo "File saved in " $FILENAME rm $SAVEDFILE fi |