I've noticed I get quite a bit of HTTP 400
faliures when trying to upload videos via: https://developers.google.com/youtube/v3/docs/videos/insert
(我注意到,尝试通过以下方式上传视频时,我收到了大量HTTP 400
错误: https : //developers.google.com/youtube/v3/docs/videos/insert)
I am using the Go SDK from Google: code.google.com/p/google-api-go-client
(我正在使用Google的Go SDK: code.google.com/p/google-api-go-client)
The thing that the failed uploads have in common is that somewhere in the videos snippet data (title/description) there are characters like <, >
.
(上传失败的共同点是,在视频摘要数据(标题/说明)的某个地方有<, >
类的字符。)
If I remove the conflicting character, the video uploads fine. (如果我删除有冲突的字符,则视频可以正常上传。)
I can't seem to find it in documentation, but am I required to do some kind of sanitization?
(我似乎无法在文档中找到它,但是是否需要进行某种消毒?)
HTML escaping? (HTML转义?)
Removal of everything thats ^A-Za-z0-9
? (删除所有多数民众赞成^A-Za-z0-9
吗?)
What about non-html usage of <
, like <3
? (<
非html用法怎么样,例如<3
呢?)
What about unicode characters? (Unicode字符呢?)
I'm confused. (我糊涂了。)
EDIT: To answer my question, here is a little hack I wrote to combat the issue of Google hating on >
, <
characters.
(编辑:要回答我的问题,这是我写的一个小技巧,用于解决>
, <
字符上的Google仇恨问题。)
I simply replace them with different UNICODE characters that look similar. (我只是用看起来相似的不同UNICODE字符替换了它们。)
// < and > need to be stripped out, or the upload will throw 400 error
// https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:description
sanitize := func(val string) string {
replacements := map[string]string{
"<": "?",
">": "?",
}
for k, v := range replacements {
val = strings.Replace(val, k, v, -1)
}
return val
}
ask by if __name__ is None translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…