Support local torrent

pull/183/head
FongMi 3 years ago
parent c06f4af82a
commit d8a06b7632
  1. 1
      app/src/main/java/com/fongmi/android/tv/utils/Download.java
  2. 2
      app/src/main/java/com/fongmi/android/tv/utils/Sniffer.java
  3. 1
      thunder/src/main/java/com/xunlei/downloadlib/XLTaskHelper.java
  4. 11
      thunder/src/main/java/com/xunlei/downloadlib/parameter/GetTaskId.java

@ -32,6 +32,7 @@ public class Download {
}
public void start() {
if (url.startsWith("file")) return;
if (callback == null) doInBackground();
else App.execute(this::doInBackground);
}

@ -32,7 +32,7 @@ public class Sniffer {
}
public static boolean isTorrent(String url) {
return url.startsWith("http") && url.endsWith(".torrent");
return (url.startsWith("http") || url.startsWith("file")) && url.endsWith(".torrent");
}
public static boolean isAds(Uri uri) {

@ -47,6 +47,7 @@ public class XLTaskHelper {
}
public synchronized GetTaskId parse(String url, File savePath) {
if (url.startsWith("file://")) return new GetTaskId(url, savePath);
if (url.startsWith("thunder://")) url = getManager().parserThunderUrl(url);
String fileName = getManager().getFileNameFromUrl(url);
GetTaskId taskId = new GetTaskId(savePath, fileName, url);

@ -1,5 +1,7 @@
package com.xunlei.downloadlib.parameter;
import com.github.catvod.utils.Path;
import java.io.File;
public class GetTaskId {
@ -13,6 +15,15 @@ public class GetTaskId {
this.mSavePath = savePath;
}
public GetTaskId(String url, File savePath) {
File file = new File(url.substring(7));
File dest = new File(savePath, file.getName());
Path.copy(file, dest);
this.mFileName = file.getName();
this.mSavePath = savePath;
this.mRealUrl = url;
}
public GetTaskId(File savePath, String fileName, String realUrl) {
this.mSavePath = savePath;
this.mFileName = fileName;

Loading…
Cancel
Save