Adding YouTube video to a playlist throws InvalidEntryException
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(ne开发者_StackOverflow中文版w 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.
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.
精彩评论