#!/bin/sh
#201122 sfs
t=/tmp
C(){
rm -R $t/__main__.py $t/youtube_dl $t/build $t/dist "$HOME"/.cache/pyinstaller
}
C &2>/dev/null

D(){
which pyinstaller2 || sfs-get pyinstaller2
wget -N --no-check-certificate  https://yt-dl.org/downloads/latest/youtube-dl -O $t/youtube-dl &&
    cd $t &&
    unzip $t/youtube-dl 
}
D

[ -d $t/youtube_dl ] &&  rm $t/youtube-dl #&&
    ln -sf /usr/local/share/doc/pra/youtube-dl.spec $t/youtube-dl.spec
cd $t &&
    pyinstaller2 youtube-dl.spec &&
    $t/dist/youtube-dl --version &&
    sudo mv $t/dist/youtube-dl /usr/bin/youtube-dl
C