Youtube视频无法嵌入,但API说它是

时间:2014-09-22 09:24:38

标签: video youtube youtube-api embeddable

我想从Youtube上检测视频是否可播放。我目前正在检测版权侵权,可嵌入和“可以联合”的限制。我在API中调用两次,一次在版本3中,一次在版本2中调用这些:

http://gdata.youtube.com/feeds/api/videos/{videoId}?v=2&alt=jsonc

https://www.googleapis.com/youtube/v3/videos?id={videoId}&key={key}&part=status

对于视频(https://www.youtube.com/watch?v=TzmyOT1kcfc),我得到了以下答案:

{

    "kind": "youtube#videoListResponse",
    "etag": "\"kjEFmP90GvrCl8BObMQtGoRfgaQ/yoB7kT2xS4cnv1zDF-EiUrfidKQ\"",
    "pageInfo": {
        "totalResults": 1,
        "resultsPerPage": 1
    },
    "items": [
        {
            "kind": "youtube#video",
            "etag": "\"kjEFmP90GvrCl8BObMQtGoRfgaQ/mk9sFeT7lpR0qthcrYeJssWlayY\"",
            "id": "TzmyOT1kcfc",
            "status": {
                 "uploadStatus": "processed",
                 "privacyStatus": "public",
                 "license": "youtube",
                 "embeddable": true,
                 "publicStatsViewable": true
            }
            "player": {
                "embedHtml": "<iframe type='text/html' src='http://www.youtube.com/embed/TzmyOT1kcfc' width='640' height='360' frameborder='0' allowfullscreen='true'/>"
            }
        }
    ]
}

并且:

{
    "apiVersion": "2.1",
    "data": {
        "id": "TzmyOT1kcfc",
        "uploaded": "2014-08-07T11:13:03.000Z",
        "updated": "2014-09-22T01:13:46.000Z",
        "uploader": "topgear",
        "category": "Autos",
        "title": "Aston Martin: DBS vs DB9 and Vanquish (HQ) - Top Gear - Series 10 - BBC",
        "description": "Jeremy test drives the flashy Aston Martin DBS. Clip taken from series 10, episode 6.\n\nSubscribe for more awesome Top Gear videos: http://www.youtube.com/subscription_center?add_user=Topgear\n\nTop Gear YouTube channel: http://www.youtube.com/topgear\nTopGear.com website: http://www.topgear.com\n\nTop Gear Facebook: http://www.facebook.com/topgear\nTop Gear Twitter: http://twitter.com/BBC_topgear\n\nThis is a channel from BBC Worldwide who help fund new BBC programmes.",
        "thumbnail": {
            "sqDefault": "http://i.ytimg.com/vi/TzmyOT1kcfc/default.jpg",
            "hqDefault": "http://i.ytimg.com/vi/TzmyOT1kcfc/hqdefault.jpg"
        },
        "player": {
            "default": "http://www.youtube.com/watch?v=TzmyOT1kcfc&feature=youtube_gdata_player",
            "mobile": "http://m.youtube.com/details?v=TzmyOT1kcfc"
    },
        "content": {
            "1": "rtsp://r6---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQn3cWQ9ObI5TxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp",
            "5": "http://www.youtube.com/v/TzmyOT1kcfc?version=3&f=videos&app=youtube_gdata",
            "6": "rtsp://r6---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQn3cWQ9ObI5TxMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"
        },
        "duration": 438,
        "aspectRatio": "widescreen",
        "rating": 4.917057,
        "likeCount": "2928",
        "ratingCount": 2990,
        "viewCount": 320436,
        "favoriteCount": 0,
        "commentCount": 143,
        "accessControl": {
            "comment": "allowed",
            "commentVote": "allowed",
            "videoRespond": "moderated",
            "rate": "allowed",
            "embed": "allowed",
            "list": "allowed",
            "autoPlay": "allowed",
            "syndicate": "allowed"
        }
    }
}

所以我看到的是视频既可以“联合”(可在手机上查看)又可嵌入,但它不可嵌入(https://www.youtube.com/embed/TzmyOT1kcfc?autoplay=true ==&gt;刷新页面)。该视频正在我的Android应用中播放,因为我正在使用官方Youtube SDK,因此我猜测,对于Google,我的应用程序的这部分是Youtube的一部分。

问题是:为什么在这两个调用中,API告诉我它是嵌入式的,而绝对不是?

我发现通过以“autoplay = true”作为参数启动嵌入式播放器,我可以在返回的HTML中查找“ytp-error html5-stop-propagation”类,但是解析它会非常昂贵每个Youtube视频的HTML。您是否有其他方法可以了解视频是否真的可以嵌入?

最后一个问题:我点击了我在这个主题上提供给你的嵌入式播放器,它是第一次工作,但是当你刷新页面时却没有。为什么呢?

1 个答案:

答案 0 :(得分:0)

一小部分视频的内容所有者将其应用于域级白名单或黑名单。这些限制未反映在API响应中 您无能为力。由视频的内容所有者决定可以在哪里嵌入视频