fix style;fix 嗅探;

main
jun 12 months ago
parent 376214f6c0
commit ccc54c91eb
  1. 8
      app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java
  2. 2
      app/src/main/java/com/github/tvbox/osc/ui/fragment/GridFragment.java
  3. 9
      app/src/main/java/com/github/tvbox/osc/ui/fragment/PlayFragment.java
  4. 97
      app/src/main/java/com/github/tvbox/osc/util/urlhttp/AESUtil.java
  5. 55
      app/src/main/java/com/github/tvbox/osc/util/urlhttp/ThreadsManager.java

@ -1656,13 +1656,13 @@ public class PlayActivity extends BaseActivity {
loadFoundVideoUrlsHeader.put(url, headers);
LOG.i("echo-loadFoundVideoUrl:" + url );
if (loadFoundCount.incrementAndGet() == 1) {
stopLoadWebView(false);
SuperParse.stopJsonJx();
url = loadFoundVideoUrls.poll();
mHandler.removeMessages(100);
String cookie = CookieManager.getInstance().getCookie(url);
if(!TextUtils.isEmpty(cookie))headers.put("Cookie", " " + cookie);//携带cookie
playUrl(url, headers);
SuperParse.stopJsonJx();
stopLoadWebView(false);
}
}
}
@ -1844,13 +1844,13 @@ public class PlayActivity extends BaseActivity {
loadFoundVideoUrlsHeader.put(url, webHeaders);
LOG.i("echo-loadFoundVideoUrl:" + url );
if (loadFoundCount.incrementAndGet() == 1) {
SuperParse.stopJsonJx();
stopLoadWebView(false);
mHandler.removeMessages(100);
url = loadFoundVideoUrls.poll();
String cookie = CookieManager.getInstance().getCookie(url);
if(!TextUtils.isEmpty(cookie))webHeaders.put("Cookie", " " + cookie);//携带cookie
playUrl(url, webHeaders);
SuperParse.stopJsonJx();
stopLoadWebView(false);
}
}
}

