pull/586/head
FongMi 1 year ago
parent 26a9509e8b
commit 47023df72b
  1. 19
      app/src/main/java/com/fongmi/android/tv/player/extractor/TVBus.java

@ -1,15 +1,21 @@
package com.fongmi.android.tv.player.extractor;
import android.net.Uri;
import com.fongmi.android.tv.App;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.api.config.LiveConfig;
import com.fongmi.android.tv.bean.Core;
import com.fongmi.android.tv.exception.ExtractException;
import com.fongmi.android.tv.player.Source;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Path;
import com.google.gson.JsonObject;
import com.tvbus.engine.Listener;
import com.tvbus.engine.TVCore;
import java.io.File;
public class TVBus implements Source.Extractor, Listener {
private TVCore tvcore;
@ -23,13 +29,24 @@ public class TVBus implements Source.Extractor, Listener {
private void init(Core core) {
App.get().setHook(core.getHook());
tvcore = new TVCore(core.getSo());
tvcore = new TVCore(getPath(core.getSo()));
tvcore.auth(core.getAuth()).broker(core.getBroker());
tvcore.name(core.getName()).pass(core.getPass());
tvcore.serv(0).play(8902).mode(1).listener(this);
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 "";
}
}
@Override
public String fetch(String url) throws Exception {
if (core != null && !core.equals(LiveConfig.get().getHome().getCore())) change();

Loading…
Cancel
Save