User Tools

Site Tools


ubuntu:youtube:download_a_youtube_video

Ubuntu - Youtube - Download a Youtube video

Youtube used to create temporary files in /tmp whenever a video was watched.

The temporary file, named similar to /tmp/FlashXX*/ remained there while the webpage was kept open.

To make a copy of the video was a simple task of copying the temporary file elsewhere:

</code bash> cp /tmp/FlashXX* /videos_to_keep </code>

However, newer versions of flash (since 10.2r152 in Linux) have changed that. The temporary file no longer exists.

The following bash script allows one to download a youtube video.

#!/bin/bash
#
# Download Youtube Video
#
# Two arguments
#   $1 Youtube URL
#   $2 You name for the video
#
 
wget -c --no-check-certificate --user-agent="" $1 -qO- | \
sed 's/\\u0026/\&/g'| \
awk '/fmt_url_map/{gsub(/[\|\"]/,"\n");print}' | \
sed -n "/^fmt_url_map/,/videoplayback/p" | \
sed -e :a -e '$q;N;2,$D;ba' | tr -d '\n' | \
sed -e "s/\(.*\),\(.\)\{1,3\}/\1/;s/\\\//g" | \
wget -c --no-check-certificate --user-agent="" -i - -O $2.flv

After putting in in a file and making it executable just go get your YouTube url and fire off the download. Here's an example.

./ytd.sh 'http://www.youtube.com/watch?v=J---aiyznGQ' keycat

This will make the file keycat.flv in your dir. Use a recent VLC or Mplayer to play the file.

Its very likely that this script will be out of date (broken) soon but hopefully it will be a good blueprint for anyone else in the future.

ubuntu/youtube/download_a_youtube_video.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki