Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2019-01-02 11:11:08 +08:00
commit c857465adc
6 changed files with 86 additions and 82 deletions

View File

@ -1,3 +1,5 @@
bestony translating
10 killer tools for the admin in a hurry
======

View File

@ -1,3 +1,5 @@
bestony translating
Build an interactive CLI with Node.js
======

View File

@ -1,80 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Watch YouTube videos at the Linux terminal)
[#]: via: (https://opensource.com/article/18/12/linux-toy-youtube-dl)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
Watch YouTube videos at the Linux terminal
======
Thought video content was just for your GUI? Think again.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-youtube-dl.png?itok=HYR5vU2a)
We're almost to the end of our 24-day-long Linux command-line toys advent calendar. Hopefully, you've been following along, but if not, start back at [the beginning][1] and work your way through. You'll find plenty of games, diversions, and oddities for your Linux terminal.
And while you may have seen some toys from our calendar before, we hope theres at least one new thing for everyone.
Today we're going to double-down on yesterday's toy, [MPlayer][2], and add in one more, [**youtube-dl**][3].
As its name would imply, **youtube-dl** is a command-line utility for downloading YouTube videos, but it can capture video from a number of other sites as well, and it's a really quite full-featured application with [thorough documentation][4] to make video acquisition easy. A note: please don't use **youtube-dl** in any context that would violate the copyright laws in your jurisdiction.
**youtube-dl** is licensed under a public domain dedication known as [the][5] [Unlicense][5] that's similar to Creative Common's [CC0][6]. There are some interesting [legal opinions][7] out there about where public domain dedication fits into the open source landscape, but it's generally considered compatible with existing open source licenses even by organizations who don't recommend its use.
In its simplest form, we're going to use **youtube-dl** to grab a video for playback in our terminal. First, [install][8] it using a method appropriate for your distribution. For me, in Fedora, it was packaged in my repositories, so installation was as simple as:
```
$ sudo dnf install youtube-dl
```
Then, let's grab a video. YouTube allows you to search by license, so today, we're going to take a look at a fireplace [video][9] from [Gemmy's Videos][10] available under a Creative Commons attribution license. For YouTube videos, you can download with the file ID alone, like this, and we'll specify an output file name as well. I intentionally picked a short video, since long videos can get quite large!
```
$ youtube-dl pec8P5K4s8c -o fireplace.mp4
```
If you didn't install [MPlayer][2] yesterday, go ahead and do that, and you may need to install **libcaca** for your system as well if you did not install it previously. If you just use MPlayer to launch the video from the command line as-is ( **$** **mplayer fireplace.webm** ), it will play, but in a window all of its own; not exactly what we were going for.
First, I set my **libcaca** settings to force it to use **ncurses** **** as the display driver, keeping the output in my terminal, with:
```
$ export CACA_DRIVER=ncurses
```
Then, I zoomed way out in my terminal (the more "pixels", the better), and played the file with the following (forcing the use of **libcaca** and silencing text output from MPlayer):
```
$ mplayer -really-quiet -vo caca fireplace.mp4
```
And, there you go!
![](https://opensource.com/sites/default/files/uploads/linux-toy-youtube-dl.gif)
Do you have a favorite command-line toy that we should have included? It's a little late to submit a suggestion for this year, but we'd still love to feature some cool command-line toys in the new year. Let me know in the comments below, and I'll check it out. And let me know what you thought of today's amusement.
Be sure to check out yesterday's toy, [Listen to the radio at the Linux terminal][2], and come back tomorrow for another!
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/linux-toy-youtube-dl
作者:[Jason Baker][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/jason-baker
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/18/12/linux-toy-boxes
[2]: https://opensource.com/article/18/12/linux-toy-mplayer
[3]: https://rg3.github.io/youtube-dl/
[4]: https://github.com/rg3/youtube-dl/blob/master/README.md#readme
[5]: https://unlicense.org/
[6]: https://creativecommons.org/share-your-work/public-domain/cc0/
[7]: https://opensource.org/faq#public-domain
[8]: https://github.com/rg3/youtube-dl/blob/master/README.md#installation
[9]: https://www.youtube.com/watch?v=pec8P5K4s8c
[10]: https://www.youtube.com/channel/UCwwaepmpWZVDd605MIRC20A

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (LazyWolfLin)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,80 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Watch YouTube videos at the Linux terminal)
[#]: via: (https://opensource.com/article/18/12/linux-toy-youtube-dl)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
在 Linux 终端上观看 YouTube 视频
======
认为视频只能在 GUI 下看么?再想想。
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-youtube-dl.png?itok=HYR5vU2a)
我们即将结束为期 24 天的 Linux 命令行玩具日历。希望你一直在看,如果没有,请回到[这里][1]开始,自己试试。你会发现 Linux 终端有很多游戏,消遣和奇怪的东西。
虽然你之前可能已经看过我们日历中的一些玩具,但我们希望对每个人至少有一个新事物。
今天我们要在昨天的玩具 [MPlayer][2] 上再加上一个 [**youtube-dl**][3]。
正如其名称所暗示的那样,**youtube-dl** 是一个用于下载 YouTube 视频的命令行程序,但它也可以从其他许多站点下载视频,而且它是一个有着[丰富文档][4]的功能齐全的程序,从而使视频获取变得容易。注意:请勿在任何违反你所在司法辖区的版权法的情况下使用 **youtube-dl**
**youtube-dl** 使用的是 [Unlicense][5] 这个公共领域许可,类似于 Creative Common 的 [CC0][6]。这里还有哪些公共领域贡献适用于开源领域的[法律意见][7],但它通常被认为与现有的开源许可证兼容,即使是不推荐使用它的组织也是如此。
最简单地,我们将使用 **youtube-dl** 来获取视频以便在终端中播放。首先,使用适用于你发行版的方法[安装][8]它。对我来说,在 Fedora 中,它被打包在我的仓库中,因此安装非常简单:
```
$ sudo dnf install youtube-dl
```
然后获取一个视频。YouTube 允许你按照许可证进行搜索,所以今天我们将根据知识共享署名许可证查看来自 [Gemmy's Videos][10] 中的壁炉[视频][9]。对于 YouTube 视频,你可以像这样用文件 ID 下载,我们也可以指定输出文件名。我故意选择了一个短片,因为长视频会变得很大!
```
$ youtube-dl pec8P5K4s8c -o fireplace.mp4
```
如果你昨天没有安装 [MPlayer][2],请继续安装好,如果你之前没有安装 **libcaca** 则需要安装它。如果你直接用 MPlayer 在命令行中播放视频 ( **$****mplayer fireplace.webm** ),它能够播放,但是会在一个自己的窗口中,这不是我们想要的。
首先,我设置将 **libcaca** 强制使用 **ncurses** 作为显示驱动,使输出保持在我的终端:
```
$ export CACA_DRIVER=ncurses
```
然后,我放大了终端(“像素”越多越好),并使用以下命令播放文件(强制使用 **libcaca**并静默 MPlayer 的文本输出):
```
$ mplayer -really-quiet -vo caca fireplace.mp4
```
这就完成了!
![](https://opensource.com/sites/default/files/uploads/linux-toy-youtube-dl.gif)
你有特别喜欢的命令行小玩具需要我介绍的吗?提交今年的建议有点晚了,但我们仍然希望在新的一年里有一些很酷的命令行玩具。请在下面的评论中告诉我,我会查看的。让我知道你对今天的玩具有何看法。
一定要看看昨天的玩具,[在 Linux 终端收听广播][2],明天还要再来!
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/12/linux-toy-youtube-dl
作者:[Jason Baker][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/jason-baker
[b]: https://github.com/lujun9972
[1]: https://opensource.com/article/18/12/linux-toy-boxes
[2]: https://opensource.com/article/18/12/linux-toy-mplayer
[3]: https://rg3.github.io/youtube-dl/
[4]: https://github.com/rg3/youtube-dl/blob/master/README.md#readme
[5]: https://unlicense.org/
[6]: https://creativecommons.org/share-your-work/public-domain/cc0/
[7]: https://opensource.org/faq#public-domain
[8]: https://github.com/rg3/youtube-dl/blob/master/README.md#installation
[9]: https://www.youtube.com/watch?v=pec8P5K4s8c
[10]: https://www.youtube.com/channel/UCwwaepmpWZVDd605MIRC20A