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

Commit

Permalink
fix m3u8 download
Browse files Browse the repository at this point in the history
  • Loading branch information
670848654 committed Jun 11, 2022
1 parent 50aa5bc commit 6f76eb9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 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 39
versionName "2.3.0"
versionCode 40
versionName "2.3.1"
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.1", "尽可能修复M3U8下载时可能出现下载失败的情况(下载时不建议批量下载过多的视频)\n*目前发现MaliMali源有些视频因资源问题导致无法播放,可尝试下载,如果能下载成功可尝试使用你的外置播放器进行播放"));
logsList.add(new LogBean("版本:2.3.0", "由于imomoe源访问变成dmh8.com(怕是凉了),番剧画质差且视频中夹带非法广告,现移除imomoe源解析替换为质量不错的malimali源,更新后将清空所有imomoe源的存储信息(下载除外)。\n修复伪装为图片格式的M3U8下载完成后合并的文件无法播放的问题。"));
logsList.add(new LogBean("版本:2.2.0", "修改首页UI,移除侧滑栏,不再将时间表作为首页展示内容\n修复下载M3U8视频失败时无法删除任务的问题\n移除设置同时下载数量功能(功能存在问题),暂设置默认下载数量为1\n修复投屏功能目前发现的一些问题\n修复我的追番列表、历史记录、下载列表中的番剧图片地址更换而无法显示的问题,更新新的图片地址存入数据库\n修改历史记录、下载列表中列表数据UI呈现样式"));
logsList.add(new LogBean("版本:2.1.0", "新增追番更新检测,有更新的番剧将排在列表最前面(仅支持Yhdm源)\n新增观看历史记录\n新增剧集下载功能\n新增保存播放进度"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ protected void running(DownloadTask downloadTask) {

@Download.onTaskComplete
public void onTaskComplete(DownloadTask downloadTask) {
Log.e("Activity onTaskComplete", downloadTask.getTaskName() + ",下载完成");
JSONObject obj = JSONObject.parseObject(Aria.download(this).load(downloadTask.getEntity().getId()).getExtendField());
for (int i = 0, size = downloadDataBeans.size(); i < size; i++) {
if (downloadDataBeans.get(i).getAnimeTitle().equals(obj.getString("title")) && downloadTask.getTaskName().contains(downloadDataBeans.get(i).getPlayNumber())) {
Expand All @@ -300,14 +301,15 @@ public void onTaskComplete(DownloadTask downloadTask) {

@Download.onTaskCancel
public void onTaskCancel(DownloadTask downloadTask) {
Log.e("onTaskCancel", downloadTask.getTaskName() + ",取消下载");
Log.e("Service onTaskCancel", downloadTask.getTaskName() + ",取消下载");
List<Object> objects = DatabaseUtil.queryDownloadAnimeInfo(downloadTask.getEntity().getId());
DatabaseUtil.deleteDownloadData(downloadDataId);
EventBus.getDefault().post(new Refresh(3));
}

@Download.onTaskFail
public void onTaskFail(DownloadTask downloadTask) {
Log.e("Service onTaskCancel", downloadTask.getTaskName() + ",下载失败");
JSONObject obj = JSONObject.parseObject(Aria.download(this).load(downloadTask.getEntity().getId()).getExtendField());
for (int i = 0, size = downloadDataBeans.size(); i < size; i++) {
if (downloadDataBeans.get(i).getAnimeTitle().equals(obj.getString("title")) && downloadTask.getTaskName().contains(downloadDataBeans.get(i).getPlayNumber())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onCreate() {
handler = new Handler(Looper.getMainLooper());
handler.post(() -> CustomToast.showToast(getApplicationContext(), "下载服务已开启", CustomToast.SUCCESS));
mNotify = new DownloadNotification(this);
Log.e("onCreate", "DownloadService开始运行");
Log.e("Service onCreate", "DownloadService开始运行");
EventBus.getDefault().post(new Refresh(3));
Aria.download(this).resumeAllTask();
Aria.download(this).register();
Expand All @@ -64,59 +64,59 @@ public void onDestroy() {
wakeLock = null;
}
Aria.download(this).unRegister();
Log.e("onDestroy", "DownloadService销毁了");
Log.e("Service onDestroy", "DownloadService销毁了");
handler.post(() -> CustomToast.showToast(getApplicationContext(), "下载服务已关闭", CustomToast.SUCCESS));
super.onDestroy();
}

@Download.onWait
public void onTaskWait(DownloadTask downloadTask) {
Log.e("onTaskWait", downloadTask.getTaskName() + ",等待处理");
Log.e("Service onTaskWait", downloadTask.getTaskName() + ",等待处理");
EventBus.getDefault().post(new Refresh(3));
}

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


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

@Download.onTaskStop
public void onTaskStop(DownloadTask downloadTask) {
Log.e("onTaskStop", downloadTask.getTaskName() + ",停止下载");
shouldDestroy();
Log.e("Service onTaskStop", downloadTask.getTaskName() + ",停止下载");
// shouldDestroy();
}

@Download.onTaskCancel
public void onTaskCancel(DownloadTask downloadTask) {
Log.e("onTaskCancel", downloadTask.getTaskName() + ",取消下载");
Log.e("Service onTaskCancel", downloadTask.getTaskName() + ",取消下载");
// showInfo(downloadTask, "取消下载");
shouldDestroy();
// shouldDestroy();
}

@Download.onTaskFail
public void onTaskFail(DownloadTask downloadTask) {
Log.e("onTaskFail", downloadTask.getTaskName() + ",下载失败");
Log.e("Service onTaskFail", downloadTask.getTaskName() + ",下载失败");
DatabaseUtil.updateDownloadError((String) getAnimeInfo(downloadTask, 0), (Integer) getAnimeInfo(downloadTask, 1), downloadTask.getFilePath(), downloadTask.getEntity().getId(), downloadTask.getFileSize());
mNotify.uploadInfo(new Long(downloadTask.getEntity().getId()).intValue(), false);
shouldDestroy();
// shouldDestroy();
}

@Download.onTaskComplete
public void onTaskComplete(DownloadTask downloadTask) {
Log.e("onTaskComplete", downloadTask.getTaskName() + ",下载完成");
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());
shouldDestroy();
// shouldDestroy();
}

@Download.onTaskRunning
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/res/layout/item_history.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_height="wrap_content"
android:orientation="horizontal">

<RelativeLayout
Expand All @@ -34,9 +34,13 @@

<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="W,9:16"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="3dp"
android:transitionName="sharedImg" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<string name="test_model_desc">OnePlus 8 Pro\nAndroid 12</string>
<string name="now_version">当前版本</string>
<string name="final_compile">最后编译日期</string>
<string name="final_compile_time">2022年6月2日</string>
<string name="final_compile_time">2022年6月11日</string>
<string name="cache">缓存目录</string>
<string name="cache_text">/SakuraAnime/\n卸载后自行删除此目录</string>
<string name="github">Github仓库</string>
Expand Down

0 comments on commit 6f76eb9

Please sign in to comment.