从 curl 或 get_video_info 获取 youtube 视频 URL

2022-01-06 00:00:00 youtube php video

所以,我正在开发一个 php 项目,其中一部分是抓取 youtube 视频 url 并将其插入到 html5 视频标签中.我使用 curl 调用 http://youtube.com/get_video_info?video_id=XXX 并获取正确的视频文件我本地机器上的网址.

So, I am working on a php project and one part of it is grabbing a youtube video url and inserting it into an html5 video tag. I was using a curl call to http://youtube.com/get_video_info?video_id=XXX and getting the right video file urls on my local machine.

但是,当我将代码上传到我的网络服务器并尝试运行它时,没有一个视频 URL 有效.网址看起来不错,但有些参数(如 IP)有所不同.我不明白为什么它可以在运行 xampp 或 mamp 的本地机器上运行,但不能在我的 Web 服务器上运行.我什至尝试在 youtube 视频页面上做一个卷曲,并注意到在本地,它会输出页面并播放视频,但在我的网络服务器上,所有视频通话都有 404.

But, when I uploaded my code to my web server and tried to run it, none of the video URLs have worked. The urls seemed fine but some parameters, like IP, where different. I can't understand why it works from my local machine running xampp or mamp but not on my web server. I even tried just doing a curl on the youtube video page and noticed that locally, it would output the page and play the video but on my webserver, all the video calls got 404s.

有这方面的信息吗?无论如何,我可以获取一个 youtube 视频网址,以便我可以在 html5 视频标签中播放 youtube 视频?这就是 keepvid 和类似网站使用该死的 Java 小程序的原因吗?

Any info about this? Anyway I can grab a youtube video url so that I can play youtube videos in a html5 video tag? Is this why keepvid and sites like that use the damn java applet?

推荐答案

你应该看看 youtube-dl 项目 我很确定您可以通过一些想法来理解实现目标的正确方法.

You should take a look to youtube-dl project I'm pretty sure you can takes some idea to understand the proper way to achieve your goal.

相关文章