This commit is contained in:
GH Action - Upstream Sync 2023-12-15 01:14:19 +00:00
commit f48a2b80bf
6 changed files with 20 additions and 20 deletions

View File

@ -328,7 +328,7 @@ public class AliYun {
public String getShareDownloadUrl(String shareId, String fileId) {
try {
if (shareDownloadMap.containsKey(fileId) && shareDownloadMap.get(fileId) != null && !isExpire(shareDownloadMap.get(fileId), 600)) return shareDownloadMap.get(fileId);
if (shareDownloadMap.containsKey(fileId) && shareDownloadMap.get(fileId) != null && !isExpire(shareDownloadMap.get(fileId))) return shareDownloadMap.get(fileId);
refreshShareToken(shareId);
SpiderDebug.log("getShareDownloadUrl..." + fileId);
JsonObject param = new JsonObject();
@ -347,7 +347,7 @@ public class AliYun {
public String getDownloadUrl(String shareId, String fileId) {
try {
if (downloadMap.containsKey(fileId) && downloadMap.get(fileId) != null && !isExpire(downloadMap.get(fileId), 900)) return downloadMap.get(fileId);
if (downloadMap.containsKey(fileId) && downloadMap.get(fileId) != null && !isExpire(downloadMap.get(fileId))) return downloadMap.get(fileId);
refreshShareToken(shareId);
SpiderDebug.log("getDownloadUrl..." + fileId);
tempIds.add(0, copy(shareId, fileId));
@ -449,7 +449,11 @@ public class AliYun {
}
private String proxyVideoUrl(String cate, String shareId, String fileId) {
return String.format(Proxy.getUrl() + "?do=ali&type=video&cate=%s&shareId=%s&fileId=%s", cate, shareId, fileId);
int thread = 1;
String url = String.format(Proxy.getUrl() + "?do=ali&type=video&cate=%s&shareId=%s&fileId=%s", cate, shareId, fileId);
if ("open".equals(cate)) thread = 10;
if ("share".equals(cate)) thread = 10;
return thread == 1 ? url : ProxyVideo.url(url, thread);
}
private String proxyVideoUrl(String cate, String shareId, String fileId, String templateId) {
@ -460,10 +464,10 @@ public class AliYun {
return String.format(Proxy.getUrl() + "?do=ali&type=video&cate=%s&shareId=%s&fileId=%s&templateId=%s&mediaId=%s", cate, shareId, fileId, templateId, mediaId);
}
private static boolean isExpire(String url, int time) {
private static boolean isExpire(String url) {
String expires = new UrlQuerySanitizer(url).getValue("x-oss-expires");
if (TextUtils.isEmpty(expires)) return false;
return Long.parseLong(expires) - getTimeStamp() <= time / 60;
return Long.parseLong(expires) - getTimeStamp() <= 60;
}
private static long getTimeStamp() {
@ -477,22 +481,19 @@ public class AliYun {
String fileId = params.get("fileId");
String cate = params.get("cate");
String downloadUrl = "";
int thread = 1;
if ("preview".equals(cate)) {
return previewProxy(shareId, fileId, templateId);
}
if ("open".equals(cate)) {
thread = 10;
downloadUrl = getDownloadUrl(shareId, fileId);
} else if ("share".equals(cate)) {
thread = 10;
downloadUrl = getShareDownloadUrl(shareId, fileId);
} else if ("m3u8".equals(cate)) {
lock.lock();
String mediaUrl = m3u8MediaMap.get(fileId).get(mediaId);
if (isExpire(mediaUrl, 900)) {
if (isExpire(mediaUrl)) {
getM3u8(shareId, fileId, templateId);
mediaUrl = m3u8MediaMap.get(fileId).get(mediaId);
}
@ -512,12 +513,7 @@ public class AliYun {
headers.remove("templateId");
headers.remove("remote-addr");
headers.remove("http-client-ip");
if (thread == 1) {
return new Object[]{ProxyVideo.proxy(downloadUrl, headers)};
} else {
return new Object[]{ProxyVideo.multi(downloadUrl, headers, thread)};
}
return new Object[]{ProxyVideo.proxy(downloadUrl, headers)};
}
private Object[] previewProxy(String shareId, String fileId, String templateId) {

View File

@ -19,10 +19,14 @@ public class ProxyVideo {
private static final String GO_SERVER = "http://127.0.0.1:7777/";
public static NanoHTTPD.Response multi(String url, Map<String, String> headers, int thread) throws Exception {
public static void go() {
if (OkHttp.string(GO_SERVER).isEmpty()) OkHttp.string("http://127.0.0.1:" + Proxy.getPort() + "/go");
while (OkHttp.string(GO_SERVER).isEmpty()) SystemClock.sleep(20);
return proxy(String.format(Locale.getDefault(), "%s?url=%s&thread=%d", GO_SERVER, URLEncoder.encode(url), thread), headers);
}
public static String url(String url, int thread) {
go();
return String.format(Locale.getDefault(), "%s?url=%s&thread=%d", GO_SERVER, URLEncoder.encode(url), thread);
}
public static NanoHTTPD.Response proxy(String url, Map<String, String> headers) throws Exception {

Binary file not shown.

View File

@ -1 +1 @@
430c09fd9d279d1b5d1fdebbae7e1d67
5d1ab45ff233a49e9bc9b9a1554b38a9

View File

@ -1,5 +1,5 @@
{
"spider": "https://fm.t4tv.hz.cz/jar/custom_spider.jar;md5;430c09fd9d279d1b5d1fdebbae7e1d67",
"spider": "https://fm.t4tv.hz.cz/jar/custom_spider.jar;md5;5d1ab45ff233a49e9bc9b9a1554b38a9",
"wallpaper": "https://gao.chuqiuyu.workers.dev",
"sites": [
{

View File

@ -1,5 +1,5 @@
{
"spider": "https://fm.t4tv.hz.cz/jar/custom_spider.jar;md5;430c09fd9d279d1b5d1fdebbae7e1d67",
"spider": "https://fm.t4tv.hz.cz/jar/custom_spider.jar;md5;5d1ab45ff233a49e9bc9b9a1554b38a9",
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
"sites": [
{