如何下载 YouTube 视频?

cat*_*thy 209 software-recommendation

关于如何从 YouTube 下载视频的说明是什么?


通知:违反服务条款

请注意,遵循以下任何答案,您将违反 YouTube 的服务条款 (TOS)。特别是,从第 5.B. 节:

内容按原样提供给您。您可以仅通过服务提供的功能和这些服务条款允许的方式访问内容以供您参考和个人使用。您不得下载任何内容,除非您在服务上看到 YouTube 为该内容显示的“下载”或类似链接。未经 YouTube 或内容的相应许可方事先书面同意,您不得出于任何其他目的复制、复制、分发、传输、广播、展示、出售、许可或以其他方式利用任何内容。YouTube 及其许可方保留未在服务和内容中明确授予的所有权利。


小智 332

youtube-dl

从官网安装:

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
Run Code Online (Sandbox Code Playgroud)

它也在 Ubuntu 存储库上,但您通常需要使其保持最新状态 sudo youtube-dl -U

pip( / )安装和升级:

sudo -H pip install --upgrade youtube-dl
Run Code Online (Sandbox Code Playgroud)

用法:

youtube-dl YouTube-(or-other-website)-video-link
Run Code Online (Sandbox Code Playgroud)

所以它会下载视频。

您也可以看看这个关于如何使用它非常深入的文档。

  • 我建议在 apt-get 之后立即运行 `sudo youtube-dl -U`。 (10认同)
  • 如果你没有 `aptitude`,你可以使用 `apt-get` 来代替。另请注意,在使用 `sudo aptitude install ...` 或 `sudo apt-get install ...` 命令之前,您应该首先运行 `sudo aptitude update` 或 `sudo apt-get update`。 (7认同)
  • 请记住,youtube-dl 也可以从许多其他站点下载 (3认同)
  • @ThorSummoner 您可以使用 --max-quality 或 --format 选项。示例:youtube-dl http://www.youtube.com/videolink --max-quality 360p 或 youtube-dl http://www.youtube.com/videolink --format mp4 (3认同)
  • 不要乱用 PPA,只需使用`sudo pip install youtube-dl`。@modosansreves 我强烈不同意,程序不应该弄乱包管理器安装的东西。下次官方 repo 升级时,dpkg 可能会因为修改的文件而吓坏了。 (2认同)

Ped*_*ram 84

youtube-dl是下载 YouTube 视频的绝佳工具。安装

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
Run Code Online (Sandbox Code Playgroud)

或使用pippython3-pip):

sudo -H pip install --upgrade youtube-dl
Run Code Online (Sandbox Code Playgroud)

或者来自 Ubuntu 的 repo(旧版本)

sudo apt-get install youtube-dl
Run Code Online (Sandbox Code Playgroud)

然后这样使用它:

youtube-dl [VIDEO_LINK]
Run Code Online (Sandbox Code Playgroud)

要了解有关高级选项的更多信息,请运行

man youtube-dl
Run Code Online (Sandbox Code Playgroud)

或查看文档

原答案

对于 Firefox 用户:

您可以在 Firefox 中安装Video DownloadHelper插件并下载任何嵌入对象,包括 YouTube 视频。

在此处输入图片说明

在此处输入图片说明


Uri*_*era 54

迷你管

安装微型管

Minitube 是一个 YouTube 桌面应用程序。有了它,您可以以一种新的方式观看 YouTube 视频:您输入关键字,Minitube 为您提供无尽的视频流。Minitube 并不是要克隆原始的 YouTube 网络界面,而是旨在创造一种新的类似电视的体验。

它不需要Flash Player。通过此应用程序,您可以观看和下载视频。


截图1

截图2

  • 这不是问题所指的真正内容。你可以从这里下载youtube视频吗? (6认同)
  • 截至 2014 年 5 月,我检查了这个并且 minitube 似乎是一个死项目。较新的 (PAID) 版本是 minitube-ubuntu,您无法免费获得。显然,软件中心的许多评论都表明旧的微型管崩溃了。 (6认同)
  • 这在我的 Ubuntu 13.04 上不起作用,总是在 10 秒后崩溃。 (5认同)

Jeg*_*ggy 31

浏览器插件:http :
//www.clipconverter.cc/addon/

在此处输入图片说明

其他可以使用的网站:

http://www.clipconverter.cc/
http://keepvid.com/
http://www.listentoyoutube.com/

这个软件也很棒:

http://www.4kdownload.com/

在此处输入图片说明

  • 太好了,4k下载很好。愿原力与你同在!! (3认同)

eft*_*lex 29

