Pustaka Taratsa

Baca teks (EPUB): Script untuk Download Youtube ke .avi

1 bagian

Teks ini diambil langsung dari berkas EPUB; tata letak dan gambar tidak disertakan. Untuk tampilan lengkap, silakan merujuk pada dokumen asli.

Daftar isi
  1. Script untuk Download Youtube ke .avi
  2. Referensi
  3. Pranala Menarik

Script untuk Download Youtube ke .avi

Sumber: https://onnocenter.or.id/wiki/index.php/Script_untuk_Download_Youtube_ke_.avi

Edit file misalnya

$ vi hacktube.sh



Masukan script berikut

#!/bin/sh

# YouTube Videodownloader for those of us, 
# who has no sucking Flash in their browsers.
# If you experience any problems with this script, please
# report them to ivap on SILCNet (https://silcnet.org)
#
# $Id: hacktube.sh,v 0.1.0.9 2007/04/29 00:45:51 ivap Exp $

if [ $# -lt 1 ]; then
   echo -e 1>&2 "Usage: $0 [-f] <url or id>"
   echo -e 1>&2 "Options:\n\t-f   enable ffmpeg postprocessing"
   echo -e 1>&2 "Examples: "
   echo -e 1>&2 "\t$0 http://www.youtube.com/watch?v=injqufD1WZI"
   echo -e 1>&2 "\t$0 injqufD1WZI"
   exit 64
fi

while [ $# -ge 1 ]; do
            case "$1" in
             "-f")
                if ! `which ffmpeg >/dev/null 2>&1`; then
                   echo 1>&2 "ERROR: Install ffmpeg and try again"
                   exit 69
                fi
                with_ffmpeg="true"              
                ;;
             *youtube*)
                vid_url=$1
                ;;
             *)
                vid_url=`echo http://www.youtube.com/watch?v= $1 | sed 's/ //g'`
                ;;
            esac
            shift
done

if ! `which wget >/dev/null 2>&1`; then
   echo 1>&2 "ERROR: Install wget and try again"
   exit 69
fi

f_id=`echo $vid_url | sed 's/.*=//1'`
base_url='http://www.youtube.com/get_video?'
temp_fname=`mktemp html_data.XXXXXX`
if [ $? -ne 0 ]; then
   echo "ERROR: cannot create temp file"
   exit 69
fi

if ! wget -q -O $temp_fname $vid_url; then
   echo "ERROR: could not retrieve requested page"
   rm $temp_fname
   exit 69
fi 

new_url=`cat $temp_fname | grep player2.swf | sed 's/va.*?//1' | sed 's/".*;//g'`
complete=`echo $base_url $new_url| sed 's/ //1'`
rm $temp_fname

if ! wget -O ${f_id}.flv $complete; then
    echo "ERROR: could not retrieve requested video"
    exit 69
fi

#feel free to tune ffmpeg's flags
if [ -n "$with_ffmpeg" ]; then 
   if ffmpeg -acodec mp3 -i ${f_id}.flv ${f_id}.avi; then
         rm ${f_id}.flv
         exit 0
   else
      echo "ERROR: could not convert video"
      rm -f ${f_id}.avi
      exit 69
   fi
fi



Ubah permission

$ chmod +x hacktube.sh

Jalankan

$ ./hacktube.sh http://youtube.com/url.... 

Referensi

Pranala Menarik