mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
translated sources/tech/20151007 How To Download Videos Using youtube-dl In Linux.md
This commit is contained in:
parent
0fdff22824
commit
b63183dc59
@ -1,94 +0,0 @@
|
||||
ictlyh Translating
|
||||
How To Download Videos Using youtube-dl In Linux
|
||||
================================================================================
|
||||
![](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/10/Download-YouTube-Videos.jpeg)
|
||||
|
||||
I know you have already seen [how to download YouTube videos][1]. But those tools were mostly GUI ways. I am going to show you how to download YouTube videos via terminal using youtube-dl.
|
||||
|
||||
### [youtube-dl][2] ###
|
||||
|
||||
youtube-dl is a Python based small command-line tool that allows to download videos from YouTube.com, Dailymotion, Google Video, Photobucket, Facebook, Yahoo, Metacafe, Depositfiles and few more similar sites. It written in pygtk and requires Python interpreter to run this program, it’s not platform restricted. It should run on any Unix, Windows or in Mac OS X based systems.
|
||||
|
||||
The youtube-dl tool supports resuming interrupted downloads. If youtube-dl is killed (for example by Ctrl-C or due to loss of Internet connectivity) in the middle of download, you can simply re-run it with the same YouTube video url. It will automatically resume the unfinished download, as long as a partial download is present in the current directory. Which means, you don’t need a [download][3] manager for resuming downloads.
|
||||
|
||||
#### Installing youtube-dl ####
|
||||
|
||||
If you are running Ubuntu based Linux distribution, you can install it using this command:
|
||||
|
||||
sudo apt-get install youtube-dl
|
||||
|
||||
For any Linux distribution, you can quickly install youtube-dl on your system through the command line interface with:
|
||||
|
||||
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O/usr/local/bin/youtube-dl
|
||||
|
||||
After fetching the file, you need to set a executable permission on the script to execute properly.
|
||||
|
||||
sudo chmod a+rx /usr/local/bin/youtube-dl
|
||||
|
||||
#### Use YouTube-DL to Download Videos: ####
|
||||
|
||||
To download a video file, simply run the following command. Where “VIDEO_URL” is the url of the video that you want to download.
|
||||
|
||||
youtube-dl VIDEO_URL
|
||||
|
||||
#### Download YouTube Videos in Multiple Formats: ####
|
||||
|
||||
These days YouTube videos have different resolutions, you first need to check available video formats of a given YouTube video. For that run youtube-dl with “-F” option. It will show you a list of available formats.
|
||||
|
||||
youtube-dl -F http://www.youtube.com/watch?v=BlXaGWbFVKY
|
||||
|
||||
It’s output will be like:
|
||||
|
||||
Setting language
|
||||
BlXaGWbFVKY: Downloading video webpage
|
||||
BlXaGWbFVKY: Downloading video info webpage
|
||||
BlXaGWbFVKY: Extracting video information
|
||||
Available formats:
|
||||
37 : mp4 [1080×1920]
|
||||
46 : webm [1080×1920]
|
||||
22 : mp4 [720×1280]
|
||||
45 : webm [720×1280]
|
||||
35 : flv [480×854]
|
||||
44 : webm [480×854]
|
||||
34 : flv [360×640]
|
||||
18 : mp4 [360×640]
|
||||
43 : webm [360×640]
|
||||
5 : flv [240×400]
|
||||
17 : mp4 [144×176]
|
||||
|
||||
Now among the available video formats, choose one that you like. For example, if you want to download it in MP4 version, you should use:
|
||||
|
||||
youtube-dl -f 17 http://www.youtube.com/watch?v=BlXaGWbFVKY
|
||||
|
||||
#### Download subtitles of videos using youtube-dl ####
|
||||
|
||||
First check if there are subtitles available for the video. To list all subs for a video, use the command beelow:
|
||||
|
||||
youtube-dl --list-subs https://www.youtube.com/watch?v=Ye8mB6VsUHw
|
||||
|
||||
To download all subs, but not the video:
|
||||
|
||||
youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=Ye8mB6VsUHw
|
||||
|
||||
#### Download entire playlist ####
|
||||
|
||||
To download a playlist, simply run the following command. Where “playlist_url” is the url of the playlist that ou want to download.
|
||||
|
||||
youtube-dl -cit playlist_url
|
||||
|
||||
youtube-dl is a versatile command line tool and provides a number of functionalities. No wonder it is such a popular command line tool.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://itsfoss.com/download-youtube-linux/
|
||||
|
||||
作者:[alimiracle][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://itsfoss.com/author/ali/
|
||||
[1]:http://itsfoss.com/download-youtube-videos-ubuntu/
|
||||
[2]:https://rg3.github.io/youtube-dl/
|
||||
[3]:http://itsfoss.com/xtreme-download-manager-install/
|
@ -0,0 +1,93 @@
|
||||
如何在 Linux 中使用 youtube-dl 下载视频
|
||||
================================================================================
|
||||
![](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/10/Download-YouTube-Videos.jpeg)
|
||||
|
||||
我知道你已经看过[如何下载 YouTube 视频][1]。但那些工具大部分都采用图形用户界面的方式。我会向你展示如何通过终端使用 youtube-dl 下载 YouTube 视频。
|
||||
|
||||
### [youtube-dl][2] ###
|
||||
|
||||
youtube-dl 是基于 Python 的命令行小工具,允许你从 YouTube.com、Dailymotion、Google Video、Photobucket、Facebook、Yahoo、Metacafe、Depositfiles 以及其它一些类似网站中下载视频。它是用 pygtk 编写的,需要 Python 解析器来运行,对平台要求并不严格。它能够在 Unix、Windows 或者 Mac OS X 系统上运行。
|
||||
|
||||
youtube-dl 支持断点续传。如果在下载的过程中 youtube-dl 被杀死了(例如通过 Ctrl-C 或者丢失网络连接),你只需要使用相同的 YouTube 视频 URL 再次运行它。只要当前目录中有下载的部分文件,它就会自动恢复没有完成的下载,也就是说,你不需要[下载][3]管理器来恢复下载。
|
||||
|
||||
#### 安装 youtube-dl ####
|
||||
|
||||
如果你运行的是基于 Ubuntu 的 Linux 发行版,你可以使用下面的命令安装:
|
||||
|
||||
sudo apt-get install youtube-dl
|
||||
|
||||
对于任何 Linux 发行版,你都可以通过下面的命令行接口在你的系统上快速安装 youtube-dl:
|
||||
|
||||
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O/usr/local/bin/youtube-dl
|
||||
|
||||
获取到该文件后,为了能正常执行你需要给脚本设置可执行权限。
|
||||
|
||||
sudo chmod a+rx /usr/local/bin/youtube-dl
|
||||
|
||||
#### 使用 youtube-dl 下载视频: ####
|
||||
|
||||
要下载一个视频文件,只需要运行下面的命令。其中 “VIDEO_URL” 是你想要下载视频的 url。
|
||||
|
||||
youtube-dl VIDEO_URL
|
||||
|
||||
#### 以多种格式下载 YouTube 视频: ####
|
||||
|
||||
现在 YouTube 视频有不同的分辨率,首先你需要检查指定的 YouTube 视频可用的视频格式。可以使用 “-F” 选项运行 youtube-dl。它会向你显示出可用的格式。
|
||||
|
||||
youtube-dl -F http://www.youtube.com/watch?v=BlXaGWbFVKY
|
||||
|
||||
它的输出类似于:
|
||||
|
||||
Setting language
|
||||
BlXaGWbFVKY: Downloading video webpage
|
||||
BlXaGWbFVKY: Downloading video info webpage
|
||||
BlXaGWbFVKY: Extracting video information
|
||||
Available formats:
|
||||
37 : mp4 [1080×1920]
|
||||
46 : webm [1080×1920]
|
||||
22 : mp4 [720×1280]
|
||||
45 : webm [720×1280]
|
||||
35 : flv [480×854]
|
||||
44 : webm [480×854]
|
||||
34 : flv [360×640]
|
||||
18 : mp4 [360×640]
|
||||
43 : webm [360×640]
|
||||
5 : flv [240×400]
|
||||
17 : mp4 [144×176]
|
||||
|
||||
在可用的视频格式中,选择你需要的一种。例如,如果你想下载 MP4 格式的,你可以:
|
||||
|
||||
youtube-dl -f 17 http://www.youtube.com/watch?v=BlXaGWbFVKY
|
||||
|
||||
#### 使用 youtube-dl 下载视频字幕 ####
|
||||
|
||||
首先检查是否有可用的视频字幕。使用下面的命令列出视频所有可用的字幕:
|
||||
|
||||
youtube-dl --list-subs https://www.youtube.com/watch?v=Ye8mB6VsUHw
|
||||
|
||||
下载所有字幕,但不包括视频:
|
||||
|
||||
youtube-dl --all-subs --skip-download https://www.youtube.com/watch?v=Ye8mB6VsUHw
|
||||
|
||||
#### 下载整个播放列表 ####
|
||||
|
||||
运行下面的命令下载整个播放列表。其中 “playlist_url” 是你希望下载的播放列表的 url。
|
||||
|
||||
youtube-dl -cit playlist_url
|
||||
|
||||
youtube-dl 是一个多功能的命令行工具,它提供了很多功能。难怪这个命令行工具这么流行。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://itsfoss.com/download-youtube-linux/
|
||||
|
||||
作者:[alimiracle][a]
|
||||
译者:[ictlyh](http://mutouxiaogui.cn/blog/)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://itsfoss.com/author/ali/
|
||||
[1]:http://itsfoss.com/download-youtube-videos-ubuntu/
|
||||
[2]:https://rg3.github.io/youtube-dl/
|
||||
[3]:http://itsfoss.com/xtreme-download-manager-install/
|
Loading…
Reference in New Issue
Block a user