帮助google-api-java-client

时间:2010-11-13 11:47:11

标签: java youtube google-api gdata 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);
  }

}

但是缩略图没有打印出来。

有什么问题?

1 个答案:

答案 0 :(得分:1)

是因为你错过了Thumbnail.items上的@Key注释吗?