Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've setup this function in my bashrc to check for the latest build if the new one is more than 24 hours old and then run it with arguments supplied:

function youtube-dl {

        exe=$HOME/bin/youtube-dl
        link=https://rg3.github.io/youtube-dl/download.html
        url=$(curl -s $link |grep ">sig<" |head -1|sed -e 's/href="/|/g' -e 's/">/|/g'|cut -d"|" -f2)

        fetch=N
        if [ -s "$exe" ] ; then
                ts=$(date "+%s")
                yts=$(stat -c "%Y" $exe)
                [ $(( ($ts-$yts)/(60*60) )) -gt 24 ] && fetch=Y
        else
                fetch=Y
        fi

        if [ "$fetch" = "Y" ] ; then
                url=$(curl -s $url |grep ">sig<" |head -1|sed -e 's/href="/|/g' -e 's/">/|/g'|cut -d"|" -f2)
                echo "Fetching [$url] and deploying to [$exe]"
                curl -s $url -o $exe
                chmod a+x $exe
        fi
        [ -z "$@" ] && $exe --help || $exe $@
}


sounds like a job for a package manager ;-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: