有关 google-api-java-client 的帮助
我正在尝试解析 YouTube 视频源,并为每个视频打印其缩略图列表。 我已经尝试过类似的方法:
public static class VideoFeed {
@Key List<Video> items;
}
public static class Video {
@Key String title;
@Key String description;
@Key DateTime uploaded;
@Key Player player;
@Key Thumbnail thumbnail;
}
public static class Player {
@Key("default") String defaultUrl;
}
public static class Thumbnail{
List<Thumb> items = new ArrayList<Thumb>();
}
public static class Thumb extends GenericJson{
@Key("default") String defaultUrl;
@Key Integer height;
@Key Integer width;
@Key String time;
}
并打印它
for (Video video : feed.items) {
System.out.println();
System.out.println("Video title: " + video.title);
System.out.println("Uploaded: " + video.uploaded);
System.out.println("URL: " + video.player.defaultUrl);
Thumbnail thumbnails = video.thumbnail;
for (Thumb thumb : thumbnails.items){
System.out.println("Thumbnail: "+thumb.defaultUrl);
}
}
但缩略图没有被打印。
有什么问题吗?
I'm trying to parse a youtube video feed, and for each video print the list of its thumbnails.
I've tried something like that:
public static class VideoFeed {
@Key List<Video> items;
}
public static class Video {
@Key String title;
@Key String description;
@Key DateTime uploaded;
@Key Player player;
@Key Thumbnail thumbnail;
}
public static class Player {
@Key("default") String defaultUrl;
}
public static class Thumbnail{
List<Thumb> items = new ArrayList<Thumb>();
}
public static class Thumb extends GenericJson{
@Key("default") String defaultUrl;
@Key Integer height;
@Key Integer width;
@Key String time;
}
and print it
for (Video video : feed.items) {
System.out.println();
System.out.println("Video title: " + video.title);
System.out.println("Uploaded: " + video.uploaded);
System.out.println("URL: " + video.player.defaultUrl);
Thumbnail thumbnails = video.thumbnail;
for (Thumb thumb : thumbnails.items){
System.out.println("Thumbnail: "+thumb.defaultUrl);
}
}
But the thumbnails don't get printed.
What's the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是因为您缺少 Thumbnail.items 上的 @Key 注释吗?
Is it because you are missing the @Key annotation on the Thumbnail.items?