YouTube数据API V3不支持500个字符的“标签”Video.snippet资源属性 [英] YouTube Data API v3 does not support 500 characters for ‘tags’ property of Video.snippet resource

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

问题描述

我们曾经遇到过的小于记录最大500个字符的视频标签的财产意外的限制,无论是直接输入标签时到YouTube的UI交互方式或使用数据API V3视频资源片断对象时。

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#的Web应用程序,它使用谷歌API客户端库.NET与YouTube进行交互。

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?

推荐答案

的Youtube添加两个引号标记每一个单词用空格

Youtube add two quotes marks to every words with spaces

 example:  hello world   // 10 letters + 1 space + 2 quotation marks = 13chars.
           hello,world   // 10 letters + 1 comma = 11chars.

在我的JavaScript做下的验证来控制:

In javascript I do the next validation to control that:

 function tagsValidator (values) {
  //calculate num spaces (youtube add 2 quotes mark by space)
  var numSpaces = values.replace(/[^\s]/g,'').length,
      numTags = values.split(",").length,
      numChars = (numTags+(numSpaces*2));
  if(numChars>500) return false;
  return true;
}

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