使用 PHP 从 youtube 下载视频 - 仍然可以吗?
我想知道在过去几个月 youtube 发生了所有变化之后,是否有办法编写一个能够下载视频的脚本?
我知道一年前有效的方法不再适用。
I was wondering if there is a way, after all the changes in youtube in the last months, to write a script that enables downloading videos?
I'm aware of the fact that the methods that worked a year ago, are no longer relevant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,还有办法。我不会为您编写整个脚本,但至少会为您编写提供 YouTube 下载链接的函数。
好吧,您需要安装 CURL 才能执行此操作。
现在,让我谈谈代码。经过大约 30 分钟的研究,我成功破解了他们的算法,但他们现在已经设定了非常严格的界限。
由于每个视频下载请求仅与 IP 相关联,因此您需要将其从带宽中传输出来,这就是上面脚本的作用。然而,像 keepvid.com 这样的网站使用 Java 来获取下载 URL 并将其流式传输给用户。我还安装了自己的 YouTube ID 抓取器,对于此类工具来说非常方便。
请注意,如上所述,YouTube 总是会更改其算法,使用此工具的风险由您自行承担。对于对 YouTube 造成的任何损害,我不承担任何责任。
希望它为你设定了一个良好的界限,花了一段时间才做到。
Yes there is still a way. I'm not going to write the whole script for you, but I'll at least write you the function that provides the download link from YouTube.
Alright, you're going to need CURL installed to do this.
Now, let me talk about the code. After around 30 minutes of research, I managed to hack their algorithm however it does have very strict boundaries which they've set in now.
As each request made for a video download is only tied to the IP, you would need to stream it out of your bandwidth which is what the script above does. However, sites like keepvid.com use Java to grab the download url and stream it to the user. I've also put in my own YouTube ID grabber which is very handy for these kind of tools.
Please acknowledge that as stated, YouTube does always change their algorithms and usage of this tool is at your own risk. I am not held liable for any damages made to YouTube.
Hope it sets a good boundary for you, spent a while making it.