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
audioorvideo - 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-dlsudo 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:
-sdownload song.-vdownload video.-pif being behind MU proxy.-hdownload 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!
.m4ais supposed to be best format, but recently is being substituted by.webm. Anyway, I prefer.m4abecause it's more widely supported.- Converter to
.mp3and.m4awill be included in the future.
@titipata I didn't realize that there is a built-in feature from youtube-dl itself that works with both
full urlandonly video code. Right now it's fine by using either full link or just video code (Iwc81dpA008).