This commit is contained in:
GH Action - Upstream Sync 2023-10-17 12:31:57 +00:00
commit b8141fecfa
11 changed files with 578 additions and 12 deletions

View File

@ -8,6 +8,9 @@
-keep class com.github.catvod.spider.* { public <methods>; }
-keep class com.github.catvod.parser.* { public <methods>; }
# AndroidX
-keep class androidx.core.** { *; }
# Gson
-keepattributes Signature
-keepattributes *Annotation*

View File

@ -0,0 +1,43 @@
package com.github.catvod.bean.market;
import android.text.TextUtils;
import com.github.catvod.bean.Vod;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
public class Item {
@SerializedName("name")
private String name;
@SerializedName("url")
private String url;
@SerializedName("icon")
private String icon;
public static List<Item> arrayFrom(String str) {
Type listType = new TypeToken<ArrayList<Item>>() {}.getType();
return new Gson().fromJson(str, listType);
}
public String getName() {
return TextUtils.isEmpty(name) ? "" : name;
}
public String getUrl() {
return TextUtils.isEmpty(url) ? "" : url;
}
public String getIcon() {
return TextUtils.isEmpty(icon) ? "" : icon;
}
public Vod vod() {
return new Vod(getUrl(), getName(), getIcon());
}
}

View File

@ -41,6 +41,10 @@ public class OkHttp {
return client().newBuilder().followRedirects(false).followSslRedirects(false).build();
}
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 {
return client().newCall(new Request.Builder().url(url).headers(Headers.of(header)).build()).execute();
}

View File

@ -0,0 +1,133 @@
package com.github.catvod.spider;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.Uri;
import com.github.catvod.bean.Result;
import com.github.catvod.bean.Vod;
import com.github.catvod.bean.market.Item;
import com.github.catvod.crawler.Spider;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.FileUtil;
import com.github.catvod.utils.Utils;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import okhttp3.Response;
public class Market extends Spider {
private ProgressDialog dialog;
private List<Item> items;
private boolean busy;
public boolean isBusy() {
return busy;
}
public void setBusy(boolean busy) {
this.busy = busy;
}
@Override
public void init(Context context, String extend) throws Exception {
items = Item.arrayFrom(extend);
}
@Override
public String homeVideoContent() {
List<Vod> list = new ArrayList<>();
for (Item item : items) list.add(item.vod());
return Result.string(list);
}
@Override
public String detailContent(List<String> ids) throws Exception {
Init.run(this::finish);
Vod vod = new Vod();
vod.setVodPlayFrom("FongMi");
vod.setVodPlayUrl("FongMi$FongMi");
Init.execute(() -> download(ids.get(0)));
return Result.string(vod);
}
private void finish() {
try {
Activity activity = Init.getActivity();
if (activity != null) activity.finish();
} catch (Exception e) {
e.printStackTrace();
}
}
private void download(String url) {
try {
if (isBusy()) return;
setBusy(true);
Init.run(this::setDialog, 500);
Response response = OkHttp.newCall(url);
File file = FileUtil.getCacheFile(Uri.parse(url).getLastPathSegment());
download(file, response.body().byteStream(), Double.parseDouble(response.header("Content-Length", "1")));
FileUtil.openFile(FileUtil.chmod(file));
dismiss();
} catch (Exception e) {
Utils.notify(e.getMessage());
dismiss();
}
}
private void download(File file, InputStream is, double length) throws Exception {
FileOutputStream os = new FileOutputStream(file);
try (BufferedInputStream input = new BufferedInputStream(is)) {
byte[] buffer = new byte[4096];
int readBytes;
long totalBytes = 0;
while ((readBytes = input.read(buffer)) != -1) {
totalBytes += readBytes;
os.write(buffer, 0, readBytes);
setProgress((int) (totalBytes / length * 100.0));
}
}
}
private void setDialog() {
Init.run(() -> {
try {
dialog = new ProgressDialog(Init.getActivity());
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setCancelable(false);
dialog.show();
} catch (Exception e) {
e.printStackTrace();
}
});
}
private void dismiss() {
Init.run(() -> {
try {
setBusy(false);
if (dialog != null) dialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
});
}
private void setProgress(int value) {
Init.run(() -> {
try {
if (dialog != null) dialog.setProgress(value);
} catch (Exception e) {
e.printStackTrace();
}
});
}
}

View File

@ -0,0 +1,305 @@
package com.github.catvod.utils;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.res.XmlResourceParser;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.OpenableColumns;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class FileProvider extends ContentProvider {
private static final String[] COLUMNS = {OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE};
private static final String META_DATA_FILE_PROVIDER_PATHS = "android.support.FILE_PROVIDER_PATHS";
private static final String TAG_CACHE_PATH = "cache-path";
private static final String TAG_EXTERNAL = "external-path";
private static final String ATTR_NAME = "name";
private static final String ATTR_PATH = "path";
private static final String DISPLAYNAME_FIELD = "displayName";
private static final HashMap<String, PathStrategy> sCache = new HashMap<>();
private PathStrategy mStrategy;
@Override
public boolean onCreate() {
return true;
}
@Override
public void attachInfo(Context context, ProviderInfo info) {
super.attachInfo(context, info);
if (info.exported) {
throw new SecurityException("Provider must not be exported");
}
if (!info.grantUriPermissions) {
throw new SecurityException("Provider must grant uri permissions");
}
String authority = info.authority.split(";")[0];
synchronized (sCache) {
sCache.remove(authority);
}
mStrategy = getPathStrategy(context, authority, 0);
}
public static Uri getUriForFile(Context context, String authority, File file) {
final PathStrategy strategy = getPathStrategy(context, authority, 0);
return strategy.getUriForFile(file);
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
final File file = mStrategy.getFileForUri(uri);
String displayName = uri.getQueryParameter(DISPLAYNAME_FIELD);
if (projection == null) {
projection = COLUMNS;
}
String[] cols = new String[projection.length];
Object[] values = new Object[projection.length];
int i = 0;
for (String col : projection) {
if (OpenableColumns.DISPLAY_NAME.equals(col)) {
cols[i] = OpenableColumns.DISPLAY_NAME;
values[i++] = (displayName == null) ? file.getName() : displayName;
} else if (OpenableColumns.SIZE.equals(col)) {
cols[i] = OpenableColumns.SIZE;
values[i++] = file.length();
}
}
cols = copyOf(cols, i);
values = copyOf(values, i);
final MatrixCursor cursor = new MatrixCursor(cols, 1);
cursor.addRow(values);
return cursor;
}
@Override
public String getType(Uri uri) {
final File file = mStrategy.getFileForUri(uri);
final int lastDot = file.getName().lastIndexOf('.');
if (lastDot >= 0) {
final String extension = file.getName().substring(lastDot + 1);
final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (mime != null) {
return mime;
}
}
return "application/octet-stream";
}
@Override
public Uri insert(Uri uri, ContentValues values) {
throw new UnsupportedOperationException("No external inserts");
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException("No external updates");
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
final File file = mStrategy.getFileForUri(uri);
return file.delete() ? 1 : 0;
}
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
final File file = mStrategy.getFileForUri(uri);
final int fileMode = modeToMode(mode);
return ParcelFileDescriptor.open(file, fileMode);
}
private static PathStrategy getPathStrategy(Context context, String authority, int resourceId) {
PathStrategy strat;
synchronized (sCache) {
strat = sCache.get(authority);
if (strat == null) {
try {
strat = parsePathStrategy(context, authority, resourceId);
} catch (IOException e) {
throw new IllegalArgumentException("Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
} catch (XmlPullParserException e) {
throw new IllegalArgumentException("Failed to parse " + META_DATA_FILE_PROVIDER_PATHS + " meta-data", e);
}
sCache.put(authority, strat);
}
}
return strat;
}
static XmlResourceParser getFileProviderPathsMetaData(Context context, String authority, ProviderInfo info, int resourceId) {
if (info == null) {
throw new IllegalArgumentException("Couldn't find meta-data for provider with authority " + authority);
}
if (info.metaData == null && resourceId != 0) {
info.metaData = new Bundle(1);
info.metaData.putInt(META_DATA_FILE_PROVIDER_PATHS, resourceId);
}
final XmlResourceParser in = info.loadXmlMetaData(context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
if (in == null) {
throw new IllegalArgumentException("Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
}
return in;
}
private static PathStrategy parsePathStrategy(Context context, String authority, int resourceId) throws IOException, XmlPullParserException {
final SimplePathStrategy strat = new SimplePathStrategy(authority);
final ProviderInfo info = context.getPackageManager().resolveContentProvider(authority, PackageManager.GET_META_DATA);
final XmlResourceParser in = getFileProviderPathsMetaData(context, authority, info, resourceId);
int type;
while ((type = in.next()) != END_DOCUMENT) {
if (type == START_TAG) {
final String tag = in.getName();
final String name = in.getAttributeValue(null, ATTR_NAME);
String path = in.getAttributeValue(null, ATTR_PATH);
File target = null;
if (TAG_CACHE_PATH.equals(tag)) {
target = context.getCacheDir();
} else if (TAG_EXTERNAL.equals(tag)) {
target = Environment.getExternalStorageDirectory();
}
if (target != null) {
strat.addRoot(name, buildPath(target, path));
}
}
}
return strat;
}
interface PathStrategy {
Uri getUriForFile(File file);
File getFileForUri(Uri uri);
}
static class SimplePathStrategy implements PathStrategy {
private final String mAuthority;
private final HashMap<String, File> mRoots = new HashMap<>();
SimplePathStrategy(String authority) {
mAuthority = authority;
}
void addRoot(String name, File root) {
if (TextUtils.isEmpty(name)) {
throw new IllegalArgumentException("Name must not be empty");
}
try {
root = root.getCanonicalFile();
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + root, e);
}
mRoots.put(name, root);
}
@Override
public Uri getUriForFile(File file) {
String path;
try {
path = file.getCanonicalPath();
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
}
Map.Entry<String, File> mostSpecific = null;
for (Map.Entry<String, File> root : mRoots.entrySet()) {
final String rootPath = root.getValue().getPath();
if (path.startsWith(rootPath) && (mostSpecific == null || rootPath.length() > mostSpecific.getValue().getPath().length())) {
mostSpecific = root;
}
}
if (mostSpecific == null) {
throw new IllegalArgumentException("Failed to find configured root that contains " + path);
}
final String rootPath = mostSpecific.getValue().getPath();
if (rootPath.endsWith("/")) {
path = path.substring(rootPath.length());
} else {
path = path.substring(rootPath.length() + 1);
}
path = Uri.encode(mostSpecific.getKey()) + '/' + Uri.encode(path, "/");
return new Uri.Builder().scheme("content").authority(mAuthority).encodedPath(path).build();
}
@Override
public File getFileForUri(Uri uri) {
String path = uri.getEncodedPath();
final int splitIndex = path.indexOf('/', 1);
final String tag = Uri.decode(path.substring(1, splitIndex));
path = Uri.decode(path.substring(splitIndex + 1));
final File root = mRoots.get(tag);
if (root == null) {
throw new IllegalArgumentException("Unable to find configured root for " + uri);
}
File file = new File(root, path);
try {
file = file.getCanonicalFile();
} catch (IOException e) {
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
}
if (!file.getPath().startsWith(root.getPath())) {
throw new SecurityException("Resolved path jumped beyond configured root");
}
return file;
}
}
private static int modeToMode(String mode) {
int modeBits;
if ("r".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_ONLY;
} else if ("w".equals(mode) || "wt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE;
} else if ("wa".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_APPEND;
} else if ("rw".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_CREATE;
} else if ("rwt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE;
} else {
throw new IllegalArgumentException("Invalid mode: " + mode);
}
return modeBits;
}
private static File buildPath(File base, String... segments) {
File cur = base;
for (String segment : segments) {
if (segment != null) {
cur = new File(cur, segment);
}
}
return cur;
}
private static String[] copyOf(String[] original, int newLength) {
final String[] result = new String[newLength];
System.arraycopy(original, 0, result, 0, newLength);
return result;
}
private static Object[] copyOf(Object[] original, int newLength) {
final Object[] result = new Object[newLength];
System.arraycopy(original, 0, result, 0, newLength);
return result;
}
}

View File

@ -1,5 +1,10 @@
package com.github.catvod.utils;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import com.github.catvod.spider.Init;
import java.io.File;
@ -7,6 +12,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLConnection;
public class FileUtil {
@ -64,4 +70,21 @@ public class FileUtil {
return "";
}
}
public static void openFile(File file) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(getShareUri(file), FileUtil.getMimeType(file.getName()));
Init.context().startActivity(intent);
}
private static String getMimeType(String fileName) {
String mimeType = URLConnection.guessContentTypeFromName(fileName);
return TextUtils.isEmpty(mimeType) ? "*/*" : mimeType;
}
private static Uri getShareUri(File file) {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.N ? Uri.fromFile(file) : FileProvider.getUriForFile(Init.context(), Init.context().getPackageName() + ".provider", file);
}
}

