投币操作工具类. @param bvid av号 @param multiply 投币数量 @param selectLike 是否同时点赞 1是 @return 是否投币成功
(String bvid, int multiply, int selectLike)
| 126 | * @return 是否投币成功 |
| 127 | */ |
| 128 | private boolean coinAdd(String bvid, int multiply, int selectLike) { |
| 129 | String videoTitle = OftenApi.getVideoTitle(bvid); |
| 130 | //判断曾经是否对此av投币过 |
| 131 | if (isCoinAdded(bvid)) { |
| 132 | Map<String, String> headers = new HashMap<>(10); |
| 133 | headers.put("Referer", "https://www.bilibili.com/video/" + bvid); |
| 134 | headers.put("Origin", "https://www.bilibili.com"); |
| 135 | |
| 136 | String requestBody = "aid=" + HelpUtil.bv2av(bvid) |
| 137 | + "&multiply=" + multiply |
| 138 | + "&select_like=" + selectLike |
| 139 | + "&cross_domain=" + "true" |
| 140 | + "&csrf=" + ConfigLoader.helperConfig.getBiliVerify().getBiliJct(); |
| 141 | |
| 142 | new VideoWatch().watchVideo(bvid); |
| 143 | JsonObject jsonObject = HttpUtils.doPost(ApiList.COIN_ADD, requestBody, headers); |
| 144 | if (jsonObject.get(STATUS_CODE_STR).getAsInt() == 0) { |
| 145 | log.info("为 " + videoTitle + " 投币成功"); |
| 146 | return true; |
| 147 | } else { |
| 148 | log.info("投币失败" + jsonObject.get("message").getAsString()); |
| 149 | return false; |
| 150 | } |
| 151 | } else { |
| 152 | log.info("已经为" + videoTitle + "投过币了"); |
| 153 | return false; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | @Override |
| 158 | public String getName() { |
no test coverage detected