|
@@ -107,11 +107,10 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
return queryStr;
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> subCommentList(String ksid, String photoId, Long rootCommentId, String pcursor) {
|
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ public Map<String, Object> subCommentList(String userId, String ksid, String photoId, Long rootCommentId, String pcursor) {
|
|
|
QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- queryWrapper.eq("user_id", user.getId());
|
|
|
+ queryWrapper.eq("user_id", userId);
|
|
|
queryWrapper.eq("ksid", ksid);
|
|
|
KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
|
|
|
if (kuaishouUserCookie != null) {
|
|
@@ -138,7 +137,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
if (resultNode.get("subCommentList").isNull() || resultNode.get("subCommentList").get("pcursor").isNull()) {
|
|
|
ipPool.setStatus(2);
|
|
|
iIpPoolService.updateById(ipPool);
|
|
|
- return subCommentList(ksid, photoId, rootCommentId, pcursor);
|
|
|
+ return subCommentList(userId, ksid, photoId, rootCommentId, pcursor);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -146,17 +145,16 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
ipPool.setStatus(2);
|
|
|
iIpPoolService.updateById(ipPool);
|
|
|
}
|
|
|
- return subCommentList(ksid, photoId, rootCommentId, pcursor);
|
|
|
+ return subCommentList(userId, ksid, photoId, rootCommentId, pcursor);
|
|
|
}
|
|
|
}
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> commentList(String ksid, String photoId, String pcursor) {
|
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ public Map<String, Object> commentList(String userId, String ksid, String photoId, String pcursor) {
|
|
|
QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- queryWrapper.eq("user_id", user.getId());
|
|
|
+ queryWrapper.eq("user_id", userId);
|
|
|
queryWrapper.eq("ksid", ksid);
|
|
|
KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
|
|
|
if (kuaishouUserCookie != null) {
|
|
@@ -193,7 +191,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
if (httpClientEntity.getResult() == null) {
|
|
|
ipPool.setStatus(2);
|
|
|
iIpPoolService.updateById(ipPool);
|
|
|
- return commentList(ksid, photoId, pcursor);
|
|
|
+ return commentList(userId, ksid, photoId, pcursor);
|
|
|
}
|
|
|
resultMap = mapper.readValue(httpClientEntity.getResult(), new TypeReference<Map<String, Object>>() {
|
|
|
});
|
|
@@ -201,7 +199,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
if (resultNode.get("shortVideoCommentList").isNull() || resultNode.get("shortVideoCommentList").get("pcursor").isNull()) {
|
|
|
ipPool.setStatus(2);
|
|
|
iIpPoolService.updateById(ipPool);
|
|
|
- return commentList(ksid, photoId, pcursor);
|
|
|
+ return commentList(userId, ksid, photoId, pcursor);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
if (ipPool != null) {
|
|
@@ -209,7 +207,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
iIpPoolService.updateById(ipPool);
|
|
|
}
|
|
|
e.printStackTrace();
|
|
|
- return commentList(ksid, photoId, pcursor);
|
|
|
+ return commentList(userId, ksid, photoId, pcursor);
|
|
|
}
|
|
|
}
|
|
|
return resultMap;
|
|
@@ -239,11 +237,11 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> videoList(String ksid, String pcursor) {
|
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ public Map<String, Object> videoList(String userId, String ksid, String pcursor) {
|
|
|
+
|
|
|
QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- queryWrapper.eq("user_id", user.getId());
|
|
|
+ queryWrapper.eq("user_id", userId);
|
|
|
queryWrapper.eq("ksid", ksid);
|
|
|
KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
|
|
|
if (kuaishouUserCookie != null) {
|
|
@@ -266,7 +264,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
if (httpClientEntity.getResult() == null) {
|
|
|
ipPool.setStatus(2);
|
|
|
iIpPoolService.updateById(ipPool);
|
|
|
- return videoList(ksid, pcursor);
|
|
|
+ return videoList(userId, ksid, pcursor);
|
|
|
}
|
|
|
Map<String, String> map = getTTfNumber(kuaishouUserCookie);
|
|
|
for (String key : map.keySet()) {
|
|
@@ -280,7 +278,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
if (resultNode.get("publicFeeds").isNull() || resultNode.get("publicFeeds").get("pcursor").isNull()) {
|
|
|
ipPool.setStatus(2);
|
|
|
iIpPoolService.updateById(ipPool);
|
|
|
- return videoList(ksid, pcursor);
|
|
|
+ return videoList(userId, ksid, pcursor);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
if (ipPool != null) {
|
|
@@ -288,7 +286,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
iIpPoolService.updateById(ipPool);
|
|
|
}
|
|
|
e.printStackTrace();
|
|
|
- return videoList(ksid, pcursor);
|
|
|
+ return videoList(userId, ksid, pcursor);
|
|
|
}
|
|
|
}
|
|
|
return resultMap;
|
|
@@ -337,11 +335,10 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
return kuaishouNumberMap.get(key);
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> commentDelete(String ksid, String photoId, Long commentId) {
|
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ public Map<String, Object> commentDelete(String userId, String ksid, String photoId, Long commentId) {
|
|
|
QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- queryWrapper.eq("user_id", user.getId());
|
|
|
+ queryWrapper.eq("user_id", userId);
|
|
|
queryWrapper.eq("ksid", ksid);
|
|
|
KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
|
|
|
if (kuaishouUserCookie != null) {
|
|
@@ -375,11 +372,18 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
resultMap = mapper.readValue(httpClientEntity.getResult(), new TypeReference<Map<String, Object>>() {
|
|
|
});
|
|
|
- if (((Integer) resultMap.get("result")) == 109) {
|
|
|
- ipPool.setStatus(2);
|
|
|
- iIpPoolService.updateById(ipPool);
|
|
|
- return commentDelete(ksid, photoId, commentId);
|
|
|
- }
|
|
|
+ Integer code = ((Integer) resultMap.get("result"));
|
|
|
+// if(code == 109){
|
|
|
+//
|
|
|
+// }
|
|
|
+// if (((Integer) resultMap.get("result")) == 109) {
|
|
|
+// reLogin(httpClientEntity,kuaishouUserCookie);
|
|
|
+// if(ipPool != null){
|
|
|
+// ipPool.setStatus(2);
|
|
|
+// iIpPoolService.updateById(ipPool);
|
|
|
+// }
|
|
|
+// return commentDelete(userId,ksid, photoId, commentId);
|
|
|
+// }
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -387,11 +391,10 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> commentAdd(String ksid, String photoId, String content, Long replyToCommentId, Long replyTo) {
|
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ public Map<String, Object> commentAdd(String userId, String ksid, String photoId, String content, Long replyToCommentId, Long replyTo) {
|
|
|
QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- queryWrapper.eq("user_id", user.getId());
|
|
|
+ queryWrapper.eq("user_id", userId);
|
|
|
queryWrapper.eq("ksid", ksid);
|
|
|
KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
|
|
|
if (kuaishouUserCookie != null) {
|
|
@@ -427,11 +430,12 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
resultMap = mapper.readValue(httpClientEntity.getResult(), new TypeReference<Map<String, Object>>() {
|
|
|
});
|
|
|
- if (((Integer) resultMap.get("result")) == 109) {
|
|
|
- ipPool.setStatus(2);
|
|
|
- iIpPoolService.updateById(ipPool);
|
|
|
- return commentAdd(ksid, photoId, content, replyToCommentId, replyTo);
|
|
|
- }
|
|
|
+// if (((Integer) resultMap.get("result")) == 109) {
|
|
|
+// reLogin(httpClientEntity,kuaishouUserCookie);
|
|
|
+// ipPool.setStatus(2);
|
|
|
+// iIpPoolService.updateById(ipPool);
|
|
|
+// return commentAdd(userId,ksid, photoId, content, replyToCommentId, replyTo);
|
|
|
+// }
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -985,6 +989,32 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
return httpClientEntity;
|
|
|
}
|
|
|
|
|
|
+ public HttpClientEntity reLogin(HttpClientEntity httpClientEntity, KuaishouUserCookie kuaishouUserCookie) throws Exception {
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ IpPool ipPool = iIpPoolService.getAvaliableIp();
|
|
|
+ params.put("sid", "kuaishou.live.web");
|
|
|
+ HttpClientUtils httpClientUtils = new HttpClientUtils();
|
|
|
+ httpClientEntity.setCloseableHttpClient(httpClientUtils.createSSLClientDefault(ipPool));
|
|
|
+ httpClientEntity.setUrl("https://id.kuaishou.com/pass/kuaishou/login/passToken");
|
|
|
+ httpClientEntity.setResult("");
|
|
|
+ httpClientEntity.setHeaders(getHeaders());
|
|
|
+ httpClientEntity.setParams(params);
|
|
|
+ httpClientEntity = httpClientUtils.httpPostParamRequest(httpClientEntity);
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ JsonNode jsonNode = mapper.readTree(httpClientEntity.getResult());
|
|
|
+ String at = jsonNode.get("kuaishou.live.web.at").asText();
|
|
|
+ httpClientEntity.setUrl("https://live.kuaishou.com/graphql");
|
|
|
+ httpClientEntity = httpClientUtils.callingGraph(httpClientEntity, userLogin(at));
|
|
|
+ httpClientEntity = httpClientUtils.callingGraph(httpClientEntity, userInfoQuery());
|
|
|
+ JsonNode userNode = mapper.readTree(httpClientEntity.getResult());
|
|
|
+ QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("user_id", kuaishouUserCookie.getUserId());
|
|
|
+ queryWrapper.eq("ksid", kuaishouUserCookie.getKsid());
|
|
|
+ kuaishouUserCookie.setCookie(new Gson().toJson(httpClientEntity.getCookieStore()));
|
|
|
+ kuaishouUserCookieService.update(kuaishouUserCookie, queryWrapper);
|
|
|
+ return httpClientEntity;
|
|
|
+ }
|
|
|
+
|
|
|
public Date getCST(String strGMT) throws ParseException {
|
|
|
if (strGMT == null) {
|
|
|
return null;
|
|
@@ -1008,6 +1038,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
|
return httpClientEntity;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public String qrLogin(String taskId) throws Exception {
|
|
|
HttpClientEntity httpClientEntity = this.kuaishouIndex();
|
|
|
httpClientEntity = this.kuaishouQrStart(httpClientEntity);
|