java - 有关 google-api-java-client 的帮助

标签 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);
  }

}

但是缩略图不会被打印。

有什么问题吗?

最佳答案

是否是因为 Thumbnail.items 上缺少 @Key 注释?

关于java - 有关 google-api-java-client 的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4172348/

相关文章:

javascript - 如何使用Google Apps脚本将视频上传到YouTube?

api - YouTube channel 喜欢和不喜欢

java - 泛型类中出现意外的类型编译错误,可能的参数是什么?

java - app-context.xml 的完整 Java 配置,包括 jdbc 和 tx 指令等

java - 在java中无需迭代即可获取节点的xpath值

youtube - 使用youtube API登录并保存信息以供以后使用,例如为我的客户上传视频等

java - Apache POI - Excel 写入 - 锁定单个单元格

youtube - 为什么YouTube API使用刷新 token 来获取访问 token ?

python - 错误谷歌 API : "Credentials in post body and basic Authorization header do not match"

javascript - 在 angular service.ts 中使用谷歌的 api.js