我认为从 YouTube 下载视频的最简单方法是使用savefrom.net,无需安装任何插件或软件。这是演示如何使用 ss 技巧下载 YouTube 视频的视频。假设您要下载以下视频:

视频下载

在地址栏上,ss在前面添加youtube.com并点击Enter ?

如何

现在您将被重定向到savefrom.net。在右侧,单击要下载的视频质量。

下载

  • 该站点只允许下载小于 200 MB (3认同)
  • 实际上现在我在 2 分钟内下载了 700+ MB 的 H.264 视频。 (2认同)

Tak*_*kat 16

cclive

安装 cclive

我们可以使用这个易于使用的命令行工具从 YouTube 或其他流媒体网站下载免费内容。

cclive主要是一个“视频下载工具”,但它也可以与视频播放器软件一起使用,如“mplayer”,用于查看流视频而不是 Adob​​e Flash 播放器。

要从给定位置下载视频(在 YouTube 上按“共享”按钮以获取视频的 URL)。复制此链接并使用以下命令从终端发出 clive:

cclive -s best http://youtu.be/D6z6hn6wZlg
Run Code Online (Sandbox Code Playgroud)

还有许多其他选项可以控制下载行为,包括选择下载格式的选项,这些选项都在联机帮助页中详细记录。我们还可以将文件中的 URL 列表排入队列。

(将 -f 更改为 -s;不推荐使用 -f)。

仅适用于 Ubuntu 18.10 及更早版本。


nux*_*nux 16

首先,如果您没有wget,请安装它:

sudo apt-get install wget
Run Code Online (Sandbox Code Playgroud)

使用这个 Perl 脚本:

#!/usr/bin/perl -T

use strict;
use warnings;

#
##  Calomel.org  ,:,  Download YouTube videos and music using wget
##    Script Name : youtube_wget_video.pl
##    Version     : 0.38
##    Valid from  : March 2014
##    URL Page    : https://calomel.org/youtube_wget.html
##    OS Support  : Linux, Mac OSX, OpenBSD, FreeBSD or any system with perl
#                `:`
## Two arguments
##    $1 YouTube URL from the browser
##    $2 Prefix to the file name of the video (optional)
#

############  options  ##########################################

# Option: what file type do you want to download? The string is used to search
# in the YouTube URL so you can choose mp4, webm, avi or flv. mp4 seems to
# work on the most players like Android, iPod, iPad, iPhones, VLC media player
# and MPlayer.
my $fileType = "mp4";

# Option: what visual resolution or quality do you want to download? List
# multiple values just in case the highest quality video is not available, the
# script will look for the next resolution. You can choose "highres" for 4k,
# "hd1080" for 1080p, "hd720" for 720p, "itag=18" which means standard
# definition 640x380 and "itag=17" which is mobile resolution 144p (176x144).
# The script will always prefer to download the highest resolution video format
# from the list if available.
my $resolution = "hd720,itag=18";

# Option: How many times should the script retry the download if wget fails for
# any reason? Do not make this too high as a reoccurring error will just hit
# YouTube over and over again.
my $retryTimes = 5;

# Option: do you want the resolution of the video in the file name? zero(0) is
# no and one(1) is yes. This option simply puts "_hd1080.mp4" or similar at the
# end of the file name.
my $resolutionFilename = 0;

# Option: turn on DEBUG mode. Use this to reverse engineering this code if you are
# making changes or you are building your own YouTube download script.
my $DEBUG=0;

#################################################################

## Initialize retry loop and resolution variables
$ENV{PATH} = "/bin:/usr/bin:/usr/local/bin";
my $prefix = "";
my $retry = 1;
my $retryCounter = 0;
my $resFile = "unknown";
my $user_url = "";
my $user_prefix = "";

## Collect the URL from the command line argument
chomp($user_url = $ARGV[0]);
my $url = "$1" if ($user_url =~ m/^([a-zA-Z0-9\_\-\&\?\=\:\.\/]+)$/ or die "\nError: Illegal characters in YouTube URL\n\n" );

## Declare the user defined file name prefix if specified
if (defined($ARGV[1])) {
    chomp($user_prefix = $ARGV[1]);
    $prefix = "$1" if ($user_prefix =~ m/^([a-zA-Z0-9\_\-\.\ ]+)$/ or die "\nError: Illegal characters in filename prefix\n\n" );
}

