将 YouTube 视频添加到播放列表会引发 InvalidEntryException
我有一个小型 AppEngine 应用程序,可让我将 YouTube 视频添加到 YouTube 播放列表。该应用通过Java 客户端库使用 YouTube Data API。该应用程序运行得很好,直到几周前出现了一些问题,当时 API 发生了某种变化,并且有必要更新 gdata jar 来解决问题。然而,有一个持续存在的错误不断出现。
对于某些视频,应用程序会抛出 InvalidEntryException。 响应正文是
<errors xmlns='http://schemas.google.com/g/2005'>
<error>
<domain>GData</domain>
<code>InvalidEntryException</code>
<internalReason>Validation failed</internalReason>
</error>
</errors>
我无法找到有关此错误的任何信息。另外,视频似乎也没有问题。
负责将视频添加到播放列表的代码:
String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/" + videoId;
VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class);
PlaylistEntry playlistEntry = new PlaylistEntry(videoEntry);
String playlistURL = "http://gdata.youtube.com/feeds/api/playlists/" + playlistId;
service.insert(new URL(playlistURL), playlistEntry);
调用 service.insert
时会抛出错误。
I have a small AppEngine app that enables me to add YouTube videos to a YouTube playlist. The app uses YouTube Data API through Java client library. The app worked great until some problems appeared few weeks ago when the API was somehow changed and it was necessary to update gdata jars to fix the problems. However there's one ramaining bug that keeps appearing.
For some videos the app throws InvalidEntryException.
The response body is
<errors xmlns='http://schemas.google.com/g/2005'>
<error>
<domain>GData</domain>
<code>InvalidEntryException</code>
<internalReason>Validation failed</internalReason>
</error>
</errors>
I wasn't able to find any information on this error. Also, it doesn't seem that there is a problem with the videos.
Code responsible for adding the videos to the playlist:
String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/" + videoId;
VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class);
PlaylistEntry playlistEntry = new PlaylistEntry(videoEntry);
String playlistURL = "http://gdata.youtube.com/feeds/api/playlists/" + playlistId;
service.insert(new URL(playlistURL), playlistEntry);
The error is throws when service.insert
is called.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我向 Google 报告了这个问题,结果发现这是一个错误。感谢 YouTube 团队很快就修复了这个问题。异常不再出现。
I reported the problem to Google and it turned out to be a bug. Thanks to the YouTube team that fixed it soon afterwards. The exception isn't appearing any more.