diff --git a/app/libs/tvbus-release.aar b/app/libs/tvbus-release.aar index b4501b472..412edd01b 100644 Binary files a/app/libs/tvbus-release.aar and b/app/libs/tvbus-release.aar differ diff --git a/app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java b/app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java index 5f0fb72e7..961874168 100644 --- a/app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java +++ b/app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java @@ -30,30 +30,26 @@ public class TVBus implements Source.Extractor, Listener { } private void init(Core core) { - App.get().setHook(core.getHook()); - tvcore = new TVCore(getPath(core.getSo())).listener(this); - tvcore.auth(core.getAuth()).name(core.getName()).pass(core.getPass()); - tvcore.domain(core.getDomain()).broker(core.getBroker()).serv(0).play(8902).mode(1); - tvcore.init(); - } - - private String getPath(String url) { try { - File file = new File(Path.so(), Uri.parse(url).getLastPathSegment()); - if (file.length() < 10240) Path.write(file, OkHttp.newCall(url).execute().body().bytes()); - return file.getAbsolutePath(); - } catch (Exception e) { - e.printStackTrace(); - return ""; + App.get().setHook(core.getHook()); + tvcore = new TVCore(getPath(core.getSo())).listener(this).auth(core.getAuth()).name(core.getName()).pass(core.getPass()).domain(core.getDomain()).broker(core.getBroker()).serv(0).play(8902).mode(1).init(); + } catch (Exception ignored) { + } finally { + App.get().setHook(null); } } + private String getPath(String url) throws Exception { + File file = new File(Path.so(), Uri.parse(url).getLastPathSegment()); + if (file.length() < 10240) Path.write(file, OkHttp.newCall(url).execute().body().bytes()); + return file.getAbsolutePath(); + } + @Override public String fetch(String url) throws Exception { Core c = LiveConfig.get().getHome().getCore(); if (core != null && !core.equals(c)) change(); if (tvcore == null) init(core = c); - App.get().setHook(null); tvcore.start(url); onWait(); onCheck(); diff --git a/tvbus/src/main/java/com/tvbus/engine/TVCore.java b/tvbus/src/main/java/com/tvbus/engine/TVCore.java index 8a8ce78c8..3069d9f45 100644 --- a/tvbus/src/main/java/com/tvbus/engine/TVCore.java +++ b/tvbus/src/main/java/com/tvbus/engine/TVCore.java @@ -6,14 +6,11 @@ import com.github.catvod.Init; public class TVCore { - private long handle; + private final long handle; public TVCore(String so) { - try { - System.load(so); - handle = initialise(); - } catch (Throwable ignored) { - } + System.load(so); + handle = initialise(); } public TVCore listener(Listener listener) { @@ -54,7 +51,7 @@ public class TVCore { public TVCore auth(String str) { try { - if (str.length() > 0) setAuthUrl(handle, str); + if (!str.isEmpty()) setAuthUrl(handle, str); return this; } catch (Throwable ignored) { return this; @@ -63,7 +60,7 @@ public class TVCore { public TVCore domain(String str) { try { - if (str.length() > 0) setDomainSuffix(handle, str); + if (!str.isEmpty()) setDomainSuffix(handle, str); return this; } catch (Throwable ignored) { return this; @@ -72,7 +69,7 @@ public class TVCore { public TVCore broker(String str) { try { - if (str.length() > 0) setMKBroker(handle, str); + if (!str.isEmpty()) setMKBroker(handle, str); return this; } catch (Throwable ignored) { return this; @@ -81,7 +78,7 @@ public class TVCore { public TVCore name(String str) { try { - if (str.length() > 0) setUsername(handle, str); + if (!str.isEmpty()) setUsername(handle, str); return this; } catch (Throwable ignored) { return this; @@ -90,15 +87,16 @@ public class TVCore { public TVCore pass(String str) { try { - if (str.length() > 0) setPassword(handle, str); + if (!str.isEmpty()) setPassword(handle, str); return this; } catch (Throwable ignored) { return this; } } - public void init() { + public TVCore init() { new Thread(this::start).start(); + return this; } private void start() {