## Retry getting the video if the script fails for any reason
while ( $retry != 0 && $retryCounter < $retryTimes ) {

    ## Download the html code from the YouTube page suppling the page title and the
    ## video URL. The page title will be used for the local video file name and the
    ## URL will be sanitized and passed to wget for the download.
    my $html = `wget -4Ncq -e convert-links=off --keep-session-cookies --save-cookies /dev/null --no-check-certificate "$url" -O-`  or die  "\nThere was a problem downloading the HTML file.\n\n";

    ## Format the title of the page to use as the file name
    my ($title) = $html =~ m/<title>(.+)<\/title>/si;
    $title =~ s/[^\w\d]+/_/g or die "\nError: we could not find the title of the HTML page. Check the URL.\n\n";
    $title =~ s/_youtube//ig;
    $title =~ s/^_//ig;
    $title = lc ($title);
    $title =~ s/_amp//ig;

    ## Collect the URL of the video from the HTML page
    my ($download) = $html =~ /"url_encoded_fmt_stream_map"(.*)/ig;

    # Print all of the separated strings in the HTML page
    print "\n$download\n\n" if ($DEBUG == 1);

    # This is where we look through the HTMl code and select the file type and
    # video quality.
    my @urls = split(',', $download);
    OUTERLOOP:
    foreach my $val (@urls) {
    #   print "\n$val\n\n";

        if ($val =~ /$fileType/) {
            my @res = split(',', $resolution);
            foreach my $ress (@res) {
                if ($val =~ /$ress/) {
                    print "\n\nGOOD\n\n" if ($DEBUG == 1);
                    print "$val\n" if ($DEBUG == 1);
                    $resFile = $ress;
                    $resFile = "sd640" if ( $ress =~ /itag=18/ );
                    $resFile = "mobil176" if ( $ress =~ /itag=17/ );
                    $download = $val;
                    last OUTERLOOP;
                }
            }
        }
    }

    ## Clean up the URL by translating unicode and removing unwanted strings
    $download =~ s/\:\ \"//;
    $download =~ s/%3A/:/g;
    $download =~ s/%2F/\//g;
    $download =~ s/%3F/\?/g;
    $download =~ s/%3D/\=/g;
    $download =~ s/%252C/%2C/g;
    $download =~ s/%26/\&/g;
    $download =~ s/sig=/signature=/g;
    $download =~ s/\\u0026/\&/g;
    $download =~ s/(type=[^&]+)//g;
    $download =~ s/(fallback_host=[^&]+)//g;
    $download =~ s/(quality=[^&]+)//g;

    ## Clean up the URL
    my ($youtubeurl) = $download =~ /(http?:.+)/;

    ## URL title additon
    my ($titleurl) = $html =~ m/<title>(.+)<\/title>/si;
    $titleurl =~ s/ - YouTube//ig;
    $titleurl =~ s/ /%20/ig;

    ## Combine the YouTube URL and title string
    $download = "$youtubeurl\&title=$titleurl";

    ## A bit more cleanup as YouTube
    $download =~ s/&+/&/g;
    $download =~ s/&itag=\d+&signature=/&signature=/g;

    ## Combine file variables into the full file name
    my $filename = "unknown";
    if ($resolutionFilename == 1) {
        $filename = "$prefix$title\_$resFile.$fileType";
    }
    else {
        $filename = "$prefix$title.$fileType";
    }

    ## Process check: Are we currently downloading this exact same video? Two of the
    ## same wget processes will overwrite themselves and corrupt the video.
    my $running = `ps auwww | grep [w]get | grep -c "$filename"`;
    print "\nNumber of the same wgets running: $running\n" if ($DEBUG == 1);
    if ($running >= 1)
    {
        print "\nAlready $running process, exiting." if ($DEBUG == 1);
        exit 0;
    };

    ## Print the long, sanitized YouTube URL for testing and debugging
    print "\n$download\n" if ($DEBUG == 1);

    ## Print the file name of the video collected from the web page title for us to see on the cli
    print "\n Download: $filename\n\n";

    ## Background the script. Use "ps" if you need to look for the process
    ## running or use "ls -al" to look at the file size and date.
    fork and exit;

    ## Download the video
    system("wget", "-4Ncq", "-e", "convert-links=off", "--load-cookies", "/dev/null", "--tries=10", "--timeout=20", "--no-check-certificate", "$download", "-O", "$filename");

    ## Print the error code of wget
    print "     error code: $?\n" if ($DEBUG == 1);

    ## Exit Status: Check if the file exists and we received the correct error code
    ## from system call. If the download experienced any problems the script will run again and try
    ## continue the download till the file is downloaded.

    if ($? == 0 && -e "$filename" && ! -z "$filename")
    {
        print " Finished: $filename\n\n" if ($DEBUG == 1);
        $retry = 0;
    }
    else
    {
        print STDERR "\n FAILED: $filename\n\n" if ($DEBUG == 1);
        $retry = 1;
        $retryCounter++;
        sleep $retryCounter;
    }

} # while

#### EOF #####
Run Code Online (Sandbox Code Playgroud)

