【发布时间】:2023-03-24 02:47:01
【问题描述】:
我有一个小型 AppEngine 应用程序,可让我将 YouTube 视频添加到 YouTube 播放列表。该应用通过 Java client library 使用 YouTube 数据 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时会抛出错误。
【问题讨论】:
标签: java youtube youtube-api gdata-api