|
|
|
|
@ -45,6 +45,7 @@ import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.concurrent.Callable; |
|
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
|
import java.util.concurrent.Executors; |
|
|
|
|
@ -875,6 +876,135 @@ public class SourceViewModel extends ViewModel { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private AbsXml checkPush(AbsXml data) { |
|
|
|
|
if (data.movie != null && data.movie.videoList != null && data.movie.videoList.size() > 0) { |
|
|
|
|
Movie.Video video = data.movie.videoList.get(0); |
|
|
|
|
if (video != null && video.urlBean != null && video.urlBean.infoList != null && video.urlBean.infoList.size() > 0) { |
|
|
|
|
for (int i = 0; i < video.urlBean.infoList.size(); i++) { |
|
|
|
|
Movie.Video.UrlBean.UrlInfo urlinfo = video.urlBean.infoList.get(i); |
|
|
|
|
if (urlinfo != null && urlinfo.beanList != null && !urlinfo.beanList.isEmpty()) { |
|
|
|
|
for (Movie.Video.UrlBean.UrlInfo.InfoBean infoBean : urlinfo.beanList) { |
|
|
|
|
if (infoBean.url.startsWith("push://")) { |
|
|
|
|
String pushUrl = infoBean.url.substring(7); |
|
|
|
|
if (pushUrl.startsWith("b64:")) { |
|
|
|
|
try { |
|
|
|
|
pushUrl = new String(Base64.decode(pushUrl.substring(4), Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP), "UTF-8"); |
|
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
pushUrl = URLDecoder.decode(pushUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final AbsXml[] resData = {null}; |
|
|
|
|
|
|
|
|
|
final CountDownLatch countDownLatch = new CountDownLatch(1); |
|
|
|
|
ExecutorService threadPool = Executors.newSingleThreadExecutor(); |
|
|
|
|
String finalPushUrl = pushUrl; |
|
|
|
|
threadPool.execute(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
SourceBean sb = ApiConfig.get().getSource("push_agent"); |
|
|
|
|
if (sb == null) { |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (sb.getType() == 4) { |
|
|
|
|
OkGo.<String>get(sb.getApi()) |
|
|
|
|
.tag("detail") |
|
|
|
|
.params("ac","detail") |
|
|
|
|
.params("ids", finalPushUrl) |
|
|
|
|
.execute(new AbsCallback<String>() { |
|
|
|
|
@Override |
|
|
|
|
public String convertResponse(okhttp3.Response response) throws Throwable { |
|
|
|
|
if (response.body() != null) { |
|
|
|
|
return response.body().string(); |
|
|
|
|
} else { |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onSuccess(Response<String> response) { |
|
|
|
|
String res = response.body(); |
|
|
|
|
if (!TextUtils.isEmpty(res)) { |
|
|
|
|
try { |
|
|
|
|
AbsJson absJson = new Gson().fromJson(res, new TypeToken<AbsJson>() { |
|
|
|
|
}.getType()); |
|
|
|
|
resData[0] = absJson.toAbsXml(); |
|
|
|
|
absXml(resData[0], sb.getKey()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onError(Response<String> response) { |
|
|
|
|
super.onError(response); |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
try { |
|
|
|
|
Spider sp = ApiConfig.get().getCSP(sb); |
|
|
|
|
// ApiConfig.get().setPlayJarKey(sb.getJar());
|
|
|
|
|
List<String> ids = new ArrayList<>(); |
|
|
|
|
ids.add(finalPushUrl); |
|
|
|
|
String res = sp.detailContent(ids); |
|
|
|
|
if (!TextUtils.isEmpty(res)) { |
|
|
|
|
try { |
|
|
|
|
AbsJson absJson = new Gson().fromJson(res, new TypeToken<AbsJson>() {}.getType()); |
|
|
|
|
resData[0] = absJson.toAbsXml(); |
|
|
|
|
absXml(resData[0], sb.getKey()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Throwable th) { |
|
|
|
|
th.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
try { |
|
|
|
|
countDownLatch.await(15, TimeUnit.SECONDS); |
|
|
|
|
threadPool.shutdown(); |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
if (resData[0] != null) { |
|
|
|
|
AbsXml res = resData[0]; |
|
|
|
|
if (res.movie != null && res.movie.videoList != null && res.movie.videoList.size() > 0) { |
|
|
|
|
Movie.Video resVideo = res.movie.videoList.get(0); |
|
|
|
|
if (resVideo != null && resVideo.urlBean != null && resVideo.urlBean.infoList != null && resVideo.urlBean.infoList.size() > 0) { |
|
|
|
|
if (urlinfo.beanList.size() == 1) { |
|
|
|
|
video.urlBean.infoList.remove(i); |
|
|
|
|
} else { |
|
|
|
|
urlinfo.beanList.remove(infoBean); |
|
|
|
|
} |
|
|
|
|
for (Movie.Video.UrlBean.UrlInfo resUrlinfo : resVideo.urlBean.infoList) { |
|
|
|
|
if (resUrlinfo != null && resUrlinfo.beanList != null && !resUrlinfo.beanList.isEmpty()) { |
|
|
|
|
video.urlBean.infoList.add(resUrlinfo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
video.sourceKey = "push_agent"; |
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
infoBean.name = "解析失败 >>> " + infoBean.name; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void checkThunder(AbsXml data, int index) { |
|
|
|
|
boolean thunderParse = false; |
|
|
|
|
@ -960,6 +1090,7 @@ public class SourceViewModel extends ViewModel { |
|
|
|
|
EventBus.getDefault().post(new RefreshEvent(RefreshEvent.TYPE_QUICK_SEARCH_RESULT, data)); |
|
|
|
|
} else if (result != null) { |
|
|
|
|
if (result == detailResult) { |
|
|
|
|
data = checkPush(data); |
|
|
|
|
checkThunder(data,0); |
|
|
|
|
}else { |
|
|
|
|
result.postValue(data); |
|
|
|
|
@ -1007,6 +1138,7 @@ public class SourceViewModel extends ViewModel { |
|
|
|
|
EventBus.getDefault().post(new RefreshEvent(RefreshEvent.TYPE_QUICK_SEARCH_RESULT, data)); |
|
|
|
|
} else if (result != null) { |
|
|
|
|
if (result == detailResult) { |
|
|
|
|
data = checkPush(data); |
|
|
|
|
checkThunder(data,0); |
|
|
|
|
}else { |
|
|
|
|
result.postValue(data); |
|
|
|
|
|