From e55033595a51237cced5bd7ad5f768fe93c2feac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E4=BF=8A?= <215613905@qq.com> Date: Tue, 15 Nov 2022 11:07:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81jar=E5=9B=BE=E5=BA=8A(img+?= =?UTF-8?q?=E5=BC=80=E5=A4=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/tvbox/osc/api/ApiConfig.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java b/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java index 21fd60ca..baf25fa4 100644 --- a/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java +++ b/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java @@ -114,6 +114,16 @@ public class ApiConfig { return json; } + private static byte[] getImgJar(String body){ + Pattern pattern = Pattern.compile("[A-Za-z0]{8}\\*\\*"); + Matcher matcher = pattern.matcher(body); + if(matcher.find()){ + body = body.substring(body.indexOf(matcher.group()) + 10); + return Base64.decode(body, Base64.DEFAULT); + } + return "".getBytes(); + } + public void loadConfig(boolean useCache, LoadConfigCallback callback, Activity activity) { String apiUrl = Hawk.get(HawkConfig.API_URL, ""); if (apiUrl.isEmpty()) { @@ -229,6 +239,8 @@ public class ApiConfig { } } + boolean isJarInImg = jarUrl.startsWith("img+"); + jarUrl = jarUrl.replace("img+", ""); OkGo.get(jarUrl) .headers("User-Agent", userAgent) .headers("Accept", requestAccept) @@ -242,7 +254,13 @@ public class ApiConfig { if (cache.exists()) cache.delete(); FileOutputStream fos = new FileOutputStream(cache); - fos.write(response.body().bytes()); + if(isJarInImg) { + String respData = response.body().string(); + byte[] imgJar = getImgJar(respData); + fos.write(imgJar); + } else { + fos.write(response.body().bytes()); + } fos.flush(); fos.close(); return cache;