How do I use the Youtube API to check if a video is embeddable?

后端 未结 5 612
栀梦
栀梦 2020-12-15 12:28

Does anyone know how to check if a Youtube video is embeddable using the Youtube API? I\'ve tried using this URL:

http://gdata.youtube.com/feeds/api/videos/4         


        
5条回答
  •  星月不相逢
    2020-12-15 13:02

    Looking at the YouTube API reference, it appears you have a couple choices:

    Specify the "FORMAT" parameter when searching for a clip:

    The format parameter specifies that videos must be available in a particular video format. Your request can specify any of the following formats:

    5 - HTTP URL to the embeddable player (SWF) for this video. This format is not available for a video that is not embeddable. Developers commonly add &format=5 to their queries to restrict results to videos that can be embedded on their sites.

    Or reference the yt:accessControl element:

    The tag indicates whether users are allowed to rate a video, add comments about a video, rate comments about the video, add a video response to the video, or embed the video on third-party websites. Another setting indicates whether YouTube can show the video on YouTube properties other than the YouTube.com website.

    Syntax would look something like

    So in your example it looks like the line yt:format: "5" tells you the clip can be embedded.

提交回复
热议问题