pull/69/head
FongMi 3 years ago
parent 42fa76afef
commit d3dfc82c1d
  1. 6
      app/src/main/java/com/github/catvod/bean/alist/Drive.java
  2. 10
      app/src/main/java/com/github/catvod/spider/AList.java

@ -3,6 +3,7 @@ package com.github.catvod.bean.alist;
import android.text.TextUtils;
import com.github.catvod.bean.Class;
import com.github.catvod.net.OkHttpUtil;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
@ -47,6 +48,7 @@ public class Drive {
}
public int getVersion() {
checkVersion();
return version;
}
@ -82,6 +84,10 @@ public class Drive {
return getServer() + "/search?box=" + param + "&url=";
}
private void checkVersion() {
if (getVersion() == 0) setVersion(OkHttpUtil.string(settingsApi()).contains("v3.") ? 3 : 2);
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;

@ -47,14 +47,8 @@ public class AList extends Spider {
drives = Drive.objectFrom(ext).getDrives();
}
private Drive checkVersion(Drive drive) {
if (drive.getVersion() == 0) drive.setVersion(OkHttpUtil.string(drive.settingsApi()).contains("v3.") ? 3 : 2);
return drive;
}
private Drive getDrive(String name) {
Drive drive = drives.get(drives.indexOf(new Drive(name)));
return checkVersion(drive);
return drives.get(drives.indexOf(new Drive(name)));
}
@Override
@ -125,7 +119,7 @@ public class AList extends Spider {
fetchRule();
List<Vod> list = new ArrayList<>();
CountDownLatch cd = new CountDownLatch(drives.size());
for (Drive drive : drives) new Thread(() -> search(cd, list, checkVersion(drive), keyword)).start();
for (Drive drive : drives) new Thread(() -> search(cd, list, drive, keyword)).start();
cd.await();
return Result.string(list);
}

Loading…
Cancel
Save