Youtube API V3 中的 ContentDetails.RegionRestriction 和 ContentDetails.CountryRestriction 有什么区别?
What is the difference between ContentDetails.RegionRestriction and ContentDetails.CountryRestriction in the Youtube API V3?
下面是我的简单请求,用于检索特定视频的 contentDetails
。
var youTubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "your-apikey",
ApplicationName = "DIGITAL.CLI"
});
var channelsListRequest = new VideosResource.ListRequest(youTubeService, "contentDetails");
channelsListRequest.Id = "FakBv-xNTeU";
var response = channelsListRequest.Execute();
Console.WriteLine(JsonConvert.SerializeObject(response));
在响应中,我得到了视频被屏蔽区域的列表,但还有一个部分不在响应中,名为 countryRestrictions
。
{
"etag": "8Dlzw_juiiGAkJUxdgfegatGe34",
"items": [
{
"contentDetails": {
"caption": "false",
"contentRating": {},
"definition": "hd",
"dimension": "2d",
"duration": "PT1M37S",
"licensedContent": true,
"projection": "rectangular",
"regionRestriction": {
"blocked": [
"US",
"FM",
"MP",
"VI",
"GU",
"MH",
"PR",
"PW",
"AS",
"UM"
]
}
},
"etag": "-DZJdN2PuXnNfuceW0s7RVa4Y9I",
"id": "FakBv-xNTeU",
"kind": "youtube#video"
}
],
"kind": "youtube#videoListResponse",
"pageInfo": {
"resultsPerPage": 1,
"totalResults": 1
}}
所以这个视频有regionRestrictions
,但没有国家限制。 countryRestrictions
还在用吗? VideoConntentDetails
的客户端库文档对它们都有相同的描述。
还有一个额外的问题,如果 allowed
列表包含项目,那么这是否意味着所有不在允许列表中的国家都被阻止了?
根据 VideoContentDetailsRegionRestriction
的客户端库文档,此模型 class 已弃用;因此 客户端库 属性 regionRestriction
也被弃用了。
客户端库正在从 YouTube 数据 API 的 属性 contentDetails.regionRestriction
.
映射其 属性 countryRestriction
根据 YouTube 数据 API 的 Videos resource
的官方规范,此类 API 资源不包含 属性 countryRestriction
.
你的第二个问题的答案是:是的,所有不在允许列表中的国家都被阻止(下面的重点是我的):
contentDetails.regionRestriction.allowed[]
(list)
A list of region codes that identify countries where the video is viewable. If this property is present and a country is not listed in its value, then the video is blocked from appearing in that country. If this property is present and contains an empty list, the video is blocked in all countries.
下面是我的简单请求,用于检索特定视频的 contentDetails
。
var youTubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "your-apikey",
ApplicationName = "DIGITAL.CLI"
});
var channelsListRequest = new VideosResource.ListRequest(youTubeService, "contentDetails");
channelsListRequest.Id = "FakBv-xNTeU";
var response = channelsListRequest.Execute();
Console.WriteLine(JsonConvert.SerializeObject(response));
在响应中,我得到了视频被屏蔽区域的列表,但还有一个部分不在响应中,名为 countryRestrictions
。
{
"etag": "8Dlzw_juiiGAkJUxdgfegatGe34",
"items": [
{
"contentDetails": {
"caption": "false",
"contentRating": {},
"definition": "hd",
"dimension": "2d",
"duration": "PT1M37S",
"licensedContent": true,
"projection": "rectangular",
"regionRestriction": {
"blocked": [
"US",
"FM",
"MP",
"VI",
"GU",
"MH",
"PR",
"PW",
"AS",
"UM"
]
}
},
"etag": "-DZJdN2PuXnNfuceW0s7RVa4Y9I",
"id": "FakBv-xNTeU",
"kind": "youtube#video"
}
],
"kind": "youtube#videoListResponse",
"pageInfo": {
"resultsPerPage": 1,
"totalResults": 1
}}
所以这个视频有regionRestrictions
,但没有国家限制。 countryRestrictions
还在用吗? VideoConntentDetails
的客户端库文档对它们都有相同的描述。
还有一个额外的问题,如果 allowed
列表包含项目,那么这是否意味着所有不在允许列表中的国家都被阻止了?
根据 VideoContentDetailsRegionRestriction
的客户端库文档,此模型 class 已弃用;因此 客户端库 属性 regionRestriction
也被弃用了。
客户端库正在从 YouTube 数据 API 的 属性 contentDetails.regionRestriction
.
countryRestriction
根据 YouTube 数据 API 的 Videos resource
的官方规范,此类 API 资源不包含 属性 countryRestriction
.
你的第二个问题的答案是:是的,所有不在允许列表中的国家都被阻止(下面的重点是我的):
contentDetails.regionRestriction.allowed[]
(list)
A list of region codes that identify countries where the video is viewable. If this property is present and a country is not listed in its value, then the video is blocked from appearing in that country. If this property is present and contains an empty list, the video is blocked in all countries.