@ -232,7 +232,7 @@ public class GridFragment extends BaseLazyFragment {
bundle.putString("title", video.name);
if( video.tag !=null && (video.tag.equals("folder") || video.tag.equals("cover"))){
focusedView = view;
if(("12".indexOf(getUITag()) != -1)){
if(("12".indexOf(getUITag()) != -1) && style == null){
changeView(video.id,video.tag.equals("folder"));
}else {
changeView(video.id,false);

@ -1728,13 +1728,13 @@ public class PlayFragment extends BaseLazyFragment {
loadFoundVideoUrlsHeader.put(url, headers);
LOG.i("echo-loadFoundVideoUrl:" + url );
if (loadFoundCount.incrementAndGet() == 1) {
stopLoadWebView(false);
SuperParse.stopJsonJx();
url = loadFoundVideoUrls.poll();
mHandler.removeMessages(100);
String cookie = CookieManager.getInstance().getCookie(url);
if(!TextUtils.isEmpty(cookie))headers.put("Cookie", " " + cookie);//携带cookie
playUrl(url, headers);
stopLoadWebView(false);
SuperParse.stopJsonJx();
}
}
}
@ -1902,7 +1902,6 @@ public class PlayFragment extends BaseLazyFragment {
ad = Boolean.TRUE.equals(loadedUrls.get(url));
}
if (!ad ) {
if (checkVideoFormat(url)) {
HashMap<String, String> webHeaders = new HashMap<>();
Map<String, String> hds = request.getRequestHeaders();
@ -1919,13 +1918,13 @@ public class PlayFragment extends BaseLazyFragment {
loadFoundVideoUrlsHeader.put(url, webHeaders);
LOG.i("echo-loadFoundVideoUrl:" + url );
if (loadFoundCount.incrementAndGet() == 1) {
stopLoadWebView(false);
SuperParse.stopJsonJx();
mHandler.removeMessages(100);
url = loadFoundVideoUrls.poll();
String cookie = CookieManager.getInstance().getCookie(url);
if(!TextUtils.isEmpty(cookie))webHeaders.put("Cookie", " " + cookie);//携带cookie
playUrl(url, webHeaders);
stopLoadWebView(false);
SuperParse.stopJsonJx();
}
}
}

@ -1,97 +0,0 @@
package com.github.tvbox.osc.util.urlhttp;
import java.util.Base64;
import java.security.spec.AlgorithmParameterSpec;
import java.security.Key;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.Cipher;
public class AESUtil
{
public static byte[] decryptData(byte[] array, final String s, final String s2) throws Exception {
try {
final Cipher instance = Cipher.getInstance("AES/CBC/PKCS5Padding");
instance.init(2, new SecretKeySpec(s.getBytes(), "AES"), new IvParameterSpec(s2.getBytes()));
array = instance.doFinal(array);
array = Base64.getDecoder().decode(array);
return array;
}
catch (Exception ex) {
throw ex;
}
}
public static String desEncry(final String s, String substring) throws Exception {
String substring2;
if (substring.length() > 16) {
substring2 = substring.substring(substring.length() - 16);
substring = substring.substring(0, 16);
}
else {
substring2 = substring;
}
return new String(decryptData(parseHexStr2Byte(s), substring, substring2), "UTF-8");
}
public static String encry(final String s, String substring) throws Exception {
String substring2;
if (substring.length() > 16) {
substring2 = substring.substring(substring.length() - 16);
substring = substring.substring(0, 16);
final StringBuilder sb = new StringBuilder();
sb.append(substring2);
sb.append(substring);
sb.toString();
}
else {
substring2 = substring;
}
return parseByte2HexStr(encryptData(s, substring, substring2));
}
public static byte[] encryptData(final String s, final String s2, final String s3) throws Exception {
try {
final Cipher instance = Cipher.getInstance("AES/CBC/PKCS5Padding");
final byte[] encode = Base64.getEncoder().encode(s.getBytes("UTF-8"));
final byte[] array = new byte[encode.length];
System.arraycopy(encode, 0, array, 0, encode.length);
instance.init(1, new SecretKeySpec(s2.getBytes(), "AES"), new IvParameterSpec(s3.getBytes()));
return instance.doFinal(array);
}
catch (Exception ex) {
throw ex;
}
}
public static String parseByte2HexStr(final byte[] array) {
final StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; ++i) {
String s2;
final String s = s2 = Integer.toHexString(array[i] & 0xFF);
if (s.length() == 1) {
final StringBuilder sb2 = new StringBuilder();
sb2.append('0');
sb2.append(s);
s2 = sb2.toString();
}
sb.append(s2.toUpperCase());
}
return sb.toString();
}
public static byte[] parseHexStr2Byte(final String s) {
if (s.length() < 1) {
return null;
}
final byte[] array = new byte[s.length() / 2];
for (int i = 0; i < s.length() / 2; ++i) {
final int n = i * 2;
final int n2 = n + 1;
array[i] = (byte)(Integer.parseInt(s.substring(n, n2), 16) * 16 + Integer.parseInt(s.substring(n2, n + 2), 16));
}
return array;
}
}

@ -1,55 +0,0 @@
package com.github.tvbox.osc.util.urlhttp;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class ThreadsManager {
private static ExecutorService mExecutorService;
private static Map<Integer, Future> mTaskMap = new HashMap();
public ThreadsManager() {
}
static {
}
public static void init() {
if (mExecutorService == null) {
mExecutorService = Executors.newCachedThreadPool();
clear();
}
}
public static void clear() {
Collection<Future> values = mTaskMap.values();
if (values.size() > 0) {
for (Future hashCode : values) {
stop(Integer.valueOf(hashCode.hashCode()));
}
}
}
public static Integer post(Runnable runnable) {
if (mExecutorService == null) {
init();
}
Future<?> submit = mExecutorService.submit(runnable);
Integer valueOf = Integer.valueOf(submit.hashCode());
mTaskMap.put(Integer.valueOf(submit.hashCode()), submit);
return valueOf;
}
public static void stop(Integer num) {
Future future = mTaskMap.get(num);
if (future != null) {
mTaskMap.remove(num);
if (!future.isDone() && !future.isCancelled() && mExecutorService != null) {
future.cancel(true);
}
}
}
}
Loading…
Cancel
Save