以下查询将返回结果,但其中一些将包含limitedSyndication
限制。不能通过format
或restriction
参数将其滤除。http://gdata.youtube.com/feeds/api/videos?alt=json-in-script&callback=jQuery.youtube.response&q=Madonna&v=2&format=5&start-index=11&max-results=10
上面的查询中未使用restriction
参数,因为YouTube Data API reference guide声明以下内容:
By default, the API filters out videos that cannot be played in the country from which you send API requests.
难道我做错了什么? (除了搜索麦当娜)
如何摆脱
limitedSyndication
结果,或者这是一个错误?
最佳答案
如GData文档中所述,您可以传递一个“限制”参数,该参数将过滤出所传递的ip无法播放的结果,因此您只需要获取用户的IP并将其传递给请求即可:
To request videos playable from a specific computer, include the restriction parameter in your request and set the parameter value to the IP address of the computer where the videos will be played – e.g. restriction=255.255.255.255. To request videos that are playable in a specific country, include the restriction parameter in your request and set the parameter value to the ISO 3166 two-letter country code of the country where the videos will be played – e.g. restriction=DE. You should include this parameter in any request to retrieve a list of videos, including search results, playlists, favorite videos, video responses and so forth. If a video in the API response is not playable in the location that you're using to restrict availability of the content, the <entry> for that tag will not contain a <media:content> tag. However, it will contain a <yt:state> tag that indicates that the video is restricted.
关于youtube - 如何从YouTube数据API搜索结果中删除 `limitedSyndication`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1231417/