Announcement

Collapse
No announcement yet.

For those who want to download Youtube videos easily

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    For those who want to download Youtube videos easily

    There are many Windoze solutions, on which users click stuff and have their videos downloaded, but I've just noticed that Linux options are all manual and users need to write a bunch of commands. So I wrote this small script to make things easy. You end up needing the command line but it's just 1 command and 2 arguments.
    This avoids you to download the whole mplayer/mencoder stuff, so it's a 1MB solution (ffmpeg+youtube-dl+the script). The first 2 are in the repositories.
    Make it executable and it's good to go. I hope it is of some use for you.

    Code:
    #!/bin/sh
    # Author: Saulo Silva (saulo.cpp AT globo DOT com)
    # This bash script is a simple front-end for 2 programs, which downloads a video from a Youtube URL and saves it in MPEG format.
    # External programs recquired:
    #	- youtube-dl (author: Ricardo Garcia Gonzalez, URL: [url]http://www.arrakis.es/~rggi3/youtube-dl/[/url])
    #	- ffmpeg (author: Fabrice Bellard, URL: [url]http://sourceforge.net/projects/ffmpeg/[/url])
    # Before downloading the source, check if your Linux distro already has it in the repositories.
    # The default encoding options are: 56 kb/s and 22050Hz for audio, 500 kb/s and 320x240 for video.
    # If you don't want a mess of buttons to click nor programs which you don't know what they do, this solution is for you.
    # Distribute and modify this script to suit your needs.
    
    
    if test $# == 2; then
    	URL=$1
    	FILENAME=$2
    	if [ ! -f "$FILENAME" ]; then
    		youtube-dl -o "${FILENAME}.flv" "$URL"
    		ffmpeg -i "${FILENAME}.flv" -ab 56 -ar 22050 -b 500 -s 320x240 "$FILENAME"
    		rm -rf "${FILENAME}.flv"
    		printf "\n"
    		echo "*** `basename $0`: File download and conversion successful. Have fun."
    	else
    		printf "\n"
    		echo "*** `basename $0` error! The file $FILENAME already exists. Plase choose another name to save."
    		exit 1
    	fi
    else
    	printf "\n"
    	echo "*** `basename $0` error! I need 2 arguments. Usage: `basename $0` YOUTUBE_URL FILENAME.mpg"
    	exit 1
    fi
    
    exit 0
Working...
X