请求视频title,未获取到时返回bvid. @return title
(String bvid)
| 58 | * @return title |
| 59 | */ |
| 60 | public static String getVideoTitle(String bvid) { |
| 61 | String title; |
| 62 | String urlParameter = "?bvid=" + bvid; |
| 63 | JsonObject jsonObject = HttpUtils.doGet(ApiList.VIDEO_VIEW + urlParameter); |
| 64 | |
| 65 | if (jsonObject.get("code").getAsInt() == 0) { |
| 66 | title = jsonObject.getAsJsonObject("data").getAsJsonObject("owner").get("name").getAsString() + ": "; |
| 67 | title += jsonObject.getAsJsonObject("data").get("title").getAsString(); |
| 68 | } else { |
| 69 | title = "未能获取标题"; |
| 70 | log.info(title); |
| 71 | log.debug(jsonObject.get("message").getAsString()); |
| 72 | } |
| 73 | |
| 74 | return title.replace("&", "-"); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * query username. |
no test coverage detected