将此脚本复制到 .txt 文件并重命名youtube_wget.pl

使用以下命令使其可执行:

chmod 755 youtube_wget.pl
Run Code Online (Sandbox Code Playgroud)

当你想在终端中下载时,输入:

./youtube_wget.pl http://www.youtube.com/watch?v=ejkm5uGoxs4
Run Code Online (Sandbox Code Playgroud)

将 YouTube URL 更改为您的 YouTube 视频 URL。

保存位置:视频将保存在您当前的目录中。

来源:YouTube 下载器 Wget Perl 脚本

  • 我确信 OP 已经安装了 `wget`,因为他询问了如何以特定方式使用。 (5认同)

小智 15

对于 Firefox 用户:

由于对这个问题的回答在这里可能更有效,为了方便起见,我将在此处提供。

您可以使用flashgot,这是一个 Firefox 插件,我发现它对于从 YouTube 和其他网站下载视频非常有用。(但是,您仍然需要浏览器中的 flash 插件,以便 检测视频flashgot。)

  • flashgot官方 Mozilla 插件站点安装并重新启动 Firefox。确保插件已启用;通过转到菜单工具检查?插件扩展名。从flashgot扩展选项卡的条目中,您还可以设置许多首选项。

  • 导航到您的 YouTube 视频并在 YouTube 视频设置中设置质量,然后开始播放视频几秒钟然后暂停。

  • 右键单击 YouTube 页面并选择flashgot media; 可能会有不止一个视频;要么简单地下载它们,要么选择更大的文件大小(这将是更高质量的视频)。您可以使用浏览器的下载管理器或通过flashgot options.

在此处输入图片说明


cod*_*eak 9

4k下载器!除了从 URL 下载视频外,它还可以下载整个播放列表,并在需要时将它们转换为 MP3 或其他格式。

http://www.4kdownload.com/

我长期使用它,它简单易用,并且它有一个适用于Ubuntu的GUI界面。

在此处输入图片说明


小智 9

我想建议一种使用 VLC 媒体播放器下载 YouTube 视频的方法,只需四个简单的步骤:

  1. 在 VLC 媒体播放器中打开视频链接作为网络流媒体。(Ctrl + N或媒体 > 打开网络流...)
  2. 选择媒体信息并复制位置(Ctrl + I或右键单击视频区域>工具>媒体信息)
  3. 将其粘贴到浏览器的地址栏中
  4. 保存。


Ste*_*goo 6

更新

不再维护bytubed。因此,新的解决方案与著名的命令行youtube-dl 一起使用。它定期维护并且运行良好。

  1. 更新它

    youtube-dl -U
    
    Run Code Online (Sandbox Code Playgroud)
  2. 并下载视频或播放列表

    youtube-dl -c -t URL_HERE
    
    Run Code Online (Sandbox Code Playgroud)
  3. 如果有一个带有 URL 的文件,那么

    youtube-dl -c -t -a urls.txt
    
    Run Code Online (Sandbox Code Playgroud)

旧答案

我知道有人回答了,但我很震惊,没有人明确提到Bytubed。在 YouTube 下载方面,它对我来说是最好的。只需安装它,然后转到 Firefox 的菜单工具旁管

唯一的缺点是它仅适用于 Firefox,但对我来说这不是缺点,因为我使用 Firefox 进行所有浏览......


rst*_*r78 5

您也可以尝试使用 Clipgrab。它可以通过剪贴板从 YouTube 下载视频,也可以通过应用程序搜索视频。购电协议就在这里

您可以使用这些命令:

sudo add-apt-repository ppa:clipgrab-team/ppa
sudo apt-get update && sudo apt-get install clipgrab
Run Code Online (Sandbox Code Playgroud)


Pra*_*shi 5

您可以使用 Python 命令行程序youtube-dl

  1. 要安装 youtube-dl 程序,请在终端中键入以下命令:

    $ sudo apt-get install python-pip
    $ sudo pip install --upgrade youtube_dl
    
    Run Code Online (Sandbox Code Playgroud)
  2. 要从终端下载 YouTube 视频,请使用:

    $youtube-dl <video_url>
    
    Run Code Online (Sandbox Code Playgroud)
  3. 要查看可用的不同质量和格式option -F。然后使用使用选项 -F 后显示的格式代码,以所需的格式下载它。

    $ youtube-dl -F $ youtube-dl -f

  4. 要下载整个播放列表,请使用

    $ youtube-dl -citw <playlist_url>
    
    Run Code Online (Sandbox Code Playgroud)
  5. 要下载整个频道,请使用

    $ youtube-dl -citw ytuser:<channel_name>
    
    Run Code Online (Sandbox Code Playgroud)