Merge branch 'q215613905:main' into main

pull/102/head
watson1982 2 years ago committed by GitHub
commit e379fda0cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/build.gradle
  2. 8
      app/proguard-rules.pro
  3. 8
      app/src/main/java/com/github/tvbox/osc/base/App.java
  4. 2
      app/src/main/java/com/github/tvbox/osc/player/thirdparty/RemoteTVBox.java
  5. 15
      app/src/main/java/com/github/tvbox/osc/server/RemoteServer.java
  6. 34
      app/src/main/java/com/github/tvbox/osc/subtitle/SubtitleLoader.java
  7. 6
      app/src/main/java/com/github/tvbox/osc/ui/activity/FastSearchActivity.java
  8. 1
      app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java
  9. 32
      app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java
  10. 32
      app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java
  11. 15
      app/src/main/java/com/github/tvbox/osc/ui/fragment/GridFragment.java
  12. 34
      app/src/main/java/com/github/tvbox/osc/ui/fragment/PlayFragment.java
  13. 7
      app/src/main/java/com/github/tvbox/osc/ui/fragment/UserFragment.java
  14. 7
      app/src/main/java/com/github/tvbox/osc/util/FileUtils.java
  15. 122
      app/src/main/java/com/github/tvbox/osc/viewmodel/SourceViewModel.java
  16. 4
      player/src/main/java/xyz/doikki/videoplayer/exo/ExoMediaSourceHelper.java

