如何识别可以嵌入文件的YouTube视频

发布于 2025-01-23 04:44:18 字数 1049 浏览 2 评论 0 原文

我有一个移动应用程序,该应用程序将一些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

enter image description here

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

请恋爱 2025-01-30 04:44:18

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 =返回:

{
    "kind": "youtube#videoListResponse",
    "etag": "NotImplemented",
    "items": [
        {
            "kind": "youtube#video",
            "etag": "NotImplemented",
            "id": "TjI3bzvbCU4",
            "status": {
                "embeddable": true,
                ...
            }
        }
    ]
}

返回:

{
    "kind": "youtube#videoListResponse",
    "etag": "NotImplemented",
    "items": [
        {
            "kind": "youtube#video",
            "etag": "NotImplemented",
            "id": "ZqYezph-hgg",
            "status": {
                "embeddable": true,
                ...
            }
        }
    ]
}

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:

{
    "kind": "youtube#videoListResponse",
    "etag": "NotImplemented",
    "items": [
        {
            "kind": "youtube#video",
            "etag": "NotImplemented",
            "id": "TjI3bzvbCU4",
            "status": {
                "embeddable": true,
                ...
            }
        }
    ]
}

and https://yt.lemnoslife.com/videos?part=status&id=ZqYezph-hgg returns:

{
    "kind": "youtube#videoListResponse",
    "etag": "NotImplemented",
    "items": [
        {
            "kind": "youtube#video",
            "etag": "NotImplemented",
            "id": "ZqYezph-hgg",
            "status": {
                "embeddable": true,
                ...
            }
        }
    ]
}
心在旅行 2025-01-30 04:44:18

我发现此可能解释为什么不可用视频。

引用:

实际上在这里找到了问题。 在此显示的视频
嵌入在背景中播放“受版权保护”的音乐。 YouTube
显然在嵌入时不会播放这样的视频。
我们有我们的
用户删除音频并重新上传视频,一切都是
现在正常工作。

希望这对某人有帮助。

可能,YouTube数据API未更新以匹配视频和YouTube指南的上传器/所有者设置的值,以允许嵌入视频。

对于这种情况,我建议您在问题跟踪器

如果输入视频的源代码 - 喜欢: view -source:https://www.youtube.com/embed/tji3bzvbcu4 ,您可以在其中找到一个称为 PreviewPlayabilityStatus 如下:

"previewPlayabilityStatus": {
    "status": "UNPLAYABLE",
    "reason": "Video no disponible",
    "errorScreen": {
        "playerErrorMessageRenderer": {
            "reason": {
                "runs": [{
                    "text": "Video no disponible"
                }]
            },
            "proceedButton": {
                "buttonRenderer": {
                    "style": "STYLE_DEFAULT",
                    "size": "SIZE_DEFAULT",
                    "isDisabled": false,
                    "text": {
                        "simpleText": "Mirar en YouTube"
                    },
                    "navigationEndpoint": {
                        "clickTrackingParams": "CAEQ8FsiEwiT6sGfg6j3AhVG25QJHY96Amgu003d"

可通过此端点提供此信息: https://wwww.youtube.com/get_video_info?vide = ide = tji = tji3bzvbcu4 ,但是,现在返回 HTTP错误410

不幸的是,此信息没有提供有关为什么无法使用视频的原因的任何有用数据 - 尽管事实

"status": {
    "uploadStatus": "processed",
    "privacyStatus": "public",
    "license": "youtube",
    "embeddable": true,
    "publicStatsViewable": true,
    "madeForKids": false
  },

您也可以使用此替代方案用于嵌入YouTube视频 - 我在这里分享,因为我觉得很有趣。

I found this entry on Google Support that might explain why a video is not available.

Quote:

Actually found the issue here. The videos that were displaying this on
embed had "Copyrighted" music playing in the background. YouTube
apparently does not play videos like this while embedded.
We had our
user remove the audio and re-uploaded the video and everything is
working fine now.

Hope this helps somebody.

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 called previewPlayabilityStatus as follows:

"previewPlayabilityStatus": {
    "status": "UNPLAYABLE",
    "reason": "Video no disponible",
    "errorScreen": {
        "playerErrorMessageRenderer": {
            "reason": {
                "runs": [{
                    "text": "Video no disponible"
                }]
            },
            "proceedButton": {
                "buttonRenderer": {
                    "style": "STYLE_DEFAULT",
                    "size": "SIZE_DEFAULT",
                    "isDisabled": false,
                    "text": {
                        "simpleText": "Mirar en YouTube"
                    },
                    "navigationEndpoint": {
                        "clickTrackingParams": "CAEQ8FsiEwiT6sGfg6j3AhVG25QJHY96Amgu003d"

This info was available throught this endpoint: https://www.youtube.com/get_video_info?video_id=TjI3bzvbCU4, but, now, an HTTP 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:

"status": {
    "uploadStatus": "processed",
    "privacyStatus": "public",
    "license": "youtube",
    "embeddable": true,
    "publicStatsViewable": true,
    "madeForKids": false
  },

You can also use this alternative for embed a YouTube video - I share it here because I find it interesting.

つ低調成傷 2025-01-30 04:44:18

确保在标题中所有请求中都有参考器和推荐人 - 政策集。

Make sure you have your referer and referer-policy set in the header all requests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文