Merge branch 'refs/heads/main' into mine
# Conflicts: # app/src/main/java/com/github/catvod/debug/MainActivity.java # app/src/main/java/com/github/catvod/spider/Proxy.java # jar/custom_spider.jar # jar/custom_spider.jar.md5
This commit is contained in:
commit
25ba5e7ea4
|
|
@ -16,6 +16,7 @@ import com.github.catvod.crawler.Spider;
|
|||
import com.github.catvod.utils.Image;
|
||||
import com.github.catvod.utils.Util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -25,6 +26,7 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class Local extends Spider {
|
||||
|
||||
|
|
@ -103,18 +105,18 @@ public class Local extends Spider {
|
|||
Vod vod = new Vod();
|
||||
vod.setVodId(file.getAbsolutePath());
|
||||
vod.setVodName(file.getName());
|
||||
vod.setVodPic(file.isFile() ? getBase64(file) : Image.FOLDER);
|
||||
vod.setVodPic(file.isFile() ? Proxy.getUrl() + "?do=local&path=" + Base64.encodeToString(file.getAbsolutePath().getBytes(), Base64.DEFAULT | Base64.URL_SAFE) : Image.FOLDER);
|
||||
vod.setVodRemarks(format.format(file.lastModified()));
|
||||
vod.setVodTag(file.isDirectory() ? "folder" : "file");
|
||||
return vod;
|
||||
}
|
||||
|
||||
private String getBase64(File file) {
|
||||
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(file.getAbsolutePath(), MediaStore.Images.Thumbnails.MINI_KIND);
|
||||
if (bitmap == null) return Image.VIDEO;
|
||||
private static byte[] getBase64(String path) {
|
||||
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MINI_KIND);
|
||||
if (bitmap == null) return Base64.decode(Image.VIDEO.split("base64,")[1], Base64.DEFAULT);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
|
||||
return "data:image/jpg;base64," + Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
private List<Sub> getSubs(String path) {
|
||||
|
|
@ -128,4 +130,13 @@ public class Local extends Spider {
|
|||
}
|
||||
return subs;
|
||||
}
|
||||
|
||||
public static Object[] proxy(Map<String, String> params) {
|
||||
String path = new String(Base64.decode(params.get("path"), Base64.DEFAULT | Base64.URL_SAFE));
|
||||
Object[] result = new Object[3];
|
||||
result[0] = 200;
|
||||
result[1] = "application/octet-stream";
|
||||
result[2] = new ByteArrayInputStream(getBase64(path));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -66,14 +66,14 @@ public class PTT extends Spider {
|
|||
String remark = div.select("span.badge.badge-success").get(0).text();
|
||||
String vodPic = img.attr("src").startsWith("http") ? img.attr("src") : url + img.attr("src");
|
||||
String name = img.attr("alt");
|
||||
if (!TextUtils.isEmpty(name)) list.add(new Vod(a.attr("href").substring(1), name, vodPic, remark));
|
||||
if (!TextUtils.isEmpty(name)) list.add(new Vod(a.attr("href").substring(3), name, vodPic, remark));
|
||||
}
|
||||
return Result.string(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String detailContent(List<String> ids) throws Exception {
|
||||
Document doc = Jsoup.parse(OkHttp.string(url + ids.get(0), getHeader()));
|
||||
Document doc = Jsoup.parse(OkHttp.string(url + ids.get(0) + "/1", getHeader()));
|
||||
LinkedHashMap<String, String> flags = new LinkedHashMap<>();
|
||||
List<String> playUrls = new ArrayList<>();
|
||||
for (Element a : doc.select("ul#w1 > li > a")) {
|
||||
|
|
@ -114,7 +114,7 @@ public class PTT extends Spider {
|
|||
String remark = div.select("span.badge.badge-success").get(0).text();
|
||||
String vodPic = img.attr("src").startsWith("http") ? img.attr("src") : url + img.attr("src");
|
||||
String name = img.attr("alt");
|
||||
if (!TextUtils.isEmpty(name)) list.add(new Vod(a.attr("href").substring(1), name, vodPic, remark));
|
||||
if (!TextUtils.isEmpty(name)) list.add(new Vod(a.attr("href").substring(3), name, vodPic, remark));
|
||||
}
|
||||
return Result.string(list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public class Proxy extends Spider {
|
|||
return Bili.proxy(params);
|
||||
case "webdav":
|
||||
return WebDAV.vod(params);
|
||||
case "local":
|
||||
return Local.proxy(params);
|
||||
case "proxy":
|
||||
return commonProxy(params);
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class Util {
|
|||
public static final Pattern THUNDER = Pattern.compile("(magnet|thunder|ed2k):.*");
|
||||
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36";
|
||||
public static final String ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
|
||||
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "iso", "mpg", "ts", "iso", "mp3", "aac", "flac", "m4a", "ape", "ogg");
|
||||
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "iso", "mpg", "ts", "mp3", "aac", "flac", "m4a", "ape", "ogg");
|
||||
public static final List<String> SUB = Arrays.asList("srt", "ass", "ssa", "vtt");
|
||||
|
||||
public static boolean isVip(String url) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue