|
|
|
|
@ -1,60 +1,15 @@ |
|
|
|
|
package com.github.catvod.utils; |
|
|
|
|
|
|
|
|
|
import android.text.TextUtils; |
|
|
|
|
|
|
|
|
|
import com.github.catvod.net.OkHttp; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
import okhttp3.OkHttpClient; |
|
|
|
|
import okhttp3.Response; |
|
|
|
|
|
|
|
|
|
public class Github { |
|
|
|
|
|
|
|
|
|
public static final int TIMEOUT = 5 * 1000; |
|
|
|
|
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 M = "FongMi/Release/main"; |
|
|
|
|
|
|
|
|
|
private final OkHttpClient client; |
|
|
|
|
private String proxy; |
|
|
|
|
|
|
|
|
|
private static class Loader { |
|
|
|
|
static volatile Github INSTANCE = new Github(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static Github get() { |
|
|
|
|
return Loader.INSTANCE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Github() { |
|
|
|
|
client = OkHttp.client(TIMEOUT); |
|
|
|
|
check(A); |
|
|
|
|
check(B); |
|
|
|
|
check(C); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void check(String url) { |
|
|
|
|
try { |
|
|
|
|
if (getProxy().length() > 0) return; |
|
|
|
|
Response response = OkHttp.newCall(client, url).execute(); |
|
|
|
|
if (response.code() == 200) setProxy(url); |
|
|
|
|
} catch (IOException ignored) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setProxy(String url) { |
|
|
|
|
this.proxy = url.equals(C) ? url + A + M : url + M; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getProxy() { |
|
|
|
|
return TextUtils.isEmpty(proxy) ? A + M : proxy; |
|
|
|
|
} |
|
|
|
|
public static final String URL = "https://fongmi.cachefly.net/FongMi/Release/main"; |
|
|
|
|
|
|
|
|
|
private static String getUrl(String path, String name) { |
|
|
|
|
return get().getProxy() + "/" + path + "/" + name; |
|
|
|
|
return URL + "/" + path + "/" + name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String getJson(boolean dev, String name) { |
|
|
|
|
|