How to get direct url of video from youtube url?(如何从 youtube url 获取视频的直接 url?)
问题描述
我正在 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.此外,您可能应该查看 YouTube TOS
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
您不得下载任何内容,除非您看到 YouTube 在该内容的服务上显示下载"或类似链接.
You shall not download any Content unless you see a "download" or similar link displayed by YouTube on the Service for that Content.
但无论如何,我知道的一种方法是 youtube-dl,但我是很确定它只适用于python.不过,网上似乎有一些节点包装器(ex.)
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 下载器,ytdl.上次更新是 9 天前,所以它应该可以在当前系统上正常工作.您应该可以使用 -o filename
或 --output filename
下载它,或 --print-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 url 获取视频的直接 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 youtube url 获取视频的直接 url?


- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01