Binary file not shown.

View File

@ -1 +1 @@
6aa99ddfd99dd2e5b68615edd29ddb43
8a9d215c9f79d7e5ce9e223b40ed81e8

View File

@ -1,5 +1,5 @@
{
"spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;6aa99ddfd99dd2e5b68615edd29ddb43",
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;8a9d215c9f79d7e5ce9e223b40ed81e8",
"wallpaper": "https://gao.chuqiuyu.tk",
"sites": [
{
@ -74,7 +74,7 @@
"key": "18A貓",
"name": "18A貓",
"type": 3,
"api": "https://fongmi.cachefly.net/FongMi/CatVodOpen/main/open/18a_open.js",
"api": "https://raw.githubusercontent.com/FongMi/CatVodOpen/main/open/18a_open.js",
"searchable": 1,
"style": {
"type": "rect",

View File

@ -1,5 +1,5 @@
{
"spider": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;6aa99ddfd99dd2e5b68615edd29ddb43",
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;8a9d215c9f79d7e5ce9e223b40ed81e8",
"wallpaper": "http://饭太硬.top/深色壁纸/api.php",
"sites": [
{
@ -27,7 +27,7 @@
"changeable": 0,
"ext": {
"token": "影視天下第一",
"filter": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/json/wogg.json"
"filter": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/wogg.json"
}
},
{
@ -37,7 +37,7 @@
"api": "csp_Jianpian",
"searchable": 1,
"changeable": 1,
"ext": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/json/jianpian.json"
"ext": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/jianpian.json"
},
{
"key": "獨播",
@ -46,13 +46,13 @@
"api": "csp_XPathMacFilter",
"searchable": 1,
"changeable": 1,
"ext": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/json/duboku.json"
"ext": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/duboku.json"
},
{
"key": "五五",
"name": "五五",
"type": 3,
"api": "https://fongmi.cachefly.net/FongMi/CatVodOpen/main/open/555dy_open.js",
"api": "https://raw.githubusercontent.com/FongMi/CatVodOpen/main/open/555dy_open.js",
"searchable": 1,
"changeable": 1
},
@ -166,7 +166,7 @@
"ratio": 1.433
},
"ext": {
"json": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/json/bili.json",
"json": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/bili.json",
"type": "帕梅拉#太极拳#广场舞#演唱会",
"cookie": ""
}
@ -198,7 +198,7 @@
"api": "csp_AList",
"searchable": 1,
"changeable": 0,
"ext": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/json/alist.json"
"ext": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/alist.json"
},
{
"key": "WebDAV",
@ -207,7 +207,7 @@
"api": "csp_WebDAV",
"searchable": 1,
"changeable": 0,
"ext": "https://fongmi.cachefly.net/FongMi/CatVodSpider/main/json/webdav.json"
"ext": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/json/webdav.json"
},
{
"key": "七夜",
@ -273,6 +273,61 @@
"api": "csp_Push",
"searchable": 1,
"changeable": 0
},
{
"key": "應用商店",
"name": "應用商店",
"type": 3,
"api": "csp_Market",
"searchable": 0,
"changeable": 0,
"ext": [
{
"name": "電視-java-v7",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/release/leanback-java-armeabi_v7a.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8nk2.png"
},
{
"name": "電視-java-v8",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/release/leanback-java-arm64_v8a.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8nk2.png"
},
{
"name": "電視-py-v7",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/release/leanback-python-armeabi_v7a.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8nk2.png"
},
{
"name": "電視-py-v8",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/release/leanback-python-arm64_v8a.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8nk2.png"
},
{
"name": "Android-4.x",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/kitkat/leanback.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8nk2.png"
},
{
"name": "手機-java-v7",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/release/mobile-java-armeabi_v7a.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8lVK.png"
},
{
"name": "手機-java-v8",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/release/mobile-java-arm64_v8a.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8lVK.png"
},
{
"name": "手機-py-v7",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/release/mobile-python-armeabi_v7a.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8lVK.png"
},
{
"name": "手機-py-v8",
"url": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/Release/main/apk/release/mobile-python-arm64_v8a.apk",
"icon": "https://i.imgs.ovh/2023/10/17/r8lVK.png"
}
]
}
],
"doh": [

View File

@ -51,7 +51,7 @@ public class Live {
for (Group group : groups) {
for (Channel channel : group.getChannel()) {
channel.number(String.format(Locale.getDefault(), "%03d", ++number));
channel.logo("https://fongmi.cachefly.net/FongMi/TV/release/app/src/main/res/drawable-xxhdpi/ic_img_empty.png");
channel.logo("https://raw.githubusercontent.com/FongMi/TV/release/app/src/main/res/drawable-xxhdpi/ic_img_empty.png");
combine(channel);
}
}