mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-17 12:53:02 +00:00
1. add 网易云音乐解析
This commit is contained in:
@@ -52,15 +52,16 @@ public class CacheManager {
|
||||
}
|
||||
|
||||
// 写入网盘厂商API解析次数
|
||||
public Future<Integer> updateTotalByCached(String shareKey) {
|
||||
public Future<Integer> updateTotalByField(String shareKey, CacheTotalField field) {
|
||||
Promise<Integer> promise = Promise.promise();
|
||||
String fieldLower = field.name().toLowerCase();
|
||||
String sql = """
|
||||
MERGE INTO `api_statistics_info` (`pan_type`, `share_key`, `cache_hit_total`, `update_ts`)
|
||||
MERGE INTO `api_statistics_info` (`pan_type`, `share_key`, `{field}`, `update_ts`)
|
||||
KEY (`share_key`)
|
||||
VALUES (#{panType}, #{shareKey}, #{total}, #{ts})
|
||||
""";
|
||||
""".replace("field", fieldLower);
|
||||
|
||||
getShareKeyTotal(shareKey, "cache_hit_total").onSuccess(total -> {
|
||||
getShareKeyTotal(shareKey, fieldLower).onSuccess(total -> {
|
||||
Integer newTotal = (total == null ? 0 : total) + 1;
|
||||
SqlTemplate.forUpdate(jdbcPool, sql)
|
||||
.execute(new HashMap<>() {{
|
||||
@@ -81,30 +82,6 @@ public class CacheManager {
|
||||
return fullShareKey.split(":")[0];
|
||||
}
|
||||
|
||||
// 写入网盘厂商API解析次数
|
||||
public Future<Integer> updateTotalByParser(String shareKey) {
|
||||
Promise<Integer> promise = Promise.promise();
|
||||
String sql = """
|
||||
MERGE INTO `api_statistics_info` (`pan_type`, `share_key`, `api_parser_total`, `update_ts`)
|
||||
KEY (`share_key`)
|
||||
VALUES (#{panType}, #{shareKey}, #{total}, #{ts})
|
||||
""";
|
||||
|
||||
getShareKeyTotal(shareKey, "api_parser_total").onSuccess(total -> {
|
||||
Integer newTotal = (total == null ? 0 : total) + 1;
|
||||
SqlTemplate.forUpdate(jdbcPool, sql)
|
||||
.execute(new HashMap<>() {{
|
||||
put("panType", getShareType(shareKey));
|
||||
put("shareKey", shareKey);
|
||||
put("total", newTotal);
|
||||
put("ts", System.currentTimeMillis());
|
||||
}})
|
||||
.onSuccess(res -> promise.complete(res.rowCount()))
|
||||
.onFailure(Throwable::printStackTrace);
|
||||
});
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
public Future<Integer> getShareKeyTotal(String shareKey, String name) {
|
||||
String sql = """
|
||||
select `share_key`, sum({total_name}) sum_num
|
||||
|
||||
10
web-service/src/main/java/cn/qaiu/lz/common/cache/CacheTotalField.java
vendored
Normal file
10
web-service/src/main/java/cn/qaiu/lz/common/cache/CacheTotalField.java
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package cn.qaiu.lz.common.cache;
|
||||
|
||||
/**
|
||||
* 缓存字段
|
||||
*/
|
||||
public enum CacheTotalField {
|
||||
API_PARSER_TOTAL, // 解析次数
|
||||
CACHE_HIT_TOTAL, // 缓存次数
|
||||
FAILED_TOTAL // 解析失败次数
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package cn.qaiu.lz.web.service.impl;
|
||||
import cn.qaiu.entity.ShareLinkInfo;
|
||||
import cn.qaiu.lz.common.cache.CacheConfigLoader;
|
||||
import cn.qaiu.lz.common.cache.CacheManager;
|
||||
import cn.qaiu.lz.common.cache.CacheTotalField;
|
||||
import cn.qaiu.lz.web.model.CacheLinkInfo;
|
||||
import cn.qaiu.lz.web.service.CacheService;
|
||||
import cn.qaiu.parser.ParserCreate;
|
||||
@@ -46,12 +47,12 @@ public class CacheServiceImpl implements CacheService {
|
||||
"shareKey", cacheKey
|
||||
));
|
||||
cacheManager.cacheShareLink(cacheLinkInfo).onFailure(Throwable::printStackTrace);
|
||||
cacheManager.updateTotalByParser(cacheKey).onFailure(Throwable::printStackTrace);
|
||||
cacheManager.updateTotalByField(cacheKey, CacheTotalField.API_PARSER_TOTAL).onFailure(Throwable::printStackTrace);
|
||||
}).onFailure(promise::fail);
|
||||
} else {
|
||||
result.setExpires(generateDate(result.getExpiration()));
|
||||
promise.complete(result);
|
||||
cacheManager.updateTotalByCached(cacheKey).onFailure(Throwable::printStackTrace);
|
||||
cacheManager.updateTotalByField(cacheKey, CacheTotalField.CACHE_HIT_TOTAL).onFailure(Throwable::printStackTrace);
|
||||
}
|
||||
}).onFailure(t -> promise.fail(t.fillInStackTrace()));
|
||||
return promise.future();
|
||||
|
||||
@@ -54,8 +54,9 @@ cache:
|
||||
iz: 20
|
||||
le: 2879
|
||||
lz: 20
|
||||
qq: 999999
|
||||
qq: 9999999
|
||||
ws:
|
||||
ye:
|
||||
mne: 30
|
||||
|
||||
|
||||
|
||||
11
web-service/src/main/resources/http-tools/pan-mne.http
Normal file
11
web-service/src/main/resources/http-tools/pan-mne.http
Normal file
@@ -0,0 +1,11 @@
|
||||
#@no-redirect
|
||||
# https://y.music.163.com/m/song?id=472194327&uct2=qzCghKR6RWwXkHGVOZeRrg%3D%3D&fx-wechatnew=t1&fx-wxqd=c&fx-wordtest=&fx-listentest=t3&H5_DownloadVIPGift=&playerUIModeId=76001&PlayerStyles_SynchronousSharing=t3&dlt=0846&app_version=9.1.78&sc=wm&tn=
|
||||
http://163cn.tv/ykLZJJT
|
||||
|
||||
###
|
||||
#@no-redirect
|
||||
https://music.163.com/song?id=233334
|
||||
|
||||
###
|
||||
#@no-redirect
|
||||
https://music.163.com/song/media/outer/url?id=233334
|
||||
@@ -195,6 +195,11 @@ GET http://127.0.0.1:6401/json/parser?url=https://iwx.mail.qq.com/ftn/download?f
|
||||
GET http://127.0.0.1:6401/parser?url=https://474b.com/file/4015376-131945810
|
||||
|
||||
|
||||
### PASS MNE
|
||||
# @no-redirect
|
||||
GET http://127.0.0.1:6401/parser?url=http://163cn.tv/ykLZJJT
|
||||
|
||||
|
||||
|
||||
### n1
|
||||
http://127.0.0.1:6401/n1/statisticsInfo
|
||||
|
||||
@@ -15,7 +15,7 @@ proxy:
|
||||
# 1.origin代理地址端口后有目录(包括 / ),转发后地址:代理地址+访问URL目录部分去除location匹配目录
|
||||
# 2.origin代理地址端口后无任何,转发后地址:代理地址+访问URL目录部
|
||||
location:
|
||||
- path: ~^/(json/|v2/|parser|ye/|lz/|cow/|ec/|fj/|fc/|le/|qq/|ws/|iz/|ce/).*
|
||||
- path: ~^/(json/|v2/|parser|ye/|lz/|cow/|ec/|fj/|fc/|le/|qq/|ws/|iz/|ce|mne/).*
|
||||
origin: 127.0.0.1:6400
|
||||
|
||||
# json/parser -> xxx/parser
|
||||
|
||||
Reference in New Issue
Block a user