Skip to content

moon004/youtube-dl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

youtube-dl

Go tool to download videos from youtube, with quality and format selection

NOTE: YouTube has changed their code so that url's signature need to be deciphered, and they rotate the ciphering code quite often. As such, this tool won't be able to download the video files anymore.

Since I'm not actively using it I won't bother working around it (the ciphering code is in youtube js player file). If you need to download youtube videos, I recommend https://rg3.github.io/youtube-dl/

Install

(sudo) go get github.com/lepidosteus/youtube-dl

Your can then start using it using youtube-dl

youtube-dl http://www.youtube.com/watch?v=xjfsmKmK9qc

Automatic naming

If used in the output path, "%author%" and "%title%" will be replaced by their value (respectively the uploader's name and the video's title)

youtube-dl -output "%title%.mp3" http://www.youtube.com/watch?v=xjfsmKmK9qc

Usage

youtube-dl [-verbose -mp3 -overwrite -output /p/a/t/h -quality list -format list] videoId|url

Examples:

youtube-dl http://www.youtube.com/watch?v=xjfsmKmK9qc

youtube-dl youtu.be/xjfsmKmK9qc

youtube-dl xjfsmKmK9qc

This video has highres and 1080p version, but we can ask for 720p only:

youtube-dl -quality hd720 9dgSa4wmMzk

This one will fail, as there is no 720p version available for this video

youtube-dl -output learning_go.mp4 -quality hd720 -format mp4 xjfsmKmK9qc

This, however, will work and download the video in the next best quality (medium)

youtube-dl -output learning_go.mp4 -quality hd720,max -format mp4 xjfsmKmK9qc

Video ID detection

The parsing tries to be smart about finding out what the video's ID is, you can give it an url, an id, an embed code fragment, ... And it will do its best.

MP3 convertion

If ffmpeg is installed, it is possible to extract the audio stream to an mp3 file on the fly. Either pass the -mp3 parameter, or give an output path ending in .mp3

youtube-dl -mp3 http://www.youtube.com/watch?v=xjfsmKmK9qc

youtube-dl -output "audio.mp3" http://www.youtube.com/watch?v=xjfsmKmK9qc

Parameters

ParameterDefault valueAllowed valuesExample
-overwrite
-overwrite=VALUE
falsetrue
false
-overwrite
if true, the destination file will be overwritten if it already exists
-verbose
-verbose=VALUE
falsetrue
false
-verbose
if true, various status messages will be shown
-mp3
-mp3=VALUE
falsetrue
false
-mp3
if true, the file's audio stream will be converted to an mp3 file
-audio-bitrate-audio-bitrate 00
any positive number
-audio-bitrate 128
The bitrate to use for audio files when converting to mp3. If set to 0 (which is the default) the bitrate will be set automatically depending on the quality of the downloaded video file
-output VALUE./video.%format%a valid path
Tokens:
%format%
%author%
%title%
-output "$HOME/funny_video.%format%"
path where to write the downloaded file
Use %format% for dynamic extension depending on format selected (eg: 'video.%format%' would be written as 'video.mp4' if the mp4 format is selected).
%author% and %title% will be replaced by the uploader's name and the video's title, respectively.
Use the .mp3 extension to convert the video to an mp3 file on the fly (eg: -ouput 'audio.mp3')
-quality VALUE[,VALUE...]hd720,maxhighres
hd1080
hd720
large
medium
small
min
max
-quality small,min
comma separated list of desired video quality, in decreasing priority. Use 'max' (or 'min') to automatically select the best (or worst) possible quality available for this video; exemple: '-quality hd720,max': select hd720 quality, if not available then select the best quality available
-format VALUE[,VALUE...]mp4,flv,webm,3gpmp4
flv
webm
3gp
-format mp4,flv
comma separated list of desired video format, in decreasing priority

About

Go tool to download videos from youtube

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%