|
|
|
|
@ -32,10 +32,12 @@ import androidx.annotation.Nullable; |
|
|
|
|
import androidx.lifecycle.Observer; |
|
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
|
|
|
|
|
|
import com.github.catvod.crawler.Spider; |
|
|
|
|
import com.github.tvbox.osc.R; |
|
|
|
|
import com.github.tvbox.osc.api.ApiConfig; |
|
|
|
|
import com.github.tvbox.osc.base.BaseActivity; |
|
|
|
|
import com.github.tvbox.osc.bean.ParseBean; |
|
|
|
|
import com.github.tvbox.osc.bean.SourceBean; |
|
|
|
|
import com.github.tvbox.osc.bean.VodInfo; |
|
|
|
|
import com.github.tvbox.osc.cache.CacheManager; |
|
|
|
|
import com.github.tvbox.osc.event.RefreshEvent; |
|
|
|
|
@ -284,6 +286,7 @@ public class PlayActivity extends BaseActivity { |
|
|
|
|
Bundle bundle = intent.getExtras(); |
|
|
|
|
mVodInfo = (VodInfo) bundle.getSerializable("VodInfo"); |
|
|
|
|
sourceKey = bundle.getString("sourceKey"); |
|
|
|
|
sourceBean = ApiConfig.get().getSource(sourceKey); |
|
|
|
|
initPlayerCfg(); |
|
|
|
|
play(); |
|
|
|
|
} |
|
|
|
|
@ -372,6 +375,7 @@ public class PlayActivity extends BaseActivity { |
|
|
|
|
private VodInfo mVodInfo; |
|
|
|
|
private JSONObject mVodPlayerCfg; |
|
|
|
|
private String sourceKey; |
|
|
|
|
private SourceBean sourceBean; |
|
|
|
|
|
|
|
|
|
private void playNext() { |
|
|
|
|
boolean hasNext = true; |
|
|
|
|
@ -510,7 +514,7 @@ public class PlayActivity extends BaseActivity { |
|
|
|
|
if (pb.getType() == 0) { |
|
|
|
|
setTip("正在嗅探播放地址", true, false); |
|
|
|
|
mHandler.removeMessages(100); |
|
|
|
|
mHandler.sendEmptyMessageDelayed(100, 15 * 1000); |
|
|
|
|
mHandler.sendEmptyMessageDelayed(100, 20 * 1000); |
|
|
|
|
loadWebView(pb.getUrl() + webUrl); |
|
|
|
|
} else if (pb.getType() == 1) { // json 解析
|
|
|
|
|
setTip("正在解析播放地址", true, false); |
|
|
|
|
@ -526,7 +530,7 @@ public class PlayActivity extends BaseActivity { |
|
|
|
|
reqHeaders.put(key, headerJson.optString(key, "")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (JSONException e) { |
|
|
|
|
} catch (Throwable e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
OkGo.<String>get(pb.getUrl() + webUrl) |
|
|
|
|
@ -564,7 +568,7 @@ public class PlayActivity extends BaseActivity { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
playUrl(rs.getString("url"), headers); |
|
|
|
|
} catch (JSONException e) { |
|
|
|
|
} catch (Throwable e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
errorWithRetry("解析错误", false); |
|
|
|
|
} |
|
|
|
|
@ -779,6 +783,15 @@ public class PlayActivity extends BaseActivity { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean checkVideoFormat(String url) { |
|
|
|
|
if (sourceBean.getType() == 3) { |
|
|
|
|
Spider sp = ApiConfig.get().getCSP(sourceBean); |
|
|
|
|
if (sp != null && sp.manualVideoCheck()) |
|
|
|
|
return sp.isVideoFormat(url); |
|
|
|
|
} |
|
|
|
|
return DefaultConfig.isVideoFormat(url); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class MyWebView extends WebView { |
|
|
|
|
public MyWebView(@NonNull Context context) { |
|
|
|
|
super(context); |
|
|
|
|
@ -900,7 +913,7 @@ public class PlayActivity extends BaseActivity { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!ad && !loadFound) { |
|
|
|
|
if (DefaultConfig.isVideoFormat(url)) { |
|
|
|
|
if (checkVideoFormat(url)) { |
|
|
|
|
mHandler.removeMessages(100); |
|
|
|
|
loadFound = true; |
|
|
|
|
if (headers != null && !headers.isEmpty()) { |
|
|
|
|
@ -1056,7 +1069,7 @@ public class PlayActivity extends BaseActivity { |
|
|
|
|
ad = loadedUrls.get(url); |
|
|
|
|
} |
|
|
|
|
if (!ad && !loadFound) { |
|
|
|
|
if (DefaultConfig.isVideoFormat(url)) { |
|
|
|
|
if (checkVideoFormat(url)) { |
|
|
|
|
mHandler.removeMessages(100); |
|
|
|
|
loadFound = true; |
|
|
|
|
HashMap<String, String> webHeaders = new HashMap<>(); |
|
|
|
|
|