diff --git a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt index 222bdcbbeef..b97c3b34369 100644 --- a/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt +++ b/app/src/main/java/ani/dantotsu/download/DownloadsManager.kt @@ -369,7 +369,7 @@ class DownloadsManager(private val context: Context) { } private const val RESERVED_CHARS = "|\\?*<\":>+[]/'" -private fun String?.findValidName(): String { +fun String?.findValidName(): String { return this?.filterNot { RESERVED_CHARS.contains(it) } ?: "" } diff --git a/app/src/main/java/ani/dantotsu/download/anime/OfflineAnimeFragment.kt b/app/src/main/java/ani/dantotsu/download/anime/OfflineAnimeFragment.kt index 3a3216c16dd..ea63bcd897b 100644 --- a/app/src/main/java/ani/dantotsu/download/anime/OfflineAnimeFragment.kt +++ b/app/src/main/java/ani/dantotsu/download/anime/OfflineAnimeFragment.kt @@ -36,6 +36,7 @@ import ani.dantotsu.download.DownloadCompat.Companion.loadOfflineAnimeModelCompa import ani.dantotsu.download.DownloadedType import ani.dantotsu.download.DownloadsManager import ani.dantotsu.download.DownloadsManager.Companion.compareName +import ani.dantotsu.download.findValidName import ani.dantotsu.initActivity import ani.dantotsu.media.Media import ani.dantotsu.media.MediaDetailsActivity @@ -289,7 +290,7 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener { } downloadsJob = Job() CoroutineScope(Dispatchers.IO + downloadsJob).launch { - val animeTitles = downloadManager.animeDownloadedTypes.map { it.titleName }.distinct() + val animeTitles = downloadManager.animeDownloadedTypes.map { it.titleName.findValidName() }.distinct() val newAnimeDownloads = mutableListOf() for (title in animeTitles) { val tDownloads = downloadManager.animeDownloadedTypes.filter { it.titleName == title } @@ -365,6 +366,7 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener { val bannerUri: Uri? = if (banner?.exists() == true) { banner.uri } else null + if (coverUri == null && bannerUri == null) throw Exception("No cover or banner found, probably compat") val title = mediaModel.mainName() val score = ((if (mediaModel.userScore == 0) (mediaModel.meanScore ?: 0) else mediaModel.userScore) / 10.0).toString() diff --git a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt index f368a77a5bb..3ee64ee42c0 100644 --- a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt +++ b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt @@ -34,6 +34,7 @@ import ani.dantotsu.download.DownloadedType import ani.dantotsu.download.DownloadsManager import ani.dantotsu.download.DownloadsManager.Companion.compareName import ani.dantotsu.download.DownloadsManager.Companion.getSubDirectory +import ani.dantotsu.download.findValidName import ani.dantotsu.initActivity import ani.dantotsu.media.Media import ani.dantotsu.media.MediaDetailsActivity @@ -280,7 +281,7 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener { downloads = listOf() downloadsJob = Job() CoroutineScope(Dispatchers.IO + downloadsJob).launch { - val mangaTitles = downloadManager.mangaDownloadedTypes.map { it.titleName }.distinct() + val mangaTitles = downloadManager.mangaDownloadedTypes.map { it.titleName.findValidName() }.distinct() val newMangaDownloads = mutableListOf() for (title in mangaTitles) { val tDownloads = downloadManager.mangaDownloadedTypes.filter { it.titleName == title } @@ -356,6 +357,7 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener { val bannerUri: Uri? = if (banner?.exists() == true) { banner.uri } else null + if (coverUri == null && bannerUri == null) throw Exception("No cover or banner found, probably compat") val title = mediaModel.mainName() val score = ((if (mediaModel.userScore == 0) (mediaModel.meanScore ?: 0) else mediaModel.userScore) / 10.0).toString() diff --git a/app/src/main/java/ani/dantotsu/parsers/OfflineMangaParser.kt b/app/src/main/java/ani/dantotsu/parsers/OfflineMangaParser.kt index 113375ae6cc..f0c1237f977 100644 --- a/app/src/main/java/ani/dantotsu/parsers/OfflineMangaParser.kt +++ b/app/src/main/java/ani/dantotsu/parsers/OfflineMangaParser.kt @@ -44,7 +44,8 @@ class OfflineMangaParser : MangaParser() { } } chapters.addAll(loadChaptersCompat(mangaLink, extra, sManga)) - chapters.distinctBy { it.number }.sortedBy { MediaNameAdapter.findChapterNumber(it.number) } + return chapters.distinctBy { it.number } + .sortedBy { MediaNameAdapter.findChapterNumber(it.number) } } return emptyList() }