Fix type 0 search vodPic

pull/123/head
FongMi 3 years ago
parent 0a9f6f6675
commit d70d87e4c4
  1. 30
      app/src/main/java/com/fongmi/android/tv/model/SiteViewModel.java

@ -72,16 +72,7 @@ public class SiteViewModel extends ViewModel {
String body = OkHttp.newCall(site.getApi()).execute().body().string();
SpiderDebug.log(body);
Result result = site.getType() == 0 ? Result.fromXml(body) : Result.fromJson(body);
if (result.getList().isEmpty() || result.getList().get(0).getVodPic().length() > 0) return result;
ArrayList<String> ids = new ArrayList<>();
for (Vod item : result.getList()) ids.add(item.getVodId());
ArrayMap<String, String> params = new ArrayMap<>();
params.put("ac", site.getType() == 0 ? "videolist" : "detail");
params.put("ids", TextUtils.join(",", ids));
body = OkHttp.newCall(site.getApi(), params).execute().body().string();
List<Vod> items = site.getType() == 0 ? Result.fromXml(body).getList() : Result.fromJson(body).getList();
result.setList(items);
return result;
return fetchPic(site, result);
}
});
}
@ -172,7 +163,7 @@ public class SiteViewModel extends ViewModel {
if (site.getType() == 3) {
Spider spider = ApiConfig.get().getCSP(site);
String searchContent = spider.searchContent(Trans.t2s(keyword), false);
SpiderDebug.log(searchContent);
SpiderDebug.log(site.getName() + "," + searchContent);
post(site, Result.fromJson(searchContent));
} else {
ArrayMap<String, String> params = new ArrayMap<>();
@ -180,11 +171,24 @@ public class SiteViewModel extends ViewModel {
if (site.getType() != 0) params.put("ac", "detail");
String body = OkHttp.newCall(site.getApi(), params).execute().body().string();
SpiderDebug.log(site.getName() + "," + body);
if (site.getType() == 0) post(site, Result.fromXml(body));
else post(site, Result.fromJson(body));
Result result = site.getType() == 0 ? Result.fromXml(body) : Result.fromJson(body);
post(site, fetchPic(site, result));
}
}
private Result fetchPic(Site site, Result result) throws Exception {
if (result.getList().isEmpty() || result.getList().get(0).getVodPic().length() > 0) return result;
ArrayList<String> ids = new ArrayList<>();
for (Vod item : result.getList()) ids.add(item.getVodId());
ArrayMap<String, String> params = new ArrayMap<>();
params.put("ac", site.getType() == 0 ? "videolist" : "detail");
params.put("ids", TextUtils.join(",", ids));
String body = OkHttp.newCall(site.getApi(), params).execute().body().string();
List<Vod> items = site.getType() == 0 ? Result.fromXml(body).getList() : Result.fromJson(body).getList();
result.setList(items);
return result;
}
private void post(Site site, Result result) {
if (result.getList().isEmpty()) return;
for (Vod vod : result.getList()) vod.setSite(site);

Loading…
Cancel
Save