Update
This commit is contained in:
parent
e090705260
commit
1fcca306a0
|
|
@ -1,122 +0,0 @@
|
||||||
package com.github.catvod.spider;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.github.catvod.bean.Class;
|
|
||||||
import com.github.catvod.bean.Result;
|
|
||||||
import com.github.catvod.bean.Vod;
|
|
||||||
import com.github.catvod.crawler.Spider;
|
|
||||||
import com.github.catvod.net.OkHttp;
|
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
|
||||||
import org.jsoup.nodes.Document;
|
|
||||||
import org.jsoup.nodes.Element;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Eighteen extends Spider {
|
|
||||||
|
|
||||||
private final String url = "https://mjv002.com/zh/";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(Context context, String extend) throws Exception {
|
|
||||||
OkHttp.newCall("https://mjv002.com/zh/chinese_IamOverEighteenYearsOld/19/index.html").close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String homeContent(boolean filter) throws Exception {
|
|
||||||
List<Class> classes = new ArrayList<>();
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(url));
|
|
||||||
for (Element a : doc.select("ul.animenu__nav > li > a")) {
|
|
||||||
String typeName = a.text();
|
|
||||||
String typeId = a.attr("href").replace(url, "");
|
|
||||||
if (!typeId.contains("random/all/")) continue;
|
|
||||||
if (typeName.contains("18H")) break;
|
|
||||||
classes.add(new Class(typeId, typeName));
|
|
||||||
}
|
|
||||||
for (Element div : doc.select("div.post")) {
|
|
||||||
String id = div.select("a").attr("href").replace(url, "");
|
|
||||||
String name = div.select("h3").text();
|
|
||||||
String pic = div.select("a > img").attr("src");
|
|
||||||
String remark = div.select("div.meta").text();
|
|
||||||
list.add(new Vod(id, name, pic, remark));
|
|
||||||
}
|
|
||||||
return Result.string(classes, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
tid = tid.replace("random", "list");
|
|
||||||
tid = tid.replace("index", pg);
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(url + tid));
|
|
||||||
for (Element div : doc.select("div.post")) {
|
|
||||||
String id = div.select("a").attr("href").replace(url, "");
|
|
||||||
String name = div.select("h3").text();
|
|
||||||
String pic = div.select("a > img").attr("src");
|
|
||||||
String remark = div.select("div.meta").text();
|
|
||||||
list.add(new Vod(id, name, pic, remark));
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String detailContent(List<String> ids) throws Exception {
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(url + ids.get(0)));
|
|
||||||
Element wrap = doc.select("div.video-wrap").get(0);
|
|
||||||
String name = wrap.select("div.archive-title > h1").text();
|
|
||||||
String pic = wrap.select("div.player-wrap > img").attr("src");
|
|
||||||
Vod vod = new Vod();
|
|
||||||
vod.setVodId(ids.get(0));
|
|
||||||
vod.setVodPic(pic);
|
|
||||||
vod.setVodName(name);
|
|
||||||
vod.setVodPlayFrom("18AV");
|
|
||||||
vod.setVodPlayUrl("播放$" + ids.get(0));
|
|
||||||
return Result.string(vod);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String searchContent(String key, boolean quick) throws Exception {
|
|
||||||
return searchContent(key, "1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String searchContent(String key, boolean quick, String pg) throws Exception {
|
|
||||||
return searchContent(key, pg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
|
||||||
return Result.get().parse().url(url + id).string();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean manualVideoCheck() throws Exception {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVideoFormat(String url) throws Exception {
|
|
||||||
return !url.contains("afcdn.net") && (url.contains(".m3u8") || url.contains(".mp4"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String searchContent(String key, String pg) {
|
|
||||||
HashMap<String, String> params = new HashMap<>();
|
|
||||||
params.put("search_keyword", key);
|
|
||||||
params.put("search_type", "fc");
|
|
||||||
params.put("op", "search");
|
|
||||||
String res = OkHttp.post(url + "searchform_search/all/" + pg + ".html", params);
|
|
||||||
List<Vod> list = new ArrayList<>();
|
|
||||||
for (Element div : Jsoup.parse(res).select("div.post")) {
|
|
||||||
String id = div.select("a").attr("href").replace(url, "");
|
|
||||||
String name = div.select("h3").text();
|
|
||||||
String pic = div.select("a > img").attr("src");
|
|
||||||
String remark = div.select("div.meta").text();
|
|
||||||
list.add(new Vod(id, name, pic, remark));
|
|
||||||
}
|
|
||||||
return Result.string(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,6 +6,7 @@ import android.media.ThumbnailUtils;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
|
||||||
import com.github.catvod.bean.Class;
|
import com.github.catvod.bean.Class;
|
||||||
|
|
@ -14,6 +15,7 @@ import com.github.catvod.bean.Sub;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.crawler.Spider;
|
import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.utils.Image;
|
import com.github.catvod.utils.Image;
|
||||||
|
import com.github.catvod.utils.Path;
|
||||||
import com.github.catvod.utils.Util;
|
import com.github.catvod.utils.Util;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
@ -22,7 +24,6 @@ import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
@ -54,13 +55,7 @@ public class Local extends Spider {
|
||||||
@Override
|
@Override
|
||||||
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
public String categoryContent(String tid, String pg, boolean filter, HashMap<String, String> extend) throws Exception {
|
||||||
List<Vod> items = new ArrayList<>();
|
List<Vod> items = new ArrayList<>();
|
||||||
File[] files = new File(tid).listFiles();
|
List<File> files = Path.list(new File(tid));
|
||||||
if (files == null) return Result.string(items);
|
|
||||||
Arrays.sort(files, (o1, o2) -> {
|
|
||||||
if (o1.isDirectory() && o2.isFile()) return -1;
|
|
||||||
if (o1.isFile() && o2.isDirectory()) return 1;
|
|
||||||
return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
|
|
||||||
});
|
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (file.getName().startsWith(".")) continue;
|
if (file.getName().startsWith(".")) continue;
|
||||||
if (file.isDirectory() || Util.isMedia(file.getName())) items.add(create(file));
|
if (file.isDirectory() || Util.isMedia(file.getName())) items.add(create(file));
|
||||||
|
|
@ -76,7 +71,8 @@ public class Local extends Spider {
|
||||||
return Result.string(create(name, url));
|
return Result.string(create(name, url));
|
||||||
} else {
|
} else {
|
||||||
File file = new File(ids.get(0));
|
File file = new File(ids.get(0));
|
||||||
return Result.string(create(file.getName(), file.getAbsolutePath()));
|
List<File> files = Path.list(file.getParentFile());
|
||||||
|
return Result.string(create(file, files));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,6 +96,19 @@ public class Local extends Spider {
|
||||||
return vod;
|
return vod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vod create(File file, List<File> files) {
|
||||||
|
Vod vod = new Vod();
|
||||||
|
vod.setTypeName("FongMi");
|
||||||
|
vod.setVodId(file.getName());
|
||||||
|
vod.setVodName(file.getName());
|
||||||
|
vod.setVodPic(Image.VIDEO);
|
||||||
|
vod.setVodPlayFrom("播放");
|
||||||
|
List<String> playUrls = new ArrayList<>();
|
||||||
|
for (File f : files) if (Util.isMedia(f.getName())) playUrls.add(f.getName() + "$" + f.getAbsolutePath());
|
||||||
|
vod.setVodPlayUrl(TextUtils.join("#", playUrls));
|
||||||
|
return vod;
|
||||||
|
}
|
||||||
|
|
||||||
private Vod create(File file) {
|
private Vod create(File file) {
|
||||||
Vod vod = new Vod();
|
Vod vod = new Vod();
|
||||||
vod.setVodId(file.getAbsolutePath());
|
vod.setVodId(file.getAbsolutePath());
|
||||||
|
|
@ -119,11 +128,8 @@ public class Local extends Spider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Sub> getSubs(String path) {
|
private List<Sub> getSubs(String path) {
|
||||||
File file = new File(path);
|
|
||||||
File[] files = file.getParentFile() == null ? null : file.getParentFile().listFiles();
|
|
||||||
if (files == null || files.length == 0) return Collections.emptyList();
|
|
||||||
List<Sub> subs = new ArrayList<>();
|
List<Sub> subs = new ArrayList<>();
|
||||||
for (File f : files) {
|
for (File f : Path.list(new File(path).getParentFile())) {
|
||||||
String ext = Util.getExt(f.getName());
|
String ext = Util.getExt(f.getName());
|
||||||
if (Util.isSub(ext)) subs.add(Sub.create().name(Util.removeExt(f.getName())).ext(ext).url("file://" + f.getAbsolutePath()));
|
if (Util.isSub(ext)) subs.add(Sub.create().name(Util.removeExt(f.getName())).ext(ext).url("file://" + f.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,25 @@ package com.github.catvod.utils;
|
||||||
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
|
||||||
import com.github.catvod.crawler.SpiderDebug;
|
import androidx.annotation.Nullable;
|
||||||
import com.github.catvod.spider.Init;
|
|
||||||
|
|
||||||
|
import com.github.catvod.crawler.SpiderDebug;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Path {
|
public class Path {
|
||||||
|
|
||||||
|
private static final String TAG = Path.class.getSimpleName();
|
||||||
|
|
||||||
private static File mkdir(File file) {
|
private static File mkdir(File file) {
|
||||||
if (!file.exists()) file.mkdirs();
|
if (!file.exists()) file.mkdirs();
|
||||||
return file;
|
return file;
|
||||||
|
|
@ -30,22 +34,10 @@ public class Path {
|
||||||
return Environment.getExternalStorageDirectory();
|
return Environment.getExternalStorageDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File cache() {
|
|
||||||
return Init.context().getCacheDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File files() {
|
|
||||||
return Init.context().getFilesDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File tv() {
|
public static File tv() {
|
||||||
return mkdir(new File(root() + File.separator + "TV"));
|
return mkdir(new File(root() + File.separator + "TV"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File cache(String path) {
|
|
||||||
return mkdir(new File(cache(), path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File tv(String name) {
|
public static File tv(String name) {
|
||||||
if (!name.startsWith(".")) name = "." + name;
|
if (!name.startsWith(".")) name = "." + name;
|
||||||
return new File(tv(), name);
|
return new File(tv(), name);
|
||||||
|
|
@ -53,26 +45,34 @@ public class Path {
|
||||||
|
|
||||||
public static String read(File file) {
|
public static String read(File file) {
|
||||||
try {
|
try {
|
||||||
return read(new FileInputStream(file));
|
return new String(readToByte(file), StandardCharsets.UTF_8);
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String read(InputStream is) {
|
public static String read(InputStream is) {
|
||||||
try {
|
try {
|
||||||
byte[] data = new byte[is.available()];
|
return new String(readToByte(is), StandardCharsets.UTF_8);
|
||||||
is.read(data);
|
|
||||||
is.close();
|
|
||||||
return new String(data, StandardCharsets.UTF_8);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File write(File file, String data) {
|
private static byte[] readToByte(File file) throws IOException {
|
||||||
return write(file, data.getBytes());
|
try (FileInputStream is = new FileInputStream(file)) {
|
||||||
|
return readToByte(is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] readToByte(InputStream is) throws IOException {
|
||||||
|
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
|
||||||
|
int read;
|
||||||
|
byte[] buffer = new byte[16384];
|
||||||
|
while ((read = is.read(buffer)) != -1) bos.write(buffer, 0, read);
|
||||||
|
return bos.toByteArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File write(File file, byte[] data) {
|
public static File write(File file, byte[] data) {
|
||||||
|
|
@ -82,33 +82,50 @@ public class Path {
|
||||||
fos.flush();
|
fos.flush();
|
||||||
fos.close();
|
fos.close();
|
||||||
return file;
|
return file;
|
||||||
} catch (Exception ignored) {
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void move(File in, File out) {
|
||||||
|
if (in.renameTo(out)) return;
|
||||||
|
copy(in, out);
|
||||||
|
clear(in);
|
||||||
|
}
|
||||||
|
|
||||||
public static void copy(File in, File out) {
|
public static void copy(File in, File out) {
|
||||||
try {
|
try {
|
||||||
copy(new FileInputStream(in), out);
|
copy(new FileInputStream(in), out);
|
||||||
} catch (Exception ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void copy(InputStream in, File out) {
|
public static void copy(InputStream in, File out) {
|
||||||
try {
|
try {
|
||||||
int read;
|
int read;
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[16384];
|
||||||
FileOutputStream fos = new FileOutputStream(create(out));
|
FileOutputStream fos = new FileOutputStream(create(out));
|
||||||
while ((read = in.read(buffer)) != -1) fos.write(buffer, 0, read);
|
while ((read = in.read(buffer)) != -1) fos.write(buffer, 0, read);
|
||||||
fos.close();
|
fos.close();
|
||||||
in.close();
|
in.close();
|
||||||
} catch (Exception ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void move(File in, File out) {
|
public static void sort(File[] files) {
|
||||||
copy(in, out);
|
Arrays.sort(files, (o1, o2) -> {
|
||||||
clear(in);
|
if (o1.isDirectory() && o2.isFile()) return -1;
|
||||||
|
if (o1.isFile() && o2.isDirectory()) return 1;
|
||||||
|
return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<File> list(@Nullable File dir) {
|
||||||
|
if (dir == null) return new ArrayList<>();
|
||||||
|
File[] files = dir.listFiles();
|
||||||
|
if (files != null) sort(files);
|
||||||
|
return files == null ? new ArrayList<>() : Arrays.asList(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear(File dir) {
|
public static void clear(File dir) {
|
||||||
|
|
@ -117,19 +134,14 @@ public class Path {
|
||||||
if (dir.delete()) SpiderDebug.log("Deleted:" + dir.getAbsolutePath());
|
if (dir.delete()) SpiderDebug.log("Deleted:" + dir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<File> list(File dir) {
|
public static File create(File file) {
|
||||||
File[] files = dir.listFiles();
|
|
||||||
return files == null ? Collections.emptyList() : Arrays.asList(files);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File create(File file) throws Exception {
|
|
||||||
try {
|
try {
|
||||||
if (file.getParentFile() != null) mkdir(file.getParentFile());
|
if (file.getParentFile() != null) mkdir(file.getParentFile());
|
||||||
if (!file.canWrite()) file.setWritable(true);
|
if (!file.canWrite()) file.setWritable(true);
|
||||||
if (!file.exists()) file.createNewFile();
|
if (!file.exists()) file.createNewFile();
|
||||||
Shell.exec("chmod 777 " + file);
|
Shell.exec("chmod 777 " + file);
|
||||||
return file;
|
return file;
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
bd8c878db83953d74efc2cb0723f68ac
|
bc0b643f8920201b9d08f2e605f51acd
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue