Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
fix malimali source & fix download
Browse files Browse the repository at this point in the history
  • Loading branch information
670848654 committed Jul 14, 2022
1 parent 40a4a07 commit 0d580ae
Show file tree
Hide file tree
Showing 16 changed files with 379 additions and 68 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "my.project.sakuraproject"
minSdkVersion 21
targetSdkVersion 30
versionCode 42
versionName "2.3.3"
versionCode 43
versionName "2.3.4"
ndk{abiFilters "arm64-v8a", "x86_64"}
resConfigs"zh"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public void showUpdateLogs() {

public List createUpdateLogList() {
List logsList = new ArrayList();
logsList.add(new LogBean("版本:2.3.4", "修复malimali源站点UI改版(又变回原来的UI了。。。)导致所有相关解析出错的问题\n修复在下载列表界面中出现下载成功但显示下载失败的问题"));
logsList.add(new LogBean("版本:2.3.3", "malimali域名变更为https://www.malimali6.com\n修复malimali源站点UI改版导致所有相关解析出错的问题\nmalimali源新增当视频地址是链接到腾讯视频等视频网站资源时,在播放失败时选择网页嗅探时加入了几个免费的VIP视频解析接口(不保证长期有效),下载该类型的视频时同理,但不保证一定能嗅探成功\n**由于malimali源站点改版导致部分番剧的地址发生变化可能导致在我的收藏、历史记录等界面操作时出现崩溃的情况,如出现请手动删除相关信息"));
logsList.add(new LogBean("版本:2.3.2", "修复在下载过程中应用异常退出后再进行继续下载时TS转换器被回收导致下载完成后无法合并的问题\n修复Aria下载框架使用不当存在内存泄露的问题\n*本次更新后建议先手动删除所有下载失败的剧集,否则可能出现数据错乱...\n**选择多集批量下载时有时会出现未创建下载任务的情况,如出现该问题请删除未执行下载剧集后自行重新下载"));
logsList.add(new LogBean("版本:2.3.1", "尽可能修复M3U8下载时可能出现下载失败的情况(下载时不建议批量下载过多的视频)\n*目前发现MaliMali源有些视频因资源问题导致无法播放,可尝试下载,如果能下载成功可尝试使用你的外置播放器进行播放"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,17 @@ public class HomeActivity extends BaseActivity<HomeContract.View, HomePresenter>

@Override
protected HomePresenter createPresenter() {
return new HomePresenter(false, this);
return new HomePresenter(false, "", this);
// return new HomePresenter(false, this);
}

@Override
protected void loadData() {
mPresenter.loadData(true);
if (Utils.isImomoe())
mPresenter.loadMailiHtmlData();
else
mPresenter.loadData(true);
// mPresenter.loadData(true);
}

@Override
Expand Down Expand Up @@ -291,7 +296,7 @@ public void showHomeLoadSuccess(List<HomeBean> beans) {
mSwipe.setRefreshing(false);
multiItemEntities = new ArrayList<>();
headerDataBeans = new ArrayList<>();
headerDataBeans.add(new HomeHeaderBean.HeaderDataBean("新番时间表", R.drawable.ic_xfsjb, HomeHeaderBean.TYPE_XFSJB));
headerDataBeans.add(new HomeHeaderBean.HeaderDataBean("时间表", R.drawable.ic_xfsjb, HomeHeaderBean.TYPE_XFSJB));
if (!Utils.isImomoe()) {
headerDataBeans.add(new HomeHeaderBean.HeaderDataBean("动漫分类", R.drawable.ic_dmfl, HomeHeaderBean.TYPE_DMFL));
headerDataBeans.add(new HomeHeaderBean.HeaderDataBean("动漫电影", R.drawable.ic_dmdy, HomeHeaderBean.TYPE_DMDY));
Expand All @@ -316,6 +321,13 @@ public void showUpdateInfoSuccess(List<AnimeUpdateInfoBean> beans) {
animeUpdateInfoBeans = beans;
}

@Override
public void showMaliWeekInfoSuccess(String html) {
maliHtml = html;
mPresenter = new HomePresenter(false, html, this);
mPresenter.loadData(true);
}

private void setTheme(boolean isDark) {
isChangingTheme = true;
if (isDark) {
Expand Down Expand Up @@ -418,7 +430,8 @@ public void onHeaderClick(HomeHeaderBean.HeaderDataBean bean) {
//===========================================================
case HomeHeaderBean.TYPE_DMFL_MALIMALI_TAG:
bundle.putString("homeParam", Api.MALIMALI_TAG_DEFAULT);
bundle.putString("title", "全部类型");
// bundle.putString("title", "全部类型");
bundle.putString("title", "全部");
startActivity(new Intent(this, MaliTagActivity.class).putExtras(bundle));
break;
case HomeHeaderBean.TYPE_DMFL_MALIMALI_JAPAN:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

public interface HomeContract {
interface Model {
void getData(boolean isWeek, LoadDataCallback callback);
void getData(boolean isWeek, String mailiHtml, LoadDataCallback callback);

void getMaliWeek(LoadDataCallback callback);

// void getData(boolean isWeek, LoadDataCallback callback);
}

interface View extends BaseView {
Expand All @@ -19,6 +23,8 @@ interface View extends BaseView {
void showHomeLoadSuccess(List<HomeBean> beans);

void showUpdateInfoSuccess(List<AnimeUpdateInfoBean> animeUpdateInfoBeans);

void showMaliWeekInfoSuccess(String html);
}

interface LoadDataCallback extends BaseLoadDataCallback {
Expand All @@ -27,5 +33,7 @@ interface LoadDataCallback extends BaseLoadDataCallback {
void homeSuccess(List<HomeBean> beans);

void updateInfoSuccess(List<AnimeUpdateInfoBean> animeUpdateInfoBeans);

void maliWeekInfoSuccess(String html);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,27 @@
public class HomeModel extends BaseModel implements HomeContract.Model {

@Override
public void getData(boolean isWeek, String mailiHtml, HomeContract.LoadDataCallback callback) {
if (isImomoe())
parserImomoe(isWeek, mailiHtml, callback);
else
parserYhdm(isWeek, mailiHtml, callback, "");
}

@Override
public void getMaliWeek(HomeContract.LoadDataCallback callback) {
getJapanWeekData(callback);
}

/*@Override
public void getData(boolean isWeek, HomeContract.LoadDataCallback callback) {
if (isImomoe())
parserImomoe(isWeek, callback);
else
parserYhdm(isWeek, callback, "");
}
}*/

private void parserYhdm(boolean isWeek, HomeContract.LoadDataCallback callback, String RedirectedStr) {
private void parserYhdm(boolean isWeek, String mailiHtml, HomeContract.LoadDataCallback callback, String RedirectedStr) {
callback.log(Sakura.DOMAIN + RedirectedStr);
new HttpGet(Sakura.DOMAIN + RedirectedStr, new Callback() {
@Override
Expand All @@ -41,10 +54,10 @@ public void onResponse(Call call, Response response) {
try {
String source = getBody(response);
if (YhdmJsoupUtils.hasRedirected(source)) // 如果有重定向
parserYhdm(isWeek, callback, YhdmJsoupUtils.getRedirectedStr(source));
parserYhdm(isWeek, mailiHtml, callback, YhdmJsoupUtils.getRedirectedStr(source));
else {
if (YhdmJsoupUtils.hasRefresh(source)) // 如果有定时跳转
parserYhdm(isWeek, callback, "");
parserYhdm(isWeek, mailiHtml, callback, "");
else {
if (isWeek) {
LinkedHashMap map = YhdmJsoupUtils.getHomeData(source);
Expand Down Expand Up @@ -73,7 +86,7 @@ public void onResponse(Call call, Response response) {
});
}

private void parserImomoe(boolean isWeek, HomeContract.LoadDataCallback callback) {
private void parserImomoe(boolean isWeek, String mailiHtml, HomeContract.LoadDataCallback callback) {
callback.log(Sakura.DOMAIN);
new HttpGet(Sakura.DOMAIN, new Callback() {
@Override
Expand All @@ -86,7 +99,7 @@ public void onResponse(Call call, Response response) {
try {
String source = getBody(response);
if (isWeek) {
LinkedHashMap map = ImomoeJsoupUtils.getHomeData(source);
LinkedHashMap map = ImomoeJsoupUtils.getHomeData(mailiHtml, source);
if ((boolean) map.get("success"))
callback.success(map);
else
Expand All @@ -106,4 +119,25 @@ public void onResponse(Call call, Response response) {
}
});
}

private void getJapanWeekData(HomeContract.LoadDataCallback callback) {
new HttpGet(Sakura.DOMAIN + Api.MALIMALI_JAPAN_WEEK, new Callback() {

@Override
public void onFailure(Call call, IOException e) {
callback.maliWeekInfoSuccess("");
}

@Override
public void onResponse(Call call, Response response) {
try {
String japanSource = getBody(response);
callback.maliWeekInfoSuccess(japanSource);
} catch (Exception e) {
e.printStackTrace();
callback.maliWeekInfoSuccess("");
}
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,36 @@

public class HomePresenter extends Presenter<HomeContract.View> implements BasePresenter, HomeContract.LoadDataCallback {
private boolean isWeek;
private String maliHtml;
private HomeContract.View view;
private HomeModel model;

public HomePresenter(boolean isWeek, HomeContract.View view) {
public HomePresenter(boolean isWeek, String maliHtml, HomeContract.View view) {
super(view);
this.isWeek = isWeek;
this.maliHtml = maliHtml;
this.view = view;
model = new HomeModel();
}

/*public HomePresenter(boolean isWeek, HomeContract.View view) {
super(view);
this.isWeek = isWeek;
this.view = view;
model = new HomeModel();
}*/

@Override
public void loadData(boolean isMain) {
if (isMain)
view.showLoadingView();
model.getData(isWeek, this);
// model.getData(isWeek, this);
model.getData(isWeek, maliHtml, this);
}

public void loadMailiHtmlData() {
view.showLoadingView();
model.getMaliWeek(this);
}

@Override
Expand All @@ -42,6 +57,12 @@ public void updateInfoSuccess(List<AnimeUpdateInfoBean> animeUpdateInfoBeans) {
view.showUpdateInfoSuccess(animeUpdateInfoBeans);
}

@Override
public void maliWeekInfoSuccess(String html) {
view.showMaliWeekInfoSuccess(html);
}


@Override
public void error(String msg) {
view.showLoadErrorView(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import my.project.sakuraproject.main.player.LocalPlayerActivity;
import my.project.sakuraproject.util.SwipeBackLayoutUtil;
import my.project.sakuraproject.util.Utils;
import my.project.sakuraproject.util.VideoUtils;

public class DownloadDataActivity extends BaseActivity<DownloadDataContract.View, DownloadDataPresenter> implements DownloadDataContract.View {
@BindView(R.id.rv_list)
Expand Down Expand Up @@ -294,6 +295,7 @@ public void onTaskComplete(DownloadTask downloadTask) {
downloadDataBeans.get(i).setPath(downloadTask.getFilePath());
}
adapter.notifyItemChanged(i);
DatabaseUtil.updateDownloadSuccess((String) VideoUtils.getAnimeInfo(downloadTask, 0), (Integer) VideoUtils.getAnimeInfo(downloadTask, 1), downloadTask.getFilePath(), downloadTask.getEntity().getId(), downloadTask.getFileSize());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import my.project.sakuraproject.main.my.UpdateImgPresenter;
import my.project.sakuraproject.services.DownloadService;
import my.project.sakuraproject.util.Utils;
import my.project.sakuraproject.util.VideoUtils;

public class DownloadFragment extends MyLazyFragment<DownloadContract.View, DownloadPresenter> implements DownloadContract.View, UpdateImgContract.View {
@BindView(R.id.rv_list)
Expand Down Expand Up @@ -200,6 +201,7 @@ public void onTaskComplete(DownloadTask downloadTask) {
downloadList.get(i).setFilesSize(DatabaseUtil.queryDownloadFilesSize(downloadList.get(i).getDownloadId()));
downloadList.get(i).setNoCompleteSize(DatabaseUtil.queryDownloadNotCompleteCount(downloadList.get(i).getDownloadId()));
adapter.notifyItemChanged(i);
DatabaseUtil.updateDownloadSuccess((String) VideoUtils.getAnimeInfo(downloadTask, 0), (Integer) VideoUtils.getAnimeInfo(downloadTask, 1), downloadTask.getFilePath(), downloadTask.getEntity().getId(), downloadTask.getFileSize());
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ public class MaliTagActivity extends BaseActivity<TagContract.View, TagPresenter
public final static String FL_CHINA = "国产动漫";
public final static String FL_JAPAN = "日韩动漫";
public final static String FL_EUROPE = "欧美动漫";
private final static String FL = "全部类型";
/*private final static String FL = "全部类型";
private final static String LX = "全部剧情";
private final static String NF = "全部时间";
private final static String ZM = "全部字母";
private final static String ZM = "全部字母";*/
private final static String FL = "分类";
private final static String LX = "类型";
private final static String NF = "年份";
private final static String ZM = "字母";
private String homeParam = "";
private String title = "";
private LinearLayout listView;
Expand Down Expand Up @@ -251,7 +255,8 @@ private void initTagAdapter() {
adapter.setNewData(maliTagLists);
mSwipe.setEnabled(true);
// 刷新动漫列表
params[2] = bean.getItemTitle().contains("全部") ? "" : bean.getItemTitle();
params[2] = bean.getItemTitle().equals("全部") ? "" : bean.getItemTitle();
// params[2] = bean.getItemTitle().contains("全部") ? "" : bean.getItemTitle();
nowPage = 1;
params[4] = nowPage + "";
getTagData();
Expand All @@ -278,7 +283,8 @@ private void initTagAdapter() {
adapter.setNewData(maliTagLists);
mSwipe.setEnabled(true);
// 刷新动漫列表
params[5] = bean.getItemTitle().contains("全部") ? "" : bean.getItemTitle();
params[5] = bean.getItemTitle().equals("全部") ? "" : bean.getItemTitle();
// params[5] = bean.getItemTitle().contains("全部") ? "" : bean.getItemTitle();
nowPage = 1;
params[4] = nowPage + "";
getTagData();
Expand All @@ -305,7 +311,8 @@ private void initTagAdapter() {
adapter.setNewData(maliTagLists);
mSwipe.setEnabled(true);
// 刷新动漫列表
params[3] = bean.getItemTitle().contains("全部") ? "" : bean.getItemTitle();
params[3] = bean.getItemTitle().equals("全部") ? "" : bean.getItemTitle();
// params[3] = bean.getItemTitle().contains("全部") ? "" : bean.getItemTitle();
nowPage = 1;
params[4] = nowPage + "";
getTagData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public class WeekActivity extends BaseActivity<HomeContract.View, HomePresenter>

@Override
protected HomePresenter createPresenter() {
return new HomePresenter(true, this);
return new HomePresenter(true, getIntent().getExtras().getString("html"), this);
// return new HomePresenter(true, this);
}

@Override
Expand Down Expand Up @@ -159,6 +160,12 @@ public void showUpdateInfoSuccess(List<AnimeUpdateInfoBean> animeUpdateInfoBeans

}

@Override
public void showMaliWeekInfoSuccess(String html) {
mPresenter = new HomePresenter(false, html, this);
mPresenter.loadData(false);
}

public void setWeekAdapter(int pos) {
adapter = new WeekAdapter(getSupportFragmentManager(), tab.getTabCount());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ public void onTaskWait(DownloadTask downloadTask) {
@Download.onTaskResume
public void onTaskResume(DownloadTask downloadTask) {
Log.e("Service onTaskStart", downloadTask.getTaskName() + ",恢复下载");
mNotify.showNotification(new Long(downloadTask.getEntity().getId()).intValue(), (String) getAnimeInfo(downloadTask, 0), downloadTask.getTaskName());
mNotify.showNotification(new Long(downloadTask.getEntity().getId()).intValue(), (String) VideoUtils.getAnimeInfo(downloadTask, 0), downloadTask.getTaskName());
// EventBus.getDefault().post(new Refresh(3));
}


@Download.onTaskStart
public void onTaskStart(DownloadTask downloadTask) {
Log.e("Service onTaskStart", downloadTask.getTaskName() + ",开始下载");
mNotify.showNotification(new Long(downloadTask.getEntity().getId()).intValue(), (String) getAnimeInfo(downloadTask, 0), downloadTask.getTaskName());
mNotify.showNotification(new Long(downloadTask.getEntity().getId()).intValue(), (String) VideoUtils.getAnimeInfo(downloadTask, 0), downloadTask.getTaskName());
// EventBus.getDefault().post(new Refresh(3));
}

Expand All @@ -215,7 +215,7 @@ public void onTaskCancel(DownloadTask downloadTask) {
@Download.onTaskFail
public void onTaskFail(DownloadTask downloadTask) {
Log.e("Service onTaskFail", downloadTask.getTaskName() + ",下载失败");
DatabaseUtil.updateDownloadError((String) getAnimeInfo(downloadTask, 0), (Integer) getAnimeInfo(downloadTask, 1), downloadTask.getFilePath(), downloadTask.getEntity().getId(), downloadTask.getFileSize());
DatabaseUtil.updateDownloadError((String) VideoUtils.getAnimeInfo(downloadTask, 0), (Integer) VideoUtils.getAnimeInfo(downloadTask, 1), downloadTask.getFilePath(), downloadTask.getEntity().getId(), downloadTask.getFileSize());
mNotify.uploadInfo(new Long(downloadTask.getEntity().getId()).intValue(), false);
shouldUnRegister();
}
Expand All @@ -224,7 +224,7 @@ public void onTaskFail(DownloadTask downloadTask) {
public void onTaskComplete(DownloadTask downloadTask) {
Log.e("Service onTaskComplete", downloadTask.getTaskName() + ",下载完成");
mNotify.uploadInfo(new Long(downloadTask.getEntity().getId()).intValue(), true);
DatabaseUtil.updateDownloadSuccess((String) getAnimeInfo(downloadTask, 0), (Integer) getAnimeInfo(downloadTask, 1), downloadTask.getFilePath(), downloadTask.getEntity().getId(), downloadTask.getFileSize());
DatabaseUtil.updateDownloadSuccess((String) VideoUtils.getAnimeInfo(downloadTask, 0), (Integer) VideoUtils.getAnimeInfo(downloadTask, 1), downloadTask.getFilePath(), downloadTask.getEntity().getId(), downloadTask.getFileSize());
shouldUnRegister();
}

Expand All @@ -240,15 +240,4 @@ private void shouldUnRegister() {
Log.e("Service onTaskFail", "Aria取消注册");
}
}

/**
* 根据任务ID查询数据库信息
* @param downloadTask
* @param choose 0 返回番剧标题 1 返回番剧来源
* @return
*/
private Object getAnimeInfo(DownloadTask downloadTask, int choose) {
List<Object> objects = DatabaseUtil.queryDownloadAnimeInfo(downloadTask.getEntity().getId());
return objects.get(choose);
}
}
Loading

0 comments on commit 0d580ae

Please sign in to comment.