daily pastebin goal
18%
SHARE
TWEET

Vimeo Video Downloader

a guest Jul 20th, 2011 330 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. #
  3. # Vimeo Downloader
  4. #
  5. # Copyright (C) 2008, 2010  Denver Gingerich
  6. # Copyright (C) 2009  Jori Hamalainen
  7. #
  8. # Permission to use, copy, modify, and/or distribute this software for any
  9. # purpose with or without fee is hereby granted, provided that the above
  10. # copyright notice and this permission notice appear in all copies.
  11. #
  12. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19.  
  20.  
  21. if [ $# -ne 1 ]; then
  22.         echo "Vimeo Downloader v0.3.1"
  23.         echo "by Denver Gingerich (http://ossguy.com/)"
  24.         echo "    with script improvements by Jori Hamalainen"
  25.         echo
  26.         echo "Usage: $0 <vimeo_id|vimeo_URL>"
  27.         exit 1
  28. fi
  29. VIMEO_ID=`echo $1 | awk -F / '{print $NF}'`
  30.  
  31. which wget
  32. if [ $? -eq 0 ]; then
  33.         echo "Using wget..."
  34.         GET_CMD="wget -O -"
  35. else
  36.         which curl
  37.         if [ $? -eq 0 ]; then
  38.                 echo "Using curl..."
  39.                 GET_CMD="curl -L"
  40.         else
  41.                 echo "Could not find wget or curl"
  42.                 exit 2
  43.         fi
  44. fi
  45.  
  46. which perl
  47. if [ $? -eq 0 ]; then
  48.         echo "Using perl..."
  49.         USING_PERL=1
  50. else
  51.         echo "Using sed..."
  52.         USING_PERL=0
  53. fi
  54.  
  55. VIDEO_XML=`${GET_CMD} http://www.vimeo.com/moogaloop/load/clip:${VIMEO_ID}`
  56.  
  57. if [ $USING_PERL -eq 1 ]; then
  58.         REQUEST_SIGNATURE=`echo $VIDEO_XML | perl -p -e 's:^.*?\<request_signature\>(.*?)\</request_signature\>.*$:$1:g'`
  59.         REQUEST_SIGNATURE_EXPIRES=`echo $VIDEO_XML | perl -p -e 's:^.*?\<request_signature_expires\>(.*?)\</request_signature_expires\>.*$:$1:g'`
  60.         CAPTION=`echo $VIDEO_XML | perl -p -e 's:^.*?\<caption\>(.*?)\</caption\>.*$:$1:g'`
  61.         ISHD=`echo $VIDEO_XML |  perl -p -e 's:^.*?\<isHD\>(.*?)\</isHD\>.*$:$1:g'`
  62.  
  63.         if [ ${ISHD} -eq 1 ]; then
  64.                 ISHD="hd"
  65.         else
  66.                 ISHD="sd"
  67.         fi
  68.  
  69.         # caption can contain bad characters (like '/') so don't use it for now
  70.         #FILENAME="${CAPTION}-(${ISHD}${VIMEO_ID}).flv"
  71.  
  72.         #FILENAME="${VIMEO_ID}-${ISHD}.flv"
  73.  
  74.         # Rob edition
  75.         TITLE=`echo ${CAPTION} | perl -p -e 's:[^\w\d\s\-\&]:_:g'`
  76.         FILENAME="${TITLE} (${ISHD}${VIMEO_ID}).flv"
  77.  
  78. else
  79.         REQUEST_SIGNATURE=`echo $VIDEO_XML | sed -e 's/^.*<request_signature>\([^<]*\)<.*$/\1/g'`
  80.         REQUEST_SIGNATURE_EXPIRES=`echo $VIDEO_XML | sed -e 's/^.*<request_signature_expires>\([^<]*\)<.*$/\1/g'`
  81.         ISHD="sd"
  82.         FILENAME=${VIMEO_ID}.flv
  83. fi
  84.  
  85. echo "\nDownloading video ${VIMEO_ID} to ${FILENAME}...\nRequest_signature=${REQUEST_SIGNATURE}\nRequest_signature_expires=${REQUEST_SIGNATURE_EXPIRES}\n"
  86. ${GET_CMD} "http://www.vimeo.com/moogaloop/play/clip:${VIMEO_ID}/${REQUEST_SIGNATURE}/${REQUEST_SIGNATURE_EXPIRES}/?q=${ISHD}" > "${FILENAME}"
  87. echo "Video ${VIMEO_ID} saved to ${FILENAME}"
  88. echo `file "${FILENAME}"`
  89. echo
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top