This add-on is to:
bypass certification checking for youtude-dl (2015.04.26) on OSX (10.10.3)pass through proxy (MU proxy)- download the best quality of
audio
orvideo
- save to
~/Music/youtube-dl
note Since the latest update of youtube-dl (2015.08.23) and OSX (10.10.4), there is no need to bypass certificate anymore. The proxy also seems to be fixed (by importing system proxy.. maybe). However, the options will remain until I'm sure to take them out later.
Only youtube-dl is needed now.
pip install --upgrade youtube-dl
sudo nano ~/.bash_profile
# youtube-dl
# due to certification error, this alias is to bypass
chk-ytdl-dir() {
if [ ! -d ~/Music/youtube-dl ]; then
mkdir ~/Music/youtube-dl
echo "created ~/Music/youtube-dl"
fi
}
ytdl() {
## checking
testlen=$1
if [[ $# -gt 2 ]]; then
echo "Only 2 arguments are allowed!"
return 1
fi
if [[ ${#testlen} -gt 4 ]]; then
echo "Maximum length of option is 4.. (-sph or -vph)"
return 1
fi
if [[ $1 == *"s"* && $1 == *"v"* ]]; then
echo "Could not download both song and video at once!"
return 1
fi
## downloading
curdir="$PWD"
if [[ $1 != *"h"* ]]; then
chk-ytdl-dir
cd ~/Music/youtube-dl/
else
echo "Download to current path.."
fi
if [[ $1 == *"s"* ]]; then
echo "Downloading song.."
if [[ $1 == *"p"* ]]; then
echo "With proxy.."
youtube-dl -o "%(title)s.%(ext)s" -f "m4a" --proxy "" --no-check-certificate $2
else
youtube-dl -o "%(title)s.%(ext)s" -f "m4a" --no-check-certificate $2
fi
elif [[ $1 == *"v"* ]]; then
echo "Downloading video.."
if [[ $1 == *"p"* ]]; then
echo "With proxy.."
youtube-dl -o "%(title)s.%(ext)s" -f "best" --proxy "" --no-check-certificate $2
else
youtube-dl -o "%(title)s.%(ext)s" -f "best" --no-check-certificate $2
fi
else
echo "No satisfied parameters filled.."
echo "Please use -s for song, -v for video, -p if proxy and -h to save to current path."
fi
cd $curdir
}
option:
-s
download song.-v
download video.-p
if being behind MU proxy.-h
download to current path.
youtube link: https://www.youtube.com/watch?v=Iwc81dpA008
ytdl -s https://www.youtube.com/watch?v=Iwc81dpA008
ytdl -sp https://www.youtube.com/watch?v=Iwc81dpA008
ytdl -vh https://www.youtube.com/watch?v=Iwc81dpA008
ytdl -vph https://www.youtube.com/watch?v=Iwc81dpA008
- Cannot download both song and video at once!
.m4a
is supposed to be best format, but recently is being substituted by.webm
. Anyway, I prefer.m4a
because it's more widely supported.- Converter to
.mp3
and.m4a
will be included in the future.
Awesome! Now enjoying with cmus!