mirror of https://github.com/FongMi/TV.git
parent
459bf1b8d8
commit
d957c8cd27
@ -0,0 +1,70 @@ |
||||
package com.fongmi.android.tv.player.source; |
||||
|
||||
import android.net.Uri; |
||||
|
||||
import com.fongmi.android.tv.App; |
||||
import com.fongmi.android.tv.BuildConfig; |
||||
import com.fongmi.android.tv.utils.FileUtil; |
||||
import com.fongmi.android.tv.utils.Github; |
||||
import com.github.catvod.net.OkHttp; |
||||
import com.p2p.P2PClass; |
||||
|
||||
import java.io.File; |
||||
import java.net.URLDecoder; |
||||
import java.net.URLEncoder; |
||||
|
||||
public class JianPian { |
||||
|
||||
private P2PClass p2p; |
||||
private String url; |
||||
|
||||
private static class Loader { |
||||
static volatile JianPian INSTANCE = new JianPian(); |
||||
} |
||||
|
||||
public static JianPian get() { |
||||
return Loader.INSTANCE; |
||||
} |
||||
|
||||
private void init() throws Exception { |
||||
if (p2p != null) return; |
||||
String name = "libp2p-jp-" + BuildConfig.FLAVOR_abi + ".so"; |
||||
File file = FileUtil.getCacheFile(name); |
||||
String path = Github.get().getReleasePath("/other/jniLibs/" + file.getName()); |
||||
if (!file.exists()) FileUtil.write(file, OkHttp.newCall(path).execute().body().bytes()); |
||||
p2p = new P2PClass(App.get(), file.getAbsolutePath()); |
||||
} |
||||
|
||||
public String fetch(String text) throws Exception { |
||||
init(); |
||||
stop(); |
||||
set(text); |
||||
start(); |
||||
return "http://127.0.0.1:" + p2p.port + "/" + URLEncoder.encode(Uri.parse(url).getLastPathSegment(), "GBK"); |
||||
} |
||||
|
||||
private void set(String text) { |
||||
url = URLDecoder.decode(text).replace("tvbox-xg:", ""); |
||||
} |
||||
|
||||
private void start() { |
||||
try { |
||||
if (p2p == null || url == null) return; |
||||
p2p.P2Pdoxstart(url.getBytes("GBK")); |
||||
p2p.P2Pdoxadd(url.getBytes("GBK")); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public void stop() { |
||||
try { |
||||
if (p2p == null || url == null) return; |
||||
p2p.P2Pdoxpause(url.getBytes("GBK")); |
||||
p2p.P2Pdoxdel(url.getBytes("GBK")); |
||||
url = null; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,65 @@ |
||||
package com.fongmi.android.tv.player.source; |
||||
|
||||
import android.net.Uri; |
||||
|
||||
public class Source { |
||||
|
||||
private static String getScheme(Uri uri) { |
||||
return uri.getScheme().toLowerCase(); |
||||
} |
||||
|
||||
private static boolean isHttp(Uri uri) { |
||||
return getScheme(uri).startsWith("http"); |
||||
} |
||||
|
||||
private static boolean isForce(Uri uri) { |
||||
return getScheme(uri).startsWith("p") || getScheme(uri).equals("mitv"); |
||||
} |
||||
|
||||
private static boolean isZLive(Uri uri) { |
||||
return getScheme(uri).startsWith("zlive"); |
||||
} |
||||
|
||||
private static boolean isTVBus(Uri uri) { |
||||
return getScheme(uri).startsWith("tvbus"); |
||||
} |
||||
|
||||
private static boolean isYoutube(Uri uri) { |
||||
return uri.getHost().contains("youtube.com"); |
||||
} |
||||
|
||||
private static boolean isBiliBili(Uri uri) { |
||||
return uri.getHost().equals("live.bilibili.com"); |
||||
} |
||||
|
||||
private static boolean isJianPian(Uri uri) { |
||||
return uri.getScheme().equals("tvbox-xg"); |
||||
} |
||||
|
||||
public static String getUrl(String url) throws Exception { |
||||
Uri uri = Uri.parse(url); |
||||
if (isHttp(uri)) { |
||||
if (isYoutube(uri)) return Youtube.get().fetch(url); |
||||
else if (isBiliBili(uri)) return BiliBili.get().fetch(url); |
||||
else return url; |
||||
} else { |
||||
if (isForce(uri)) return Force.get().fetch(url); |
||||
else if (isZLive(uri)) return ZLive.get().fetch(url); |
||||
else if (isTVBus(uri)) return TVBus.get().fetch(url); |
||||
else if (isJianPian(uri)) return JianPian.get().fetch(url); |
||||
else return url; |
||||
} |
||||
} |
||||
|
||||
public static void stop() { |
||||
TVBus.get().stop(); |
||||
JianPian.get().stop(); |
||||
} |
||||
|
||||
public static void stopAll() { |
||||
Force.get().stop(); |
||||
ZLive.get().stop(); |
||||
TVBus.get().stop(); |
||||
JianPian.get().stop(); |
||||
} |
||||
} |
||||
@ -1,30 +0,0 @@ |
||||
package com.github.catvod.spider; |
||||
|
||||
import com.github.catvod.net.OkHttp; |
||||
|
||||
public class Proxy { |
||||
|
||||
private static int port; |
||||
|
||||
static void adjustPort() throws Exception { |
||||
if (port > 0) return; |
||||
int port = 9978; |
||||
while (port < 10000) { |
||||
String resp = OkHttp.newCall("http://127.0.0.1:" + port + "/proxy?do=port").execute().body().string(); |
||||
if (resp.equals("ok")) { |
||||
Proxy.port = port; |
||||
break; |
||||
} |
||||
port++; |
||||
} |
||||
} |
||||
|
||||
public static String getUrl() { |
||||
try { |
||||
adjustPort(); |
||||
return "http://127.0.0.1:" + port + "/proxy"; |
||||
} catch (Exception e) { |
||||
return "http://127.0.0.1:9978/proxy"; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
package com.hiker.drpy; |
||||
|
||||
import com.github.catvod.net.OkHttp; |
||||
|
||||
public class Proxy { |
||||
|
||||
private static int port; |
||||
|
||||
static void tryPort() { |
||||
if (port > 0) return; |
||||
int port = 9978; |
||||
while (port < 9999) { |
||||
boolean ok = string().equals("ok"); |
||||
if (ok) Proxy.port = port; |
||||
if (ok) break; |
||||
port++; |
||||
} |
||||
} |
||||
|
||||
private static String string() { |
||||
try { |
||||
return OkHttp.newCall("http://127.0.0.1:" + port + "/proxy?do=port").execute().body().string(); |
||||
} catch (Exception e) { |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
public static String getUrl() { |
||||
tryPort(); |
||||
return "http://127.0.0.1:" + port + "/proxy"; |
||||
} |
||||
} |
||||
@ -1,4 +1,175 @@ |
||||
package com.p2p; |
||||
|
||||
import android.content.Context; |
||||
|
||||
import java.io.File; |
||||
|
||||
public class P2PClass { |
||||
|
||||
public String path; |
||||
public int port; |
||||
|
||||
public P2PClass(Context context, String so) { |
||||
System.load(so); |
||||
String cache = context.getCacheDir().getAbsolutePath(); |
||||
File file = new File(path = cache + "/jpali"); |
||||
if (!file.exists()) file.mkdirs(); |
||||
port = doxstarthttpd("TEST3E63BAAECDAA79BEAA91853490A69F08".getBytes(), cache.getBytes()); |
||||
} |
||||
|
||||
public int P2Pdoxstart(byte[] bArr) { |
||||
return doxstart(bArr); |
||||
} |
||||
|
||||
public int P2Pdoxdownload(byte[] bArr) { |
||||
return doxdownload(bArr); |
||||
} |
||||
|
||||
public int P2Pdoxterminate() { |
||||
return doxterminate(); |
||||
} |
||||
|
||||
public int P2Pdosetupload(int i) { |
||||
return dosetupload(i); |
||||
} |
||||
|
||||
public int P2Pdoxcheck(byte[] bArr) { |
||||
return doxcheck(bArr); |
||||
} |
||||
|
||||
public int P2Pdoxadd(byte[] bArr) { |
||||
return doxadd(bArr); |
||||
} |
||||
|
||||
public int P2Pdoxpause(byte[] bArr) { |
||||
return doxpause(bArr); |
||||
} |
||||
|
||||
public int P2Pdoxdel(byte[] bArr) { |
||||
return doxdel(bArr); |
||||
} |
||||
|
||||
public int P2PdoxdelAll() { |
||||
return doxdelall(); |
||||
} |
||||
|
||||
public long P2Pgetspeed(int i) { |
||||
return getspeed(i); |
||||
} |
||||
|
||||
public long P2Pgetdownsize(int i) { |
||||
return getdownsize(i); |
||||
} |
||||
|
||||
public long P2Pgetfilesize(int i) { |
||||
return getfilesize(i); |
||||
} |
||||
|
||||
public int P2Pgetpercent() { |
||||
return getpercent(); |
||||
} |
||||
|
||||
public long P2Pgetlocalfilesize(byte[] bArr) { |
||||
return getlocalfilesize(bArr); |
||||
} |
||||
|
||||
public long P2Pdosetduration(int i) { |
||||
return doxsetduration(i); |
||||
} |
||||
|
||||
public String getServiceAddress() { |
||||
return doxgethostbynamehook("xx0.github.com"); |
||||
} |
||||
|
||||
public int P2Pdoxstarthttpd(byte[] bArr, byte[] bArr2) { |
||||
return doxstarthttpd(bArr, bArr2); |
||||
} |
||||
|
||||
public int P2Pdoxsave() { |
||||
return doxsave(); |
||||
} |
||||
|
||||
public int P2Pdoxendhttpd() { |
||||
return doxendhttpd(); |
||||
} |
||||
|
||||
public String getVersion() { |
||||
return doxgetVersion(); |
||||
} |
||||
|
||||
public long xGFilmOpenFile(byte[] bArr) { |
||||
return XGFilmOpenFile(bArr); |
||||
} |
||||
|
||||
public void xGFilmCloseFile(long j) { |
||||
XGFilmCloseFile(j); |
||||
} |
||||
|
||||
public int xGFilmReadFile(long j, long j2, int i, byte[] bArr) { |
||||
return XGFilmReadFile(j, j2, i, bArr); |
||||
} |
||||
|
||||
public void setP2PPauseUpdate(int i) { |
||||
doxSetP2PPauseUpdate(i); |
||||
} |
||||
|
||||
public String getTouPingUrl() { |
||||
return doxgetlocalAddress(); |
||||
} |
||||
|
||||
public String P2Pdoxgettaskstat(int i) { |
||||
return doxgettaskstat(i); |
||||
} |
||||
|
||||
private native void XGFilmCloseFile(long j); |
||||
|
||||
private native long XGFilmOpenFile(byte[] bArr); |
||||
|
||||
private native int XGFilmReadFile(long j, long j2, int i, byte[] bArr); |
||||
|
||||
private native int dosetupload(int i); |
||||
|
||||
private native void doxSetP2PPauseUpdate(int i); |
||||
|
||||
private native int doxadd(byte[] bArr); |
||||
|
||||
private native int doxcheck(byte[] bArr); |
||||
|
||||
private native int doxdel(byte[] bArr); |
||||
|
||||
private native int doxdelall(); |
||||
|
||||
private native int doxdownload(byte[] bArr); |
||||
|
||||
private native int doxendhttpd(); |
||||
|
||||
private native String doxgetVersion(); |
||||
|
||||
private native String doxgethostbynamehook(String str); |
||||
|
||||
private native String doxgetlocalAddress(); |
||||
|
||||
private native String doxgettaskstat(int i); |
||||
|
||||
private native int doxpause(byte[] bArr); |
||||
|
||||
private native int doxsave(); |
||||
|
||||
private native int doxsetduration(int i); |
||||
|
||||
private native int doxstart(byte[] bArr); |
||||
|
||||
private native int doxstarthttpd(byte[] bArr, byte[] bArr2); |
||||
|
||||
private native int doxterminate(); |
||||
|
||||
private native long getdownsize(int i); |
||||
|
||||
private native long getfilesize(int i); |
||||
|
||||
private native long getlocalfilesize(byte[] bArr); |
||||
|
||||
private native int getpercent(); |
||||
|
||||
private native long getspeed(int i); |
||||
} |
||||
|
||||
Loading…
Reference in new issue