Merge pull request #553 from okcaptain/dev

Dev
pull/554/head^2
okcaptain 2 years ago committed by GitHub
commit 8dbeeff5ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/build.gradle
  2. 1
      app/proguard-rules.pro
  3. 2
      app/src/leanback/java/com/fongmi/android/tv/ui/dialog/UaDialog.java
  4. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/dialog/UaDialog.java
  5. 2
      build.gradle
  6. 3
      catvod/src/main/java/com/github/catvod/utils/Util.java
  7. 9
      pyramid/src/main/java/com/undcover/freedom/pyramid/Spider.java
  8. 32
      pyramid/src/main/python/base/spider.py

@ -13,8 +13,8 @@ android {
minSdk 21
//noinspection ExpiredTargetSdkVersion
targetSdk 28
versionCode 243
versionName "2.4.3"
versionCode 244
versionName "2.4.4"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]

@ -33,6 +33,7 @@
-keep class okhttp3.** { *; }
# CatVod
-keep class com.github.catvod.Proxy { *; }
-keep class com.github.catvod.crawler.** { *; }
-keep class * extends com.github.catvod.crawler.Spider

@ -89,7 +89,7 @@ public class UaDialog implements DialogInterface.OnDismissListener {
binding.text.setText(Util.CHROME);
} else if (append && "o".equalsIgnoreCase(s)) {
append = false;
binding.text.setText(okhttp3.internal.Util.userAgent);
binding.text.setText(Util.OKHTTP);
} else if (s.length() > 1) {
append = false;
} else if (s.length() == 0) {

@ -70,7 +70,7 @@ public class UaDialog {
binding.text.setText(Util.CHROME);
} else if (append && "o".equalsIgnoreCase(s)) {
append = false;
binding.text.setText(okhttp3.internal.Util.userAgent);
binding.text.setText(Util.OKHTTP);
} else if (s.length() > 1) {
append = false;
} else if (s.length() == 0) {

@ -11,6 +11,6 @@ tasks.register('clean', Delete) {
project.ext {
gsonVersion = '2.11.0'
jsoupVersion = '1.15.3'
okhttpVersion = '4.12.0'
okhttpVersion = '5.0.0-alpha.14'
annotationVersion = '1.3.0'
}

@ -22,8 +22,11 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Enumeration;
import okhttp3.OkHttp;
public class Util {
public static final String OKHTTP = "okhttp/" + OkHttp.VERSION;
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";
public static final int URL_SAFE = Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP;

@ -3,7 +3,6 @@ package com.undcover.freedom.pyramid;
import android.content.Context;
import com.chaquo.python.PyObject;
import com.github.catvod.Proxy;
import com.github.catvod.utils.Path;
import com.github.catvod.utils.UriUtil;
import com.github.catvod.utils.Util;
@ -72,7 +71,7 @@ public class Spider extends com.github.catvod.crawler.Spider {
@Override
public String playerContent(String flag, String id, List<String> vipFlags) {
return replaceProxy(app.callAttr("playerContent", obj, flag, id, gson.toJson(vipFlags)).toString());
return app.callAttr("playerContent", obj, flag, id, gson.toJson(vipFlags)).toString();
}
@Override
@ -108,7 +107,7 @@ public class Spider extends com.github.catvod.crawler.Spider {
if (o.type().toString().contains("bytes")) {
return new ByteArrayInputStream(o.toJava(byte[].class));
} else {
String content = replaceProxy(o.toString());
String content = o.toString();
if (base64 && content.contains("base64,")) content = content.split("base64,")[1];
return new ByteArrayInputStream(base64 ? Util.decode(content) : content.getBytes());
}
@ -119,8 +118,4 @@ public class Spider extends com.github.catvod.crawler.Spider {
String url = UriUtil.resolve(api, name);
app.callAttr("download", path, url);
}
private String replaceProxy(String content) {
return content.replace("http://127.0.0.1:UndCover/proxy", Proxy.getUrl(true));
}
}

@ -6,6 +6,7 @@ from lxml import etree
from com.chaquo.python import Python
from abc import abstractmethod, ABCMeta
from importlib.machinery import SourceFileLoader
from com.github.catvod import Proxy
class Spider(metaclass=ABCMeta):
@ -99,3 +100,34 @@ class Spider(metaclass=ABCMeta):
def html(self, content):
return etree.HTML(content)
def getProxyUrl(self, local=True):
return f'{Proxy.getUrl(local)}?do=py'
def getCache(self, key):
value = self.fetch(f'http://127.0.0.1:{Proxy.getPort()}/cache?do=get&key={key}', timeout=5).text
if len(value) > 0:
if value.startswith('{') and value.endswith('}') or value.startswith('[') and value.endswith(']'):
value = json.loads(value)
if type(value) == dict:
if not 'expiresAt' in value or value['expiresAt'] >= int(time.time()):
return value
else:
self.delCache(key)
return None
return value
else:
return None
def setCache(self, key, value):
if type(value) in [int, float]:
value = str(value)
if len(value) > 0:
if type(value) == dict or type(value) == list:
value = json.dumps(value, ensure_ascii=False)
r = self.post(f'http://127.0.0.1:{Proxy.getPort()}/cache?do=set&key={key}', data={"value": value}, timeout=5)
return 'succeed' if r.status_code == 200 else 'failed'
def delCache(self, key):
r = self.fetch(f'http://127.0.0.1:{Proxy.getPort()}/cache?do=del&key={key}', timeout=5)
return 'succeed' if r.status_code == 200 else 'failed'

Loading…
Cancel
Save