我有一个移动应用程序,该应用程序将一些YouTube视频嵌入到WebView中。
问题是,使用YouTube数据API V3,我将获得“ 嵌入式”项目的列表。但是其中一些人说“视频不可用”。当我将相同的代码粘贴在JSFIDDLE,域或某种 WebServer 上时,它确实可以正常工作,但是当从 file 中阅读或导航到HTML字符串通过 WebView ,不起作用。
我的问题是,我如何理解我要嵌入的视频实际上是可嵌入的 来自 file 是否?
我已经检查了每个视频的YouTube数据API V3输出,但找不到任何有意义的信息。
还有其他一些Web API或HTTP端点,我可以检查视频是否正确吗?
如果没有,我如何从编程中从YouTube播放器中获取数据,以查看它是否成功嵌入了它?
不能嵌入文件中的YouTube视频的示例列表如下:
https://www.youtube.com/watch?v=TjI3bzvbCU4
https://www.youtube.com/watch?v=QWveXdj6oZU
https://www.youtube.com/watch?v=KEEnap_h8cs
注意:我的问题是 sideen Unimbeddable 项目,因为我想从 file (在移动应用中)加载它们。因此,试图从 Web服务器中加载对我来说不是一个选择。
注2:这些块不是区域性,它们是基于域的。
I have a mobile application that embeds some youtube videos in a webview.
The problem is that, using YouTube Data API v3 I get a list of "Embeddable" items to show. But some of them say that "Video unavailable". When I paste the same code on on jsfiddle or a domain or some sort of webserver, it does work but when reading from File or navigating to html string via webview, it doesn't work.
My question is that how can I understand if the video that I'm trying to embed is actually embeddable from file or not?
I have checked youtube data API v3 outputs for each video and I couldn't find any meaningful information.
Is there some other sort of web API or HTTP endpoint that I can check to see if the video is right?
If not, how can I get data from youtube player programatically to see whether it successfully embedded it or not?
The sample list of the youtube videos that can't be embedded in file are following:
https://www.youtube.com/watch?v=TjI3bzvbCU4
https://www.youtube.com/watch?v=QWveXdj6oZU
https://www.youtube.com/watch?v=KEEnap_h8cs

Note: My problem is to identify the unimbeddable items, because I want to load them from file (in a mobile app). Therefore trying to loading it from a webserver isn't an option for me.
Note 2: These blocks aren't regional, they are domain based.
发布评论
评论(3)
YouTube数据API v3 一个不工作的嵌入页面 ,而它说它是。
对于这样的其他视频(
zqyezph-hgg
)它起作用< /a>。所以我的想法只是检索 https://www.youtube.com/embed/embed/video_id 并查看视频是否无法播放,例如:
curl -s https://www.youtube.com/embed/tji3bzvbcu4 | grep“无法播放” | WC -L
返回
1
,因此该视频无法播放。curl -s https://www.youtube.com/embed/zqyezph-hgg | grep“无法播放” | WC -L
返回
0
,因此该视频可播放。另请注意,我的 youtube操作api httpps://yt.lemnt.lemnososlife.com/vide.poart.part.part=status = status = status = status =返回:
和返回:
YouTube Data API v3 provides a not working embed page while it says that it is.
While for other videos like this one (
ZqYezph-hgg
) it works.So my idea is just to retrieve https://www.youtube.com/embed/VIDEO_ID and see if the video is unplayable like this for instance:
curl -s https://www.youtube.com/embed/TjI3bzvbCU4 | grep "UNPLAYABLE" | wc -l
Returns
1
, so this video is unplayable.curl -s https://www.youtube.com/embed/ZqYezph-hgg | grep "UNPLAYABLE" | wc -l
Returns
0
, so this video is playable.Also note that my open-source YouTube operational API implements more properly this feature, as https://yt.lemnoslife.com/videos?part=status&id=TjI3bzvbCU4 returns:
and https://yt.lemnoslife.com/videos?part=status&id=ZqYezph-hgg returns:
我发现此可能解释为什么不可用视频。
引用:
可能,YouTube数据API未更新以匹配视频和YouTube指南的上传器/所有者设置的值,以允许嵌入视频。
对于这种情况,我建议您在问题跟踪器。
如果输入视频的源代码 - 喜欢:
view -source:https://www.youtube.com/embed/tji3bzvbcu4
,您可以在其中找到一个称为PreviewPlayabilityStatus
如下:可通过此端点提供此信息:
https://wwww.youtube.com/get_video_info?vide = ide = tji = tji3bzvbcu4 ,但是,现在返回
HTTP错误410
。不幸的是,此信息没有提供有关为什么无法使用视频的原因的任何有用数据 - 尽管事实:
您也可以使用此替代方案用于嵌入YouTube视频 - 我在这里分享,因为我觉得很有趣。
I found this entry on Google Support that might explain why a video is not available.
Quote:
Probably, YouTube Data API is not updated to match the value set by the uploader/owner of the video AND YouTube guidelines to allow embed the videos.
For this case, I suggest you to post a ticket on Issue Tracker.
If you enter to the source code of the video - like:
view-source:https://www.youtube.com/embed/TjI3bzvbCU4
, you can find there a property calledpreviewPlayabilityStatus
as follows:This info was available throught this endpoint:
https://www.youtube.com/get_video_info?video_id=TjI3bzvbCU4
, but, now, anHTTP ERROR 410
is returned.Unfortunately, this info does not provide any useful data about the reason(s) why the video is not available - despite the fact the response of the YouTube Data API says it is embeddable:
You can also use this alternative for embed a YouTube video - I share it here because I find it interesting.
确保在标题中所有请求中都有参考器和推荐人 - 政策集。
Make sure you have your referer and referer-policy set in the header all requests.