show thunder error

pull/137/head
FongMi 3 years ago
parent c8ed4ffe2e
commit 8f38208010
  1. 2
      app/src/main/java/com/fongmi/android/tv/model/SiteViewModel.java
  2. 17
      app/src/main/java/com/fongmi/android/tv/player/extractor/Thunder.java
  3. 34
      thunder/src/main/java/com/xunlei/downloadlib/parameter/Error.java
  4. 4
      thunder/src/main/java/com/xunlei/downloadlib/parameter/XLTaskInfo.java

@ -222,7 +222,7 @@ public class SiteViewModel extends ViewModel {
if (!scheme.equals("magnet") && !scheme.equals("thunder")) continue;
magnets.add(Magnet.get(episode.getUrl()));
}
for (Future<List<TorrentFileInfo>> future : Executors.newCachedThreadPool().invokeAll(magnets, 3000, TimeUnit.MILLISECONDS)) {
for (Future<List<TorrentFileInfo>> future : Executors.newCachedThreadPool().invokeAll(magnets, 5000, TimeUnit.MILLISECONDS)) {
List<TorrentFileInfo> files = future.get();
if (files.size() > 0) flag.getEpisodes().clear();
for (TorrentFileInfo file : files) flag.getEpisodes().add(Vod.Flag.Episode.create(file.getFileName(), file.getPlayUrl()));

@ -3,11 +3,14 @@ package com.fongmi.android.tv.player.extractor;
import android.net.Uri;
import android.os.SystemClock;
import com.fongmi.android.tv.App;
import com.fongmi.android.tv.player.Source;
import com.fongmi.android.tv.utils.Notify;
import com.github.catvod.utils.Path;
import com.github.catvod.utils.Util;
import com.xunlei.downloadlib.XLTaskHelper;
import com.xunlei.downloadlib.parameter.GetTaskId;
import com.xunlei.downloadlib.parameter.XLTaskInfo;
import java.io.File;
import java.util.Objects;
@ -25,19 +28,23 @@ public class Thunder implements Source.Extractor {
public String fetch(String url) throws Exception {
Uri uri = Uri.parse(url);
boolean torrent = "torrent".equals(uri.getScheme());
return torrent ? fetchTorrent(uri) : fetchThunder(url);
return torrent ? addTorrentTask(uri) : addThunderTask(url);
}
private String fetchTorrent(Uri uri) {
private String addTorrentTask(Uri uri) {
File torrent = new File(uri.getPath());
String name = uri.getQueryParameter("name");
int index = Integer.parseInt(uri.getQueryParameter("index"));
taskId = XLTaskHelper.get().addTorrentTask(torrent, Objects.requireNonNull(torrent.getParentFile()), index);
while (XLTaskHelper.get().getBtSubTaskInfo(taskId, index).mTaskInfo.mTaskStatus == 0) SystemClock.sleep(10);
return XLTaskHelper.get().getLocalUrl(new File(torrent.getParent(), name));
while (true) {
XLTaskInfo taskInfo = XLTaskHelper.get().getBtSubTaskInfo(taskId, index).mTaskInfo;
if (taskInfo.mTaskStatus == 3) App.post(() -> Notify.show(taskInfo.getErrorMsg()));
if (taskInfo.mTaskStatus != 0) return XLTaskHelper.get().getLocalUrl(new File(torrent.getParent(), name));
else SystemClock.sleep(50);
}
}
private String fetchThunder(String url) {
private String addThunderTask(String url) {
File folder = Path.thunder(Util.md5(url));
taskId = XLTaskHelper.get().addThunderTask(url, folder);
return XLTaskHelper.get().getLocalUrl(taskId.getSaveFile());

@ -0,0 +1,34 @@
package com.xunlei.downloadlib.parameter;
public class Error {
public static String get(int code) {
switch (code) {
case 9125:
return "檔案名稱太長";
case 9301:
return "緩衝區不足";
case 111085:
return "硬碟空間不足";
case 111120:
return "檔案路徑太長";
case 111142:
return "檔案大小太小";
case 111171:
return "網路連線失敗";
case 9304:
case 114001:
case 114004:
case 114005:
case 114006:
case 114007:
case 114011:
case 111154:
return "版權限制:無法下載";
case 114101:
return "地址失效";
default:
return "ErrorCode=" + code;
}
}
}

@ -82,6 +82,10 @@ public class XLTaskInfo implements Parcelable {
this.mTaskStatus = taskStatus;
}
public String getErrorMsg() {
return Error.get(mErrorCode);
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeLong(this.mTaskId);

Loading…
Cancel
Save