Created
August 8, 2011 03:51
-
-
Save turicas/1131175 to your computer and use it in GitHub Desktop.
Download a lot of videos from YouTube and merge it - example: talk by @viniciusteles about software problems (7 videos) at AgileBrazil2011
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################### | |
# This script downloads a lot of videos from YouTube and merge them into a # | |
# single .FLV file using mencoder. # | |
# # | |
# Requires Python, wget|curl and mencoder # | |
# Python and wget actually are installed on many GNU/Linux distributions and # | |
# Mac OS (sorry, Windows' users) # | |
# To install mencoder in Ubuntu/Debian, just execute as root: # | |
# aptitude install mencoder # | |
# # | |
# License: GPLv2 # | |
# # | |
# Resources: # | |
# http://www.github.com/rg3/youtube-dl # | |
# http://www.mplayerhq.hu/DOCS/HTML/en/mencoder.html # | |
# # | |
# Written by Álvaro Justen aka Turicas # | |
# Contact me: alvarojusten [no-spam_AT_] gmail [_DOT_no-spam] com # | |
# http://github.com/turicas # | |
# http://twitter.com/turicas # | |
############################################################################### | |
echodate() { | |
echo [$(date +"%Y-%m-%d %H:%m:%S")] $@ | |
} | |
OUTPUT_FILENAME="vinicius-teles_2012-o-ano-em-que-a-terra-parou-porque-o-software-travou.flv" | |
VIDEO_CODES="cwXiF3EH-Tk BUqsqT9WKUI FS3wQ0YGzrw ODl7D2FyZNE aIge6vbEViE 1AAhf00ymEY U9-qFpvQ0tQ" | |
YOUTUBE_DL_URL="https://raw.github.com/rg3/youtube-dl/33d507f1fe828b186dec9b61ff4fc6b5fdcf42b2/youtube-dl" | |
echodate 'Downloading youtube-dl...' | |
if [ ! -z "$(which wget)" ]; then | |
wget -c -t 0 "$YOUTUBE_DL_URL" -O youtube-dl | |
elif [ ! -z "$(which curl)" ]; then | |
curl "$YOUTUBE_DL_URL" > youtube-dl | |
else | |
echodate "You need either wget or curl to download youtube-dl. Exiting..." | |
exit 1 | |
fi | |
chmod +x youtube-dl | |
video_codes_flv="" | |
total_videos=0 | |
for video_code in $VIDEO_CODES; do | |
let total_videos="$total_videos + 1" | |
video_codes_flv="$video_codes_flv $video_code.flv" | |
done | |
echodate 'Starting video downloads...' | |
i=0 | |
for video_code in $VIDEO_CODES; do | |
let i="$i + 1" | |
echodate "Downloading video $i/$total_videos..." | |
./youtube-dl "http://www.youtube.com/watch?v=$video_code" | |
done | |
echodate "Merging videos to '$OUTPUT_FILENAME'..." | |
merge_videos="mencoder -oac pcm -ovc copy -o "$OUTPUT_FILENAME" $video_codes_flv" | |
rm -rf "$OUTPUT" | |
if [ ! -z "$(which mencoder)" ]; then | |
$merge_videos | |
else | |
echodate "Sorry, you don't have mencoder installed. Install it runnig: sudo aptitude install mencoder" | |
echodate "Then, run this command:" | |
echo $merge_videos | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment