Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
f6cdcca058
|
|
@ -55,6 +55,10 @@ public class OkHttp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Response newCall(String url) throws IOException {
|
||||||
|
return client().newCall(new Request.Builder().url(url).build()).execute();
|
||||||
|
}
|
||||||
|
|
||||||
public static Response newCall(String url, Map<String, String> header) throws IOException {
|
public static Response newCall(String url, Map<String, String> header) throws IOException {
|
||||||
return client().newCall(new Request.Builder().url(url).headers(Headers.of(header)).build()).execute();
|
return client().newCall(new Request.Builder().url(url).headers(Headers.of(header)).build()).execute();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
package com.github.catvod.spider;
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.github.catvod.bean.Result;
|
import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Sub;
|
import com.github.catvod.bean.Sub;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.utils.Utils;
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
@ -50,14 +51,36 @@ public class Push extends Ali {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Sub> getSubs(String url) {
|
private List<Sub> getSubs(String url) {
|
||||||
if (!url.startsWith("file://")) return Collections.emptyList();
|
|
||||||
File file = new File(url.replace("file://", ""));
|
|
||||||
if (file.getParentFile() == null) return Collections.emptyList();
|
|
||||||
List<Sub> subs = new ArrayList<>();
|
List<Sub> subs = new ArrayList<>();
|
||||||
|
if (url.startsWith("file://")) setFileSub(url, subs);
|
||||||
|
if (url.startsWith("http://")) setHttpSub(url, subs);
|
||||||
|
return subs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setHttpSub(String url, List<Sub> subs) {
|
||||||
|
try {
|
||||||
|
List<String> vodTypes = Arrays.asList("mp4", "mkv");
|
||||||
|
List<String> subTypes = Arrays.asList("srt", "ass");
|
||||||
|
if (!vodTypes.contains(Utils.getExt(url))) return;
|
||||||
|
for (String ext : subTypes) detectSub(url, ext, subs);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void detectSub(String url, String ext, List<Sub> subs) throws Exception {
|
||||||
|
url = Utils.removeExt(url).concat(".").concat(ext);
|
||||||
|
if (OkHttp.newCall(url).code() != 200) return;
|
||||||
|
String name = Uri.parse(url).getLastPathSegment();
|
||||||
|
subs.add(Sub.create().name(name).ext(ext).url(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFileSub(String url, List<Sub> subs) {
|
||||||
|
File file = new File(url.replace("file://", ""));
|
||||||
|
if (file.getParentFile() == null) return;
|
||||||
for (File f : Objects.requireNonNull(file.getParentFile().listFiles())) {
|
for (File f : Objects.requireNonNull(file.getParentFile().listFiles())) {
|
||||||
String ext = Utils.getExt(f.getName());
|
String ext = Utils.getExt(f.getName());
|
||||||
if (Utils.isSub(ext)) subs.add(Sub.create().name(Utils.removeExt(f.getName())).ext(ext).url("file://" + f.getAbsolutePath()));
|
if (Utils.isSub(ext)) subs.add(Sub.create().name(Utils.removeExt(f.getName())).ext(ext).url("file://" + f.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
return subs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
dec1a7f7a1e979b8f5ff4887dd6da378
|
d02ea3eb2cda4c0a98f3758125eb667e
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;dec1a7f7a1e979b8f5ff4887dd6da378",
|
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;d02ea3eb2cda4c0a98f3758125eb667e",
|
||||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||||
"sites": [
|
"sites": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;dec1a7f7a1e979b8f5ff4887dd6da378",
|
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;d02ea3eb2cda4c0a98f3758125eb667e",
|
||||||
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
|
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
|
||||||
"sites": [
|
"sites": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue