修分类封面/文件夹切换bug;修主页配置加载时间过长不能操作的bug;添加dns;修磁力推送解析bug

pull/98/head
21561 3 years ago
parent f0d155e573
commit d97ed6f5b6
  1. 3
      app/src/main/java/com/github/tvbox/osc/picasso/MyOkhttpDownLoader.java
  2. 24
      app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java
  3. 2
      app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java
  4. 2
      app/src/main/java/com/github/tvbox/osc/ui/fragment/GridFragment.java
  5. 2
      app/src/main/java/com/github/tvbox/osc/ui/fragment/PlayFragment.java
  6. 10
      app/src/main/java/com/github/tvbox/osc/util/OkGoHelper.java
  7. 167
      app/src/main/java/com/github/tvbox/osc/util/thunder/Thunder.java
  8. 84
      app/src/main/java/com/github/tvbox/osc/viewmodel/SourceViewModel.java

@ -96,7 +96,8 @@ public final class MyOkhttpDownLoader implements Downloader {
assert ua != null;
mRequestBuilder.addHeader("User-Agent", ua);
}else {
mRequestBuilder.addHeader("User-Agent", UA.randomOne());
String mobile_UA = "Dalvik/2.1.0 (Linux; U; Android 13; M2102J2SC Build/TKQ1.220829.002)";
mRequestBuilder.addHeader("User-Agent", mobile_UA);
}
if(!TextUtils.isEmpty(referer)){
assert referer != null;

@ -212,20 +212,26 @@ public class HomeActivity extends BaseActivity {
tvName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dataInitOk = false;
jarInitOk = true;
showSiteSwitch();
if(dataInitOk && jarInitOk){
showSiteSwitch();
}else {
jumpActivity(SettingActivity.class);
}
}
});
tvName.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
Bundle bundle = new Bundle();
bundle.putBoolean("useCache", true);
intent.putExtras(bundle);
HomeActivity.this.startActivity(intent);
if(dataInitOk && jarInitOk){
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
Bundle bundle = new Bundle();
bundle.putBoolean("useCache", true);
intent.putExtras(bundle);
HomeActivity.this.startActivity(intent);
}else {
jumpActivity(SettingActivity.class);
}
return true;
}
});

@ -845,7 +845,7 @@ public class PlayActivity extends BaseActivity {
}
@Override
public void list(String playList) {
public void list(Map<Integer, String> urlMap) {
}
@Override

@ -87,7 +87,7 @@ public class GridFragment extends BaseLazyFragment {
if(isFolder){
this.sortData.flag ="1"; // 修改sortData.flag
}else {
this.sortData.flag =null; // 修改sortData.flag
this.sortData.flag ="2"; // 修改sortData.flag
}
initView();
this.sortData.id =id; // 修改sortData.id为新的ID

@ -874,7 +874,7 @@ public class PlayFragment extends BaseLazyFragment {
}
@Override
public void list(String playList) {
public void list(Map<Integer, String> urlMap) {
}
@Override

@ -29,7 +29,7 @@ import okhttp3.internal.Version;
import xyz.doikki.videoplayer.exo.ExoMediaSourceHelper;
public class OkGoHelper {
public static final long DEFAULT_MILLISECONDS = 10000; //默认的超时时间
public static final long DEFAULT_MILLISECONDS = 8000; //默认的超时时间
static void initExoOkHttpClient() {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
@ -75,6 +75,12 @@ public class OkGoHelper {
case 3: {
return "https://doh.360.cn/dns-query";
}
case 4: {
return "https://dns.adguard.com/dns-query";
}
case 5: {
return "https://dns.quad9.net/dns-query";
}
}
return "";
}
@ -84,6 +90,8 @@ public class OkGoHelper {
dnsHttpsList.add("腾讯");
dnsHttpsList.add("阿里");
dnsHttpsList.add("360");
dnsHttpsList.add("AdGuard");
dnsHttpsList.add("Quad9");
OkHttpClient.Builder builder = new OkHttpClient.Builder();
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkExoPlayer");
if (Hawk.get(HawkConfig.DEBUG_OPEN, false)) {

@ -7,6 +7,7 @@ import android.text.TextUtils;
import android.util.Log;
import com.github.tvbox.osc.base.App;
import com.github.tvbox.osc.bean.Movie;
import com.github.tvbox.osc.util.FileUtils;
import com.xunlei.downloadlib.XLDownloadManager;
import com.xunlei.downloadlib.XLTaskHelper;
@ -17,7 +18,9 @@ import com.xunlei.downloadlib.parameter.XLTaskInfo;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -87,105 +90,125 @@ public class Thunder {
void status(int code, String info);
void list(String playList);
void list(Map<Integer, String> urlMap);
void play(String url);
}
private static ArrayList<String> playList = null;
private static ArrayList<String> ed2kList = null;
public static void parse(Context context, List<String> urlList, ThunderCallback callback) {
public static void parse(Context context, Movie.Video.UrlBean urlBean, ThunderCallback callback) {
init(context);
stop(true);
threadPool = Executors.newSingleThreadExecutor();
playList = new ArrayList<>();
torrentFileInfoArrayList=new ArrayList<>();
playList=new ArrayList<>();
ed2kList=new ArrayList<>();
ArrayList<String> jxUrls=new ArrayList<>();
Map<Integer, String> urlMap = new HashMap<>();
threadPool.execute(new Runnable() {
@Override
public void run() {
for (String url : urlList) {
if(isThunder(url) )url=XLDownloadManager.getInstance().parserThunderUrl(url);
if (isMagnet(url) || isThunder(url) || isTorrent(url)) {
String link = isThunder(url) ? XLDownloadManager.getInstance().parserThunderUrl(url) : url;
Uri p = Uri.parse(link);
if (p == null) {
continue;
}
String fileName = XLTaskHelper.instance().getFileName(link);
File cache = new File(cacheRoot + File.separator + fileName);
try {
if (currentTask > 0) {
XLTaskHelper.instance().stopTask(currentTask);
currentTask = 0L;
}
currentTask = isMagnet(url) ?
XLTaskHelper.instance().addMagentTask(url, cacheRoot, fileName) :
XLTaskHelper.instance().addThunderTask(url, cacheRoot, fileName);
} catch (Exception exception) {
exception.printStackTrace();
currentTask = 0;
}
if (currentTask <= 0) {
continue;
}
int count = 20;
Boolean conti=true;
while (conti) {
count--;
if (count <= 0) {
conti=false;
}
XLTaskInfo taskInfo = XLTaskHelper.instance().getTaskInfo(currentTask);
switch (taskInfo.mTaskStatus) {
case 2: {
try {
TorrentInfo torrentInfo = XLTaskHelper.instance().getTorrentInfo(cache.getAbsolutePath());
if (torrentInfo == null || TextUtils.isEmpty(torrentInfo.mInfoHash)) {
} else {
TorrentFileInfo[] mSubFileInfo = torrentInfo.mSubFileInfo;
if (mSubFileInfo != null && mSubFileInfo.length >= 0) {
for (TorrentFileInfo sub : mSubFileInfo) {
if (isMedia(sub.mFileName)) {
sub.torrentPath = cache.getAbsolutePath();
playList.add(sub.mFileName + "$tvbox-torrent:" + torrentFileInfoArrayList.size());
torrentFileInfoArrayList.add(sub);
for (int idx=0;idx<urlBean.infoList.size();idx++) {
Movie.Video.UrlBean.UrlInfo urlInfo = urlBean.infoList.get(idx);
if (urlInfo != null) {
String url="";
for (Movie.Video.UrlBean.UrlInfo.InfoBean infoBean : urlInfo.beanList) {
url=infoBean.url;
// if(jxUrls.contains(url))continue;
if(isThunder(url) )url=XLDownloadManager.getInstance().parserThunderUrl(url);
if (isMagnet(url) || isThunder(url) || isTorrent(url)) {
String link = isThunder(url) ? XLDownloadManager.getInstance().parserThunderUrl(url) : url;
Uri p = Uri.parse(link);
if (p == null) {
continue;
}
String fileName = XLTaskHelper.instance().getFileName(link);
File cache = new File(cacheRoot + File.separator + fileName);
try {
if (currentTask > 0) {
XLTaskHelper.instance().stopTask(currentTask);
currentTask = 0L;
}
currentTask = isMagnet(url) ?
XLTaskHelper.instance().addMagentTask(url, cacheRoot, fileName) :
XLTaskHelper.instance().addThunderTask(url, cacheRoot, fileName);
} catch (Exception exception) {
exception.printStackTrace();
currentTask = 0;
}
if (currentTask <= 0) {
continue;
}
int count = 15;
outerLoop:
while (true) {
count--;
if (count <= 0) {
break;
}
XLTaskInfo taskInfo = XLTaskHelper.instance().getTaskInfo(currentTask);
if(taskInfo!=null){
switch (taskInfo.mTaskStatus) {
case 2: {
try {
TorrentInfo torrentInfo = XLTaskHelper.instance().getTorrentInfo(cache.getAbsolutePath());
if (torrentInfo == null || TextUtils.isEmpty(torrentInfo.mInfoHash)) {
} else {
TorrentFileInfo[] mSubFileInfo = torrentInfo.mSubFileInfo;
if (mSubFileInfo != null) {
for (TorrentFileInfo sub : mSubFileInfo) {
if (isMedia(sub.mFileName)) {
sub.torrentPath = cache.getAbsolutePath();
playList.add(sub.mFileName + "$tvbox-torrent:" + torrentFileInfoArrayList.size());
torrentFileInfoArrayList.add(sub);
}
}
jxUrls.add(url);
break outerLoop;
}
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
conti=false;
}
case 3: {
break outerLoop;
}
default: {
}
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
default: {
}else {
url=infoBean.url;
if(isThunder(url))url=XLDownloadManager.getInstance().parserThunderUrl(url);
if(isNetworkDownloadTask(url)){
task_url=url;
if(TextUtils.isEmpty(task_url)){
continue;
}
name = XLTaskHelper.instance().getFileName(task_url);
playList.add(name + "$tvbox-oth:" + ed2kList.size());
ed2kList.add(task_url);
}
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
for (String url : urlList) {
if(isThunder(url))url=XLDownloadManager.getInstance().parserThunderUrl(url);
if(isNetworkDownloadTask(url)){
task_url=url;
if(TextUtils.isEmpty(task_url)){
continue;
if (playList.size() > 0) {
urlMap.put(idx,TextUtils.join("#", playList));
playList.clear();
}
name = XLTaskHelper.instance().getFileName(task_url);
playList.add(name + "$tvbox-oth:" + ed2kList.size());
ed2kList.add(task_url);
}
}
if (playList.size() > 0) {
callback.list(TextUtils.join("#", playList));
if (urlMap.size() > 0) {
callback.list(urlMap);
} else {
callback.status(-1, "文件列表为空!");
}

@ -41,6 +41,8 @@ import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@ -844,55 +846,57 @@ public class SourceViewModel extends ViewModel {
if (data.movie != null && data.movie.videoList != null && data.movie.videoList.size() == 1) {
Movie.Video video = data.movie.videoList.get(0);
if (video != null && video.urlBean != null && video.urlBean.infoList != null) {
boolean hasThunder=false;
for (int idx=0;idx<video.urlBean.infoList.size();idx++) {
Movie.Video.UrlBean.UrlInfo urlInfo=video.urlBean.infoList.get(idx);
if(urlInfo != null){
List<String> urlList = new ArrayList<>();
for (Movie.Video.UrlBean.UrlInfo.InfoBean infoBean : urlInfo.beanList) {
urlList.add(infoBean.url);
}
if (Thunder.isSupportUrl(urlInfo.beanList.get(0).url)) {
thunderParse = true;
Thunder.parse(App.getInstance(), urlList, new Thunder.ThunderCallback() {
@Override
public void status(int code, String info) {
if (code >= 0) {
LOG.i(info);
} else {
urlInfo.beanList.get(0).name = info;
detailResult.postValue(data);
}
}
Movie.Video.UrlBean.UrlInfo urlInfo = video.urlBean.infoList.get(idx);
if(Thunder.isSupportUrl(urlInfo.beanList.get(0).url)){
hasThunder=true;
break;
}
}
if (hasThunder) {
thunderParse = true;
Thunder.parse(App.getInstance(), video.urlBean, new Thunder.ThunderCallback() {
@Override
public void status(int code, String info) {
if (code >= 0) {
LOG.i(info);
} else {
video.urlBean.infoList.get(0).beanList.get(0).name = info;
detailResult.postValue(data);
}
}
@Override
public void list(String playList) {
urlInfo.urls = playList;
String[] str = playList.split("#");
List<Movie.Video.UrlBean.UrlInfo.InfoBean> infoBeanList = new ArrayList<>();
for (String s : str) {
if (s.contains("$")) {
String[] ss = s.split("\\$");
if (ss.length > 0) {
if (ss.length >= 2) {
infoBeanList.add(new Movie.Video.UrlBean.UrlInfo.InfoBean(ss[0], ss[1]));
} else {
infoBeanList.add(new Movie.Video.UrlBean.UrlInfo.InfoBean((infoBeanList.size() + 1) + "", ss[0]));
}
@Override
public void list(Map<Integer, String> urlMap) {
for (int key : urlMap.keySet()) {
String playList=urlMap.get(key);
video.urlBean.infoList.get(key).urls = playList;
String[] str = playList.split("#");
List<Movie.Video.UrlBean.UrlInfo.InfoBean> infoBeanList = new ArrayList<>();
for (String s : str) {
if (s.contains("$")) {
String[] ss = s.split("\\$");
if (ss.length > 0) {
if (ss.length >= 2) {
infoBeanList.add(new Movie.Video.UrlBean.UrlInfo.InfoBean(ss[0], ss[1]));
} else {
infoBeanList.add(new Movie.Video.UrlBean.UrlInfo.InfoBean((infoBeanList.size() + 1) + "", ss[0]));
}
}
}
urlInfo.beanList = infoBeanList;
detailResult.postValue(data);
}
video.urlBean.infoList.get(key).beanList = infoBeanList;
}
detailResult.postValue(data);
}
@Override
public void play(String url) {
@Override
public void play(String url) {
}
});
}
}
});
}
}
}

Loading…
Cancel
Save