Update github path

pull/137/head
FongMi 3 years ago
parent 181d9f4b0c
commit 46ac7c8b20
  1. 18
      app/src/leanback/java/com/fongmi/android/tv/Updater.java
  2. 4
      app/src/main/java/com/fongmi/android/tv/utils/Utils.java
  3. 12
      app/src/mobile/java/com/fongmi/android/tv/Updater.java
  4. 21
      catvod/src/main/java/com/github/catvod/utils/Github.java

@ -25,7 +25,7 @@ public class Updater implements Download.Callback {
private DialogUpdateBinding binding;
private AlertDialog dialog;
private String branch;
private boolean dev;
private static class Loader {
static volatile Updater INSTANCE = new Updater();
@ -36,19 +36,15 @@ public class Updater implements Download.Callback {
}
private File getFile() {
return Path.cache(branch.concat(".apk"));
return Path.cache("update.apk");
}
private String getJson() {
return Github.getBranchPath(branch, "/release/" + BuildConfig.FLAVOR_mode + ".json");
return Github.getJson(dev, BuildConfig.FLAVOR_mode);
}
private String getApk() {
return Github.getBranchPath(branch, "/release/" + BuildConfig.FLAVOR_mode + "-" + BuildConfig.FLAVOR_api + "-" + BuildConfig.FLAVOR_abi + ".apk");
}
private Updater() {
this.branch = Github.RELEASE;
return Github.getApk(dev, BuildConfig.FLAVOR_mode + "-" + BuildConfig.FLAVOR_api + "-" + BuildConfig.FLAVOR_abi);
}
public Updater force() {
@ -58,12 +54,12 @@ public class Updater implements Download.Callback {
}
public Updater release() {
this.branch = Github.RELEASE;
this.dev = false;
return this;
}
public Updater dev() {
this.branch = Github.DEV;
this.dev = true;
return this;
}
@ -77,7 +73,7 @@ public class Updater implements Download.Callback {
}
private boolean need(int code, String name) {
return Setting.getUpdate() && (branch.equals(Github.DEV) ? !name.equals(BuildConfig.VERSION_NAME) && code >= BuildConfig.VERSION_CODE : code > BuildConfig.VERSION_CODE);
return Setting.getUpdate() && (dev ? !name.equals(BuildConfig.VERSION_NAME) && code >= BuildConfig.VERSION_CODE : code > BuildConfig.VERSION_CODE);
}
private void doInBackground() {

@ -136,6 +136,10 @@ public class Utils {
if (text.startsWith("上") || text.startsWith("下")) return -1;
if (text.contains(".")) text = text.substring(0, text.lastIndexOf("."));
if (text.startsWith("4k")) text = text.replace("4k", "");
if (text.contains("H264")) text = text.replace("H264", "");
if (text.contains("H265")) text = text.replace("H265", "");
if (text.contains("1080p")) text = 1080 + text.replace("1080p", "");
if (text.contains("2160p")) text = 2160 + text.replace("2160p", "");
return Integer.parseInt(text.replaceAll("\\D+", ""));
} catch (Exception e) {
return -1;

@ -26,7 +26,7 @@ public class Updater implements Download.Callback {
private DialogUpdateBinding binding;
private AlertDialog dialog;
private String branch;
private boolean dev;
private static class Loader {
static volatile Updater INSTANCE = new Updater();
@ -41,11 +41,11 @@ public class Updater implements Download.Callback {
}
private String getJson() {
return Github.getBranchPath(branch, "/release/" + BuildConfig.FLAVOR_mode + ".json");
return Github.getJson(dev, BuildConfig.FLAVOR_mode);
}
private String getApk() {
return Github.getBranchPath(branch, "/release/" + BuildConfig.FLAVOR_mode + "-" + BuildConfig.FLAVOR_api + "-" + BuildConfig.FLAVOR_abi + ".apk");
return Github.getApk(dev, BuildConfig.FLAVOR_mode + "-" + BuildConfig.FLAVOR_api + "-" + BuildConfig.FLAVOR_abi);
}
private Updater() {
@ -59,12 +59,12 @@ public class Updater implements Download.Callback {
}
public Updater release() {
this.branch = Github.RELEASE;
this.dev = false;
return this;
}
public Updater dev() {
this.branch = Github.DEV;
this.dev = true;
return this;
}
@ -78,7 +78,7 @@ public class Updater implements Download.Callback {
}
private boolean need(int code, String name) {
return Setting.getUpdate() && (branch.equals(Github.DEV) ? !name.equals(BuildConfig.VERSION_NAME) && code >= BuildConfig.VERSION_CODE : code > BuildConfig.VERSION_CODE);
return Setting.getUpdate() && (dev ? !name.equals(BuildConfig.VERSION_NAME) && code >= BuildConfig.VERSION_CODE : code > BuildConfig.VERSION_CODE);
}
private void doInBackground() {

@ -16,9 +16,7 @@ public class Github {
public static final String A = "https://raw.githubusercontent.com/";
public static final String B = "https://fongmi.cachefly.net/";
public static final String C = "https://ghproxy.com/";
public static final String REPO = "FongMi/TV/";
public static final String RELEASE = "release";
public static final String DEV = "dev";
public static final String M = "FongMi/Release/main";
private final OkHttpClient client;
private String proxy;
@ -48,26 +46,29 @@ public class Github {
}
private void setProxy(String url) {
this.proxy = url.equals(C) ? url + A + REPO : url + REPO;
this.proxy = url.equals(C) ? url + A + M : url + M;
}
private String getProxy() {
return TextUtils.isEmpty(proxy) ? "" : proxy;
}
public static String getReleasePath(String path) {
return get().getProxy() + RELEASE + path;
private static String getUrl(String path, String name) {
return get().getProxy() + "/" + path + "/" + name;
}
public static String getBranchPath(String branch, String path) {
return get().getProxy() + branch + path;
public static String getJson(boolean dev, String name) {
return getUrl("apk/" + (dev ? "dev" : "release"), name + ".json");
}
public static String getApk(boolean dev, String name) {
return getUrl("apk/" + (dev ? "dev" : "release"), name + ".apk");
}
public static String getSo(String name) {
try {
File file = Path.so(name);
String url = getReleasePath("/other/jniLibs/".concat(file.getName()));
if (file.length() < 300) Path.write(file, OkHttp.newCall(url).execute().body().bytes());
if (file.length() < 300) Path.write(file, OkHttp.newCall(getUrl("so", file.getName())).execute().body().bytes());
return file.getAbsolutePath();
} catch (Exception e) {
return "";

Loading…
Cancel
Save