Commit 569520e6b751aea2fbf0a483c396cd784a7ff087
1 parent
343edc2d
2022年7月1日18:55:34 增加将map数据写入配置文件接口
Showing
2 changed files
with
21 additions
and
8 deletions
src/main/java/cn/fw/freya/controller/KSController.java
... | ... | @@ -125,6 +125,14 @@ public class KSController { |
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | + * 将现有的签名信息map写入到配置文件中 | |
129 | + */ | |
130 | + @GetMapping("/writeMapToProperties") | |
131 | + public boolean writeMapToProperties() { | |
132 | + return kuaishouCrawl.writeMapToProperties(); | |
133 | + } | |
134 | + | |
135 | + /** | |
128 | 136 | * 获取账户直播回放地址 |
129 | 137 | * |
130 | 138 | * @param accountNo 账户号 | ... | ... |
src/main/java/cn/fw/freya/service/crawl/impl/KuaiShouCrawl.java
... | ... | @@ -125,8 +125,6 @@ public class KuaiShouCrawl implements CrawlStrategy, SmartLifecycle { |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * 停止设置sig3Map线程池 |
128 | - * | |
129 | - * @return | |
130 | 128 | */ |
131 | 129 | public boolean stopSetSig3Map() { |
132 | 130 | threadPoolExecutor.shutdownNow(); |
... | ... | @@ -135,8 +133,6 @@ public class KuaiShouCrawl implements CrawlStrategy, SmartLifecycle { |
135 | 133 | |
136 | 134 | /** |
137 | 135 | * 清空sig3Map |
138 | - * | |
139 | - * @return | |
140 | 136 | */ |
141 | 137 | public boolean cleanSig3Map() { |
142 | 138 | sig3Map.clear(); |
... | ... | @@ -166,6 +162,16 @@ public class KuaiShouCrawl implements CrawlStrategy, SmartLifecycle { |
166 | 162 | } |
167 | 163 | |
168 | 164 | /** |
165 | + * 将现有的签名信息map写入到配置文件中 | |
166 | + */ | |
167 | + public boolean writeMapToProperties() { | |
168 | + final HashMap<String, String> props = new HashMap<>(); | |
169 | + props.put("KSAccountNS_sig", JSON.toJSONString(sig3Map)); | |
170 | + updateProperties("NS_sig3Msg.properties", props); | |
171 | + return true; | |
172 | + } | |
173 | + | |
174 | + /** | |
169 | 175 | * 获取快手登录二维码 |
170 | 176 | * |
171 | 177 | * @param accountNo 账户号 |
... | ... | @@ -397,7 +403,8 @@ public class KuaiShouCrawl implements CrawlStrategy, SmartLifecycle { |
397 | 403 | params.put("count", 50); |
398 | 404 | params.put("page", 1); |
399 | 405 | params.put("kuaishou.web.cp.api_ph", this.getWebApiPh(accountNo)); |
400 | - HttpConfig config = HttpConfig.custom().url("https://cp.kuaishou.com/rest/cp/creator/analysis/live/pc/detail?__NS_sig3=" + ns_sig3) | |
406 | + HttpConfig config = HttpConfig.custom() | |
407 | + .url("https://cp.kuaishou.com/rest/cp/creator/analysis/live/pc/detail?__NS_sig3=" + ns_sig3) | |
401 | 408 | .context(cookies.getContext()) |
402 | 409 | .json(JsonUtils.objectToJson(params)) |
403 | 410 | .headers(HttpHeader |
... | ... | @@ -940,9 +947,7 @@ public class KuaiShouCrawl implements CrawlStrategy, SmartLifecycle { |
940 | 947 | log.info("springIOC停止, 将签名信息从Map中导出到配置文件"); |
941 | 948 | callback.run(); |
942 | 949 | isRunning = false; |
943 | - final HashMap<String, String> props = new HashMap<>(); | |
944 | - props.put("KSAccountNS_sig", JSON.toJSONString(sig3Map)); | |
945 | - updateProperties("NS_sig3Msg.properties", props); | |
950 | + this.writeMapToProperties(); | |
946 | 951 | } |
947 | 952 | |
948 | 953 | @Override | ... | ... |