本文介绍了如何从YouTube网址获取视频的直接网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Discord.JS(这是Node.JS的库)中创建一个机器人,我想向其中添加音乐模块。 Discord.JS可以在语音通道中播放.wav,.mp4等格式的视频。我想为用户增加一种可能性,只需键入视频的YouTube网址即可播放。是否有可能通过API或其他方式从YouTube网址获取视频的网址?

I'm creating a bot in Discord.JS (it's a library for Node.JS) and I would like to add a music module to it. Discord.JS can play videos in formats like .wav, .mp4 etc. in voice channels. I would like to add a possibility for users to just type a YouTube url of a video to play it. Is there any possibility to get a video's url from an YouTube url by an API or any other way?

推荐答案

能够通过 youtube.com/get_video?video_id = ... 轻松获得它,但是就像5年前一样,现在我认为它使用了一些奇怪的流内容。

You used to be able to get it pretty easily with youtube.com/get_video?video_id=... but that was like 5+ years ago, now I think it uses some weird stream thing.

我认为Youtube的官方API不允许您下载视频或获取URL。另外,您可能应该看看

I don't think Youtube's official API lets you download videos or get a URL. Also, you should probably take a look at section 5B of the YouTube TOS

但是无论如何,我知道的一种方法是,但我很确定它仅适用于python。似乎在线上有一些节点包装器()

But anyway, one method I know is youtube-dl, but I'm pretty sure it's only for python. There seem to be a few node wrappers online though (ex.)

我还找到了一个node.js youtube下载器,。最近一次更新是在9天前,因此它应该可以在当前系统上正常运行。您应该可以使用 -o文件名-输出文件名进行下载,或使用-print-url 以获得直接的视频URL。

I've also found a node.js youtube downloader, ytdl. Last update was 9 days ago so it should probably be working fine with the current system. You should be able to use -o filename or --output filename to download it, or --print-url to get a direct video url.

这篇关于如何从YouTube网址获取视频的直接网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 11:59
查看更多