Friday, November 05, 2010

download link from vimeo

Initially there was a requirement that we make the videos of MoL downloadable. P and I checked out various ways to do it from vimeo itself, since uploading duplicate copies to dl.radiosai.org would be not only tedious, but also tough on the server! Guided by this shell script, where he uses curl or wget to retrieve
http://www.vimeo.com/moogaloop/play/clip:${VIMEO_ID}/${REQUEST_SIGNATURE}/${REQUEST_SIGNATURE_EXPIRES}/?q=sd" > ${VIMEO_ID}.flv
where he gets REQUEST_SIGNATURE and REQUEST_SIGNATURE_EXPIRES from

VIDEO_XML=`${GET_CMD} http://www.vimeo.com/moogaloop/load/clip:${VIMEO_ID}`
REQUEST_SIGNATURE=`echo $VIDEO_XML sed -e 's/^.*\([^<]*\)<.*$/\1/g'`
REQUEST_SIGNATURE_EXPIRES=`echo $VIDEO_XML sed -e 's/^.*\([^<]*\)<.*$/\1/g'`
P made a very elegant PHP5 script based on
$xml = simplexml_load_file("http://www.vimeo.com/moogaloop/load/clip:$id");
$request_signature = $xml->request_signature;
$request_signature_expires = $xml->request_signature_expires;
$downloadurl = "http://www.vimeo.com/moogaloop/play/clip:$id/$request_signature/$request_signature_expires/?q=sd";
Unfortunately our server did not have PHP5, and PHP4.x did not have the simplexml functions. So I modified it to use curl using the code example from this page and using the value_in() example from this page.
$xml = get_html("http://www.vimeo.com/moogaloop/load/clip:$id");
$request_signature = value_in("request_signature", $xml) ;
$request_signature_expires = value_in("request_signature_expires", $xml) ;
$downloadurl = "http://www.vimeo.com/moogaloop/play/clip:$id/$request_signature/$request_signature_expires/?q=sd";
echo "<p align = \"center\">";
echo "<a href=\"";
echo $downloadurl;
echo "\">Right-click here and choose 'Save Link As...' or 'Save Target As...'</a>";
Attempls to avoid the 'right-click instruction' did not work, since the vimeo server sends the video as mp4 without a Content-Disposition attachment header, and redirects don't conserve headers. Finally, of course, the script was not used due to non-technical reasons....

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete