09 novembre 2009

Scaricare/Vedere megaupload da linux

Ho fatto un semplice script POSIX sh per vedere/scaricare i video da megavideo/megaporn.

Devi solo lanciarlo con gli URL come parametri e metterlo in pipe con un player video (per vederlo) o wget (per scaricarlo).

Ad esempio:

sh get_megavideo_url.sh http://www.megavideo.com/\?v\=IRQSIXFL http://www.megavideo.com/\?v\=H3UFB4IA | xargs wget # Per scaricarli

sh get_megavideo_url.sh http://www.megavideo.com/\?v\=IRQSIXFL http://www.megavideo.com/\?v\=H3UFB4IA | xargs mplayer # Per vederli

Potete scaricare lo script da qui

#!/bin/sh                                                     

# char * urldecode (char data[])
#                               
# Return data urldecoded        
urldecode() {                   
  local bf=""                   
  local cb=""                   
  local tab=""                  
  local hi=0                    
  local le=0                    
  local x=0                     
  for p in $*; do               
    le=${#p}                    
    until [ ${x} -eq ${le} ]; do
    x=$((${x}+1))               
    tmp=$(echo "${p}" | cut -c ${x})
    case "${tmp}" in                
      "%")                          
        if [ ${hi} -eq 0 ]; then    
          hi=$((${hi}+1))           
        else                        
          bf="${bf}${tmp}"          
          hi=0                      
        fi                          
        ;;                          
      "+")                          
        bf="${bf} "                 
        ;;                          
      *)                            
        case ${hi} in               
          0)                        
            bf="${bf}${tmp}"        
            ;;                      
          1)                        
            cb=${tmp}               
            hi=$((${hi}+1))         
            ;;                      
          2)                        
            cb="${cb}${tmp}"        
            bf="${bf}$(printf "\\$(printf "%.3o" "$((0x${cb}))")")"
            hi=0                                                   
            ;;                                                     
        esac                                                       
        ;;                                                         
    esac
    done
  done
  echo "$bf"
}

while [ -n "$1" ]; do
  DID=$(wget -O- -q "$1" | sed -n 's|.*previewplayer/?v=\([[:alnum:]]*\)&width=.*|\1|p')
  URL="http://www.megavideo.com/?v=$DID"

  if curl -s "$URL" | grep -q 'flashvars.hd = "1";'; then # Get HD video
    urldecode "$(wget -O- -q "http://www.megavideo.com/xml/videolink.php?v=$DID" | sed -n 's/.*hd_url="\(\S*\)".*/\1/p')$DID.flv"
  else
    # Use clipnabber to obtain the flv link
    SID=$(wget -O- -q "http://clipnabber.com/?mode=2&txt1=$URL" | sed -n 's/
\(.*\)<\/div>$/\1/p') MV=$(wget -O- -q "$URL" | awk -F \" '/flashvars.(un|k1|k2|s) =/{printf $2 ","}') wget -O- -q "http://clipnabber.com/gethint.php?mode=1&url=$URL&mv=$MV&sid=$SID" | grep -o 'http://\S*\.flv' | sed "s/video\.flv$/$DID.flv/" fi shift done