Skip to content

Instantly share code, notes, and snippets.

@ingridstevens
Created January 20, 2020 19:38
Show Gist options
  • Save ingridstevens/33fb1f89e0b5f1cb236d5ffe3375dcfe to your computer and use it in GitHub Desktop.
Save ingridstevens/33fb1f89e0b5f1cb236d5ffe3375dcfe to your computer and use it in GitHub Desktop.
#!/bin/bash
# converts and saves youtube video to mp3
function convert_to_mp3() {
#ensure the video is downloaded to the correct location (youtube folder in Downloads)
if [ -d "~/Downloads/youtube" ]; then
cd ~/Downloads/youtube
else
# if there is no youtube folder in Downloads, make one
mkdir ~/Downloads/youtube
cd ~/Downloads/youtube
fi
#download youtube audio into the folder ~/Downloads/youtube
youtube-dl --extract-audio --audio-format mp3 $1
}
#prints a kitty!!
function kitty() {
echo '
|\__/,| (`\
_.|o o |_ ) )
-(((---(((--------'
}
#print a bird
function bird() {
echo "
__
( o>
///\
\V_/_
"
}
@ingridstevens
Copy link
Author

ingridstevens commented Jan 20, 2020

This shell script includes a function which enables you to save the audio from a youtube video on to your computer.

To run, you first need to source the file, which can be done from any directory so long as ~ is used before the file path:
$ source ~/.youtube_downloader.sh

Then to run the youtube converter (which can be done from any directory after sourcing), run it (with any youtube URL):
$ convert_to_mp3 https://www.youtube.com/watch?v=B7UmUX68KtE

Then look for the file in
~/Downloads/youtube

You can also run $ kitty to print a friendly kitty
or run $ bird to put a bird on it

and if you want a kitty looking at a bird, run $ bird && kitty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment