From 5d20feb2adf83d962f5c1228f1173e93e05b383c Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Wed, 2 Mar 2022 15:49:07 +0100 Subject: [PATCH] fixed #739 --- .../cloudstream3/animeproviders/TenshiProvider.kt | 5 +++-- .../cloudstream3/utils/DownloadFileWorkManager.kt | 7 +++---- .../cloudstream3/utils/VideoDownloadManager.kt | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt index 424850ea..40b2f87b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt @@ -245,9 +245,10 @@ class TenshiProvider : MainAPI() { } val episodes = ArrayList(episodeNodes.map { + val title = it.selectFirst(".episode-title")?.text()?.trim() AnimeEpisode( it.attr("href"), - it.selectFirst(".episode-title")?.text()?.trim(), + if(title == "No Title") null else title, it.selectFirst("img")?.attr("src"), dateParser(it?.selectFirst(".episode-date")?.text()?.trim()), null, @@ -342,7 +343,7 @@ class TenshiProvider : MainAPI() { headers = getHeaders( mapOf(), null, - ddosGuardKiller?.savedCookiesMap?.get(URI(this.mainUrl).host) ?: mapOf() + ddosGuardKiller.savedCookiesMap.get(URI(this.mainUrl).host) ?: mapOf() ).toMap() ) }) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/DownloadFileWorkManager.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/DownloadFileWorkManager.kt index fbf1b626..c1eb649b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/DownloadFileWorkManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/DownloadFileWorkManager.kt @@ -44,7 +44,6 @@ class DownloadFileWorkManager(val context: Context, private val workerParams: Wo ::handleNotification ) awaitDownload(info.ep.id) - } else if (pkg != null) { downloadFromResume(applicationContext, pkg, ::handleNotification) awaitDownload(pkg.item.ep.id) @@ -68,9 +67,9 @@ class DownloadFileWorkManager(val context: Context, private val workerParams: Wo private suspend fun awaitDownload(id: Int) { var isDone = false - val listener = { data: Pair -> - if (id == data.first) { - when (data.second) { + val listener = { (localId, localType): Pair -> + if (id == localId) { + when (localType) { VideoDownloadManager.DownloadType.IsDone, VideoDownloadManager.DownloadType.IsFailed, VideoDownloadManager.DownloadType.IsStopped -> { isDone = true } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt index 8ff0727e..a11cd7f3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt @@ -36,7 +36,6 @@ import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.removeKey import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.withContext import okhttp3.internal.closeQuietly @@ -1346,7 +1345,18 @@ object VideoDownloadManager { tryResume: Boolean = false, ): Int { val name = - sanitizeFilename(ep.name ?: "${context.getString(R.string.episode)} ${ep.episode}") + // kinda ugly ik + sanitizeFilename( + if (ep.name == null) { + "${context.getString(R.string.episode)} ${ep.episode}" + } else { + if (ep.episode != null) { + "${context.getString(R.string.episode)} ${ep.episode} - ${ep.name}" + } else { + ep.name + } + } + ) // Make sure this is cancelled when download is done or cancelled. val extractorJob = ioSafe {