Skip to content

Commit

Permalink
1. 动态UA
Browse files Browse the repository at this point in the history
  • Loading branch information
qaiu committed Dec 16, 2024
1 parent 5af402c commit 672f100
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion parser/src/main/java/cn/qaiu/entity/ShareLinkInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ public void setStandardUrl(String standardUrl) {

public String getCacheKey() {
// 将type和shareKey组合成一个字符串作为缓存key
return type + ":" + shareKey;
String key = type + ":" + shareKey;
if (type.equals("p115")) {
key += ("_" + otherParam.get("UA").toString().hashCode());
}
return key;
}

public ShareLinkInfo setOtherParam(Map<String, Object> otherParam) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Future<LinkInfoResp> parse(HttpServerRequest request, String pwd) {
.apiLink(getDownLink(parserCreate, true))
.shareLinkInfo(shareLinkInfo).build();
// 解析次数统计
shareLinkInfo.getOtherParam().put("UA",request.headers().get("user-agent"));
cacheManager.getShareKeyTotal(shareLinkInfo.getCacheKey()).onSuccess(res -> {
if (res != null) {
build.setCacheHitTotal(res.get("hit_total") == null ? 0: res.get("hit_total"));
Expand Down
1 change: 1 addition & 0 deletions web-service/src/main/resources/app-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ cache:
mne: 30
mqq: 30
mkg: 30
p115: 5

# httpClient静态代理服务器配置(外网代理)
proxy:
Expand Down

0 comments on commit 672f100

Please sign in to comment.