@ -63,7 +63,7 @@ dependencies {
implementation 'org.nanohttpd:nanohttpd:2.3.1'
implementation 'com.google.zxing:core:3.4.1'
implementation 'com.google.zxing:core:3.3.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'

@ -204,4 +204,10 @@
# quickjs引擎
-keep class com.github.tvbox.quickjs.** {*;}
# 支持影视的ali相关的jar
-keep class com.google.gson.**{*;}
-keep class com.google.gson.**{*;}
# Zxing
-keep class com.google.zxing.**{*;}
-keepclassmembers enum * {
public static [] values();
public static ** valueOf(java.lang.String);
}

@ -33,6 +33,7 @@ public class App extends MultiDexApplication {
private static P2PClass p;
public static String burl;
private static String dashData;
@Override
public void onCreate() {
@ -102,4 +103,11 @@ public class App extends MultiDexApplication {
public Activity getCurrentActivity() {
return AppManager.getInstance().currentActivity();
}
public void setDashData(String data) {
dashData = data;
}
public String getDashData() {
return dashData;
}
}

@ -125,7 +125,7 @@ public class RemoteTVBox {
Hawk.put(HawkConfig.REMOTE_TVBOX, viewHost);
}
private static void post(String url, Map<String, String> params, okhttp3.Callback callback) {
public static void post(String url, Map<String, String> params, okhttp3.Callback callback) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.readTimeout(1000, TimeUnit.MILLISECONDS);
builder.writeTimeout(1000, TimeUnit.MILLISECONDS);

@ -8,6 +8,7 @@ import android.util.Base64;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.api.ApiConfig;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.event.RefreshEvent;
import com.github.tvbox.osc.event.ServerEvent;
import com.github.tvbox.osc.util.FileUtils;
@ -166,7 +167,19 @@ public class RemoteServer extends NanoHTTPD {
}
EventBus.getDefault().post(new RefreshEvent(RefreshEvent.TYPE_PUSH_URL, url));
return NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.OK, NanoHTTPD.MIME_PLAINTEXT, "ok");
}
} else if (fileName.startsWith("/dash/")) {
String dashData = App.getInstance().getDashData();
try {
String data = new String(Base64.decode(dashData, Base64.DEFAULT | Base64.NO_WRAP), "UTF-8");
return NanoHTTPD.newFixedLengthResponse(
Response.Status.OK,
"application/dash+xml",
data
);
} catch (Throwable th) {
return NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.INTERNAL_ERROR, NanoHTTPD.MIME_PLAINTEXT, dashData);
}
}
} else if (session.getMethod() == Method.POST) {
Map<String, String> files = new HashMap<String, String>();
try {

@ -1,28 +1,3 @@
/*
* Copyright (C) of Avery
*
* _ooOoo_
* o8888888o
* 88" . "88
* (| -_- |)
* O\ = /O
* ____/`- -'\____
* .' \\| |// `.
* / \\||| : |||// \
* / _||||| -:- |||||- \
* | | \\\ - /// | |
* | \_| ''\- -/'' | |
* \ .-\__ `-` ___/-. /
* ___`. .' /- -.- -\ `. . __
* ."" '< `.___\_<|>_/___.' >'"".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `-. \_ __\ /__ _/ .-` / /
* ======`-.____`-.___\_____/___.-`____.-'======
* `=- -='
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Buddha bless, there will never be bug!!!
*/
package com.github.tvbox.osc.subtitle;
import android.net.Uri;
@ -167,7 +142,7 @@ public class SubtitleLoader {
referer = "https://secure.assrt.net/";
}
String ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36";
Response response = OkGo.<String>get(remoteSubtitlePath)
Response response = OkGo.<String>get(remoteSubtitlePath.split("#")[0])
.headers("Referer", referer)
.headers("User-Agent", ua)
.execute();
@ -176,6 +151,7 @@ public class SubtitleLoader {
detector.handleData(bytes, 0, bytes.length);
detector.dataEnd();
String encoding = detector.getDetectedCharset();
if (TextUtils.isEmpty(encoding)) encoding = "UTF-8";
String content = new String(bytes, encoding);
InputStream is = new ByteArrayInputStream(content.getBytes());
String filename = "";
@ -198,9 +174,13 @@ public class SubtitleLoader {
Uri uri = Uri.parse(remoteSubtitlePath);
filePath = uri.getPath();
}
if (!filePath.contains(".") && remoteSubtitlePath.contains("#")) {
filePath = remoteSubtitlePath.split("#")[1];
filePath = URLDecoder.decode(filePath);
}
SubtitleLoadSuccessResult subtitleLoadSuccessResult = new SubtitleLoadSuccessResult();
subtitleLoadSuccessResult.timedTextObject = loadAndParse(is, filePath);
subtitleLoadSuccessResult.fileName = filename;
subtitleLoadSuccessResult.fileName = filePath;
subtitleLoadSuccessResult.content = content;
subtitleLoadSuccessResult.subtitlePath = remoteSubtitlePath;
return subtitleLoadSuccessResult;

@ -158,7 +158,7 @@ public class FastSearchActivity extends BaseActivity {
child.setFocusable(true);
child.setOnFocusChangeListener(focusChangeListener);
TextView t = (TextView) child;
if (t.getText() == "全部显示") {
if (t.getText() == "全部") {
t.requestFocus();
}
// if (child.isFocusable() && null == child.getOnFocusChangeListener()) {
@ -258,7 +258,7 @@ public class FastSearchActivity extends BaseActivity {
}
private void filterResult(String spName) {
if (spName == "全部显示") {
if (spName == "全部") {
mGridView.setVisibility(View.VISIBLE);
mGridViewFilter.setVisibility(View.GONE);
return;
@ -403,7 +403,7 @@ public class FastSearchActivity extends BaseActivity {
ArrayList<String> hots = new ArrayList<>();
spListAdapter.setNewData(hots);
spListAdapter.addData("全部显示");
spListAdapter.addData("全部");
for (SourceBean bean : searchRequestList) {
if (!bean.isSearchable()) {
continue;

@ -474,7 +474,6 @@ public class HomeActivity extends BaseActivity {
} else {
mExitTime = System.currentTimeMillis();
Toast.makeText(mContext, "再按一次返回键退出应用", Toast.LENGTH_SHORT).show();
showEmpty();
}
}

@ -55,12 +55,14 @@ import com.github.tvbox.osc.player.MyVideoView;
import com.github.tvbox.osc.player.TrackInfo;
import com.github.tvbox.osc.player.TrackInfoBean;
import com.github.tvbox.osc.player.controller.VodController;
import com.github.tvbox.osc.server.ControlManager;
import com.github.tvbox.osc.ui.adapter.SelectDialogAdapter;
import com.github.tvbox.osc.ui.dialog.SearchSubtitleDialog;
import com.github.tvbox.osc.ui.dialog.SelectDialog;
import com.github.tvbox.osc.ui.dialog.SubtitleDialog;
import com.github.tvbox.osc.util.AdBlocker;
import com.github.tvbox.osc.util.DefaultConfig;
import com.github.tvbox.osc.util.FileUtils;
import com.github.tvbox.osc.util.HawkConfig;
import com.github.tvbox.osc.util.LOG;
import com.github.tvbox.osc.util.MD5;
@ -499,6 +501,10 @@ public class PlayActivity extends BaseActivity {
if(autoRetryCount>1 && url.contains(".m3u8")){
url="http://home.jundie.top:666/unBom.php?m3u8="+url;//尝试去bom头再次播放
}
if (url.startsWith("data:application/dash+xml;base64,")) {
App.getInstance().setDashData(url.split("base64,")[1]);
url = ControlManager.get().getAddress(true) + "dash/proxy.mpd";
}
String finalUrl = url;
runOnUiThread(new Runnable() {
@Override
@ -599,7 +605,30 @@ public class PlayActivity extends BaseActivity {
playSubtitle = info.optString("subt", /*"https://dash.akamaized.net/akamai/test/caption_test/ElephantsDream/ElephantsDream_en.vtt"*/"");
if(playSubtitle.isEmpty() && info.has("subs")) {
try {
playSubtitle = info.getJSONArray("subs").optJSONObject(0).optString("url", "");
JSONObject obj =info.getJSONArray("subs").optJSONObject(0);
String url = obj.optString("url", "");
if (!TextUtils.isEmpty(url) && !FileUtils.hasExtension(url)) {
String format = obj.optString("format", "");
String name = obj.optString("name", "字幕");
String ext = ".srt";
switch (format) {
case "text/x-ssa":
ext = ".ass";
break;
case "text/vtt":
ext = ".vtt";
break;
case "application/x-subrip":
ext = ".srt";
break;
case "text/lrc":
ext = ".lrc";
break;
}
String filename = name + (name.toLowerCase().endsWith(ext) ? "" : ext);
url += "#" + URLEncoder.encode(filename);
}
playSubtitle = url;
} catch (Throwable th) {
}
}
@ -742,6 +771,7 @@ public class PlayActivity extends BaseActivity {
stopParse();
Thunder.stop(false);//停止磁力下载
Jianpian.finish();//停止p2p下载
App.getInstance().setDashData(null);
}
private VodInfo mVodInfo;

@ -169,7 +169,13 @@ public class SearchActivity extends BaseActivity {
wordAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
search(wordAdapter.getItem(position));
if(Hawk.get(HawkConfig.FAST_SEARCH_MODE, false)){
Bundle bundle = new Bundle();
bundle.putString("title", wordAdapter.getItem(position));
jumpActivity(FastSearchActivity.class, bundle);
}else {
search(wordAdapter.getItem(position));
}
}
});
mGridView.setHasFixedSize(true);
@ -212,7 +218,13 @@ public class SearchActivity extends BaseActivity {
hasKeyBoard = true;
String wd = etSearch.getText().toString().trim();
if (!TextUtils.isEmpty(wd)) {
search(wd);
if(Hawk.get(HawkConfig.FAST_SEARCH_MODE, false)){
Bundle bundle = new Bundle();
bundle.putString("title", wd);
jumpActivity(FastSearchActivity.class, bundle);
}else {
search(wd);
}
} else {
Toast.makeText(mContext, "输入内容不能为空", Toast.LENGTH_SHORT).show();
}
@ -356,7 +368,13 @@ public class SearchActivity extends BaseActivity {
if (intent != null && intent.hasExtra("title")) {
String title = intent.getStringExtra("title");
showLoading();
search(title);
if(Hawk.get(HawkConfig.FAST_SEARCH_MODE, false)){
Bundle bundle = new Bundle();
bundle.putString("title", title);
jumpActivity(FastSearchActivity.class, bundle);
}else {
search(title);
}
}
// 加载热词
OkGo.<String>get("https://node.video.qq.com/x/api/hot_search")
@ -394,7 +412,13 @@ public class SearchActivity extends BaseActivity {
if (event.type == ServerEvent.SERVER_SEARCH) {
String title = (String) event.obj;
showLoading();
search(title);
if(Hawk.get(HawkConfig.FAST_SEARCH_MODE, false)){
Bundle bundle = new Bundle();
bundle.putString("title", title);
jumpActivity(FastSearchActivity.class, bundle);
}else{
search(title);
}
}
}

@ -206,16 +206,17 @@ public class GridFragment extends BaseLazyFragment {
bundle.putString("id", video.id);
bundle.putString("sourceKey", video.sourceKey);
bundle.putString("title", video.name);
SourceBean homeSourceBean = ApiConfig.get().getHomeSourceBean();
if(("12".indexOf(getUITag()) != -1) && (video.tag.equals("folder") || video.tag.equals("cover"))){
focusedView = view;
changeView(video.id,video.tag.equals("folder"));
}
else if(homeSourceBean.isQuickSearch() && Hawk.get(HawkConfig.FAST_SEARCH_MODE, false) && enableFastSearch()){
jumpActivity(FastSearchActivity.class, bundle);
}else{
else{
if(video.id == null || video.id.isEmpty() || video.id.startsWith("msearch:")){
jumpActivity(SearchActivity.class, bundle);
if(Hawk.get(HawkConfig.FAST_SEARCH_MODE, false) && enableFastSearch()){
jumpActivity(FastSearchActivity.class, bundle);
}else {
jumpActivity(SearchActivity.class, bundle);
}
}else {
jumpActivity(DetailActivity.class, bundle);
}
@ -264,7 +265,7 @@ public class GridFragment extends BaseLazyFragment {
if (maxPage>0 && page > maxPage) {
gridAdapter.loadMoreEnd();
gridAdapter.setEnableLoadMore(false);
if(page>2)Toast.makeText(getContext(), "到底啦", Toast.LENGTH_SHORT).show();
if(page>2)Toast.makeText(getContext(), "最后一页啦", Toast.LENGTH_SHORT).show();
} else {
gridAdapter.loadMoreComplete();
gridAdapter.setEnableLoadMore(true);
@ -273,7 +274,7 @@ public class GridFragment extends BaseLazyFragment {
if(page == 1){
showEmpty();
}else{
Toast.makeText(getContext(), "到底啦", Toast.LENGTH_SHORT).show();
Toast.makeText(getContext(), "最后一页啦", Toast.LENGTH_SHORT).show();
gridAdapter.loadMoreEnd();
}
gridAdapter.setEnableLoadMore(false);

@ -55,12 +55,14 @@ import com.github.tvbox.osc.player.MyVideoView;
import com.github.tvbox.osc.player.TrackInfo;
import com.github.tvbox.osc.player.TrackInfoBean;
import com.github.tvbox.osc.player.controller.VodController;
import com.github.tvbox.osc.server.ControlManager;
import com.github.tvbox.osc.ui.adapter.SelectDialogAdapter;
import com.github.tvbox.osc.ui.dialog.SearchSubtitleDialog;
import com.github.tvbox.osc.ui.dialog.SelectDialog;
import com.github.tvbox.osc.ui.dialog.SubtitleDialog;
import com.github.tvbox.osc.util.AdBlocker;
import com.github.tvbox.osc.util.DefaultConfig;
import com.github.tvbox.osc.util.FileUtils;
import com.github.tvbox.osc.util.HawkConfig;
import com.github.tvbox.osc.util.LOG;
import com.github.tvbox.osc.util.MD5;
@ -510,6 +512,12 @@ public class PlayFragment extends BaseLazyFragment {
if(autoRetryCount>0 && url.contains(".m3u8")){
url="http://home.jundie.top:666/unBom.php?m3u8="+url;//尝试去bom头再次播放
}
if (url.startsWith("data:application/dash+xml;base64,")) {
App.getInstance().setDashData(url.split("base64,")[1]);
url = ControlManager.get().getAddress(true) + "dash/proxy.mpd";
}
String finalUrl = url;
if (mActivity == null) return;
requireActivity().runOnUiThread(new Runnable() {
@ -611,7 +619,30 @@ public class PlayFragment extends BaseLazyFragment {
playSubtitle = info.optString("subt", /*"https://dash.akamaized.net/akamai/test/caption_test/ElephantsDream/ElephantsDream_en.vtt"*/"");
if(playSubtitle.isEmpty() && info.has("subs")) {
try {
playSubtitle = info.getJSONArray("subs").optJSONObject(0).optString("url", "");
JSONObject obj =info.getJSONArray("subs").optJSONObject(0);
String url = obj.optString("url", "");
if (!TextUtils.isEmpty(url) && !FileUtils.hasExtension(url)) {
String format = obj.optString("format", "");
String name = obj.optString("name", "字幕");
String ext = ".srt";
switch (format) {
case "text/x-ssa":
ext = ".ass";
break;
case "text/vtt":
ext = ".vtt";
break;
case "application/x-subrip":
ext = ".srt";
break;
case "text/lrc":
ext = ".lrc";
break;
}
String filename = name + (name.toLowerCase().endsWith(ext) ? "" : ext);
url += "#" + URLEncoder.encode(filename);
}
playSubtitle = url;
} catch (Throwable th) {
}
}
@ -777,6 +808,7 @@ public class PlayFragment extends BaseLazyFragment {
stopParse();
Thunder.stop(true);//停止磁力下载
Jianpian.finish();//停止p2p下载
App.getInstance().setDashData(null);
}
private VodInfo mVodInfo;

@ -144,12 +144,7 @@ public class UserFragment extends BaseLazyFragment implements View.OnClickListen
Bundle bundle = new Bundle();
bundle.putString("id", vod.id);
bundle.putString("sourceKey", vod.sourceKey);
if(Hawk.get(HawkConfig.HOME_REC, 0)==1 && Hawk.get(HawkConfig.FAST_SEARCH_MODE, false)){
bundle.putString("title", vod.name);
jumpActivity(FastSearchActivity.class, bundle);
}else {
jumpActivity(DetailActivity.class, bundle);
}
jumpActivity(DetailActivity.class, bundle);
} else {
Intent newIntent;
if(Hawk.get(HawkConfig.FAST_SEARCH_MODE, false)){

@ -228,4 +228,11 @@ public class FileUtils {
}
return "";
}
public static boolean hasExtension(String path) {
int lastDotIndex = path.lastIndexOf(".");
int lastSlashIndex = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
// 如果路径中有点号,并且点号在最后一个斜杠之后,认为有后缀
return lastDotIndex > lastSlashIndex && lastDotIndex < path.length() - 1;
}
}

@ -3,6 +3,8 @@ package com.github.tvbox.osc.viewmodel;
import android.text.TextUtils;
import android.util.Base64;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
@ -17,7 +19,9 @@ import com.github.tvbox.osc.bean.Movie;
import com.github.tvbox.osc.bean.MovieSort;
import com.github.tvbox.osc.bean.SourceBean;
import com.github.tvbox.osc.event.RefreshEvent;
import com.github.tvbox.osc.player.thirdparty.RemoteTVBox;
import com.github.tvbox.osc.util.DefaultConfig;
import com.github.tvbox.osc.util.FileUtils;
import com.github.tvbox.osc.util.HawkConfig;
import com.github.tvbox.osc.util.LOG;
import com.github.tvbox.osc.util.thunder.Thunder;
@ -37,9 +41,14 @@ import com.thoughtworks.xstream.io.xml.DomDriver;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -53,6 +62,8 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import okhttp3.Call;
/**
* @author pj567
* @date :2020/12/18
@ -186,26 +197,70 @@ public class SourceViewModel extends ViewModel {
});
}else if (type == 4) {
String extend=sourceBean.getExt();
String apiUrl = Hawk.get(HawkConfig.API_URL, "");
extend=getFixUrl(apiUrl,extend);
OkGo.<String>get(sourceBean.getApi())
.tag(sourceBean.getKey() + "_sort")
.params("filter", "true")
.params("extend", extend)
.execute(new AbsCallback<String>() {
@Override
public String convertResponse(okhttp3.Response response) throws Throwable {
if (response.body() != null) {
return response.body().string();
} else {
throw new IllegalStateException("网络请求错误");
extend=getFixUrl(extend);
if(URLEncoder.encode(extend).length()<1000){
OkGo.<String>get(sourceBean.getApi())
.tag(sourceBean.getKey() + "_sort")
.params("filter", "true")
.params("extend", extend)
.execute(new AbsCallback<String>() {
@Override
public String convertResponse(okhttp3.Response response) throws Throwable {
if (response.body() != null) {
return response.body().string();
} else {
throw new IllegalStateException("网络请求错误");
}
}
@Override
public void onSuccess(Response<String> response) {
String sortJson = response.body();
if (sortJson != null) {
AbsSortXml sortXml = sortJson(sortResult, sortJson);
if (sortXml != null && Hawk.get(HawkConfig.HOME_REC, 0) == 1) {
AbsXml absXml = json(null, sortJson, sourceBean.getKey());
if (absXml != null && absXml.movie != null && absXml.movie.videoList != null && absXml.movie.videoList.size() > 0) {
sortXml.videoList = absXml.movie.videoList;
sortResult.postValue(sortXml);
} else {
getHomeRecList(sourceBean, null, new HomeRecCallback() {
@Override
public void done(List<Movie.Video> videos) {
sortXml.videoList = videos;
sortResult.postValue(sortXml);
}
});
}
} else {
sortResult.postValue(sortXml);
}
} else {
sortResult.postValue(null);
}
}
@Override
public void onError(Response<String> response) {
super.onError(response);
sortResult.postValue(null);
}
});
}else {
try {
Map<String, String> params = new HashMap<>();
params.put("filter","true");
params.put("extend",extend);
RemoteTVBox.post(sourceBean.getApi(), params, new okhttp3.Callback() {
@Override
public void onFailure(@NonNull Call call, IOException e) {
sortResult.postValue(null);
}
}
@Override
public void onSuccess(Response<String> response) {
String sortJson = response.body();
if (sortJson != null) {
@Override
public void onResponse(@NonNull Call call, @NonNull okhttp3.Response response) throws IOException {
assert response.body() != null;
String sortJson = response.body().string();
AbsSortXml sortXml = sortJson(sortResult, sortJson);
if (sortXml != null && Hawk.get(HawkConfig.HOME_REC, 0) == 1) {
AbsXml absXml = json(null, sortJson, sourceBean.getKey());
@ -224,17 +279,12 @@ public class SourceViewModel extends ViewModel {
} else {
sortResult.postValue(sortXml);
}
} else {
sortResult.postValue(null);
}
}
@Override
public void onError(Response<String> response) {
super.onError(response);
sortResult.postValue(null);
}
});
});
} catch (Exception ignored) {
sortResult.postValue(null);
}
}
} else {
sortResult.postValue(null);
}
@ -671,6 +721,7 @@ public class SourceViewModel extends ViewModel {
@Override
public void run() {
Spider sp = ApiConfig.get().getCSP(sourceBean);
if(TextUtils.isEmpty(url))return;
String json = sp.playerContent(playFlag, url, ApiConfig.get().getVipParseFlags());
try {
JSONObject result = new JSONObject(json);
@ -709,8 +760,8 @@ public class SourceViewModel extends ViewModel {
}
} else if (type == 4) {
String extend=sourceBean.getExt();
String apiUrl = Hawk.get(HawkConfig.API_URL, "");
extend=getFixUrl(apiUrl,extend);
extend=getFixUrl(extend);
if(URLEncoder.encode(extend).length()>1000)extend="";
OkGo.<String>get(sourceBean.getApi())
.params("play", url)
.params("flag" ,playFlag)
@ -755,12 +806,11 @@ public class SourceViewModel extends ViewModel {
}
}
private String getFixUrl(String url,String content){
if (content.contains("\"./")) {
if(!url.startsWith("http") && !url.startsWith("clan://")){
url = "http://" + url;
}
content = content.replace("./", url.substring(0,url.lastIndexOf("/") + 1));
private String getFixUrl(String content){
if (content.startsWith("http://127.0.0.1")) {
String path = content.replaceAll("^http.+/file/", FileUtils.getRootPath()+"/");
path = path.replaceAll("localhost/", "/");
content = FileUtils.readFileToString(path,"UTF-8");
}
return content;
}

@ -102,9 +102,9 @@ public final class ExoMediaSourceHelper {
private int inferContentType(String fileName) {
fileName = fileName.toLowerCase();
if (fileName.contains(".mpd")) {
if (fileName.contains(".mpd") || fileName.contains("type=mpd")) {
return C.TYPE_DASH;
} else if (fileName.contains(".m3u8")) {
} else if (fileName.contains("m3u8")) {
return C.TYPE_HLS;
} else {
return C.TYPE_OTHER;

Loading…
Cancel
Save