本文介绍了YouTube 数据 API v3 不支持 Video.snippet 资源的“标签"属性为 500 个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论是在以交互方式直接将标签输入 YouTube 用户界面时,还是在使用 Data API v3 视频资源片段对象时,我们都遇到了视频标签"属性少于记录的最大 500 个字符的意外限制.

We have encountered an unexpected limitation of less than the documented maximum 500 characters for the video ‘tags’ property, both when entering Tags directly into the YouTube UI interactively or when using the Data API v3 video resource snippet object.

我们正在使用 YouTube 数据 API v3 从 ASP.Net C# 网络应用程序与 YouTube 进行交互,该应用程序使用适用于 .NET 的 Google API 客户端库.

We are using the YouTube Data API v3 to interact with YouTube from an ASP.Net C# web application, which uses the Google APIs Client Library for .NET.

在测试过程中,我们注意到仅单个关键字标签支持 500 个字符,但是当关键字中遇到任何空格时,例如人名,每个空格似乎都有开销和 500 个字符的限制结果意外超出.

During testing we have noticed that 500 characters are supported for exclusively single keyword Tags, but when there are any spaces encountered within the keywords, such as for people's names for example, each space appears to have an overhead and the 500 character limit is unexpectedly exceeded as a result.

YouTube 文档规定标签的最大长度应为 500 个字符,并且标签字段包含一个逗号分隔的列表,列表中的项目之间的逗号以及逗号之间的标签内的空格计入限制.

The YouTube documentation states that Tags should be up to a maximum length of 500 characters, and that the Tags field contains a comma separated list and commas between items in the list and spaces within Tags between the commas count towards the limit.

虽然没有提到空格的确切处理方式,但单个空格字符似乎比单个非空格字符更计入整个字段大小,从而有效地减少了可以意外支持的标签长度涉及空间.

There is no mention of exactly how spaces are handled though, yet a single whitespace character seems to count towards the overall field size as more than a single non-whitespace character, effectively reducing the length of Tags that can be supported unexpectedly when spaces are involved.

有人可以就上述问题提出建议吗?

Could anyone please advise regarding the aforementioned issue?

推荐答案

如果标签包含空格,API 服务器会像用引号包裹一样处理标签值,并且引号计入字符限制.因此,出于字符限制的目的,标签 Foo-Baz 包含七个字符,但标签 Foo Baz 包含九个字符.

If a tag contains a space, the API server handles the tag value as though it were wrapped in quotation marks, and the quotation marks count toward the character limit. So, for the purposes of character limits, the tag Foo-Baz contains seven characters, but the tag Foo Baz contains nine characters.

这篇关于YouTube 数据 API v3 不支持 Video.snippet 资源的“标签"属性为 500 个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:19