feat: custom downloader and downloader location (#313)
* feat: custom downloader (novel broken) * fix: send headers to ffmpeg ffmpeg can be a real bitch to work with * fix: offline page for new download system * feat: novel to new system | load freezing * chore: clean manifest * fix: notification incrementing * feat: changing the downloads dir
This commit is contained in:
parent
75e90541c9
commit
720b40afa7
35 changed files with 1162 additions and 1018 deletions
|
@ -1,9 +1,12 @@
|
|||
package ani.dantotsu.parsers
|
||||
|
||||
import android.app.Application
|
||||
import android.os.Environment
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.download.DownloadsManager
|
||||
import ani.dantotsu.download.DownloadsManager.Companion.getSubDirectory
|
||||
import ani.dantotsu.media.MediaNameAdapter
|
||||
import ani.dantotsu.media.MediaType
|
||||
import me.xdrop.fuzzywuzzy.FuzzySearch
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -11,6 +14,7 @@ import java.io.File
|
|||
|
||||
class OfflineNovelParser : NovelParser() {
|
||||
private val downloadManager = Injekt.get<DownloadsManager>()
|
||||
private val context = Injekt.get<Application>()
|
||||
|
||||
override val hostUrl: String = "Offline"
|
||||
override val name: String = "Offline"
|
||||
|
@ -21,19 +25,16 @@ class OfflineNovelParser : NovelParser() {
|
|||
|
||||
override suspend fun loadBook(link: String, extra: Map<String, String>?): Book {
|
||||
//link should be a directory
|
||||
val directory = File(
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/Novel/$link"
|
||||
)
|
||||
val directory = getSubDirectory(context, MediaType.NOVEL, false, link)
|
||||
val chapters = mutableListOf<Book>()
|
||||
if (directory.exists()) {
|
||||
directory.listFiles()?.forEach {
|
||||
if (directory?.exists() == true) {
|
||||
directory.listFiles().forEach {
|
||||
if (it.isDirectory) {
|
||||
val chapter = Book(
|
||||
it.name,
|
||||
it.absolutePath + "/cover.jpg",
|
||||
it.name?:"Unknown",
|
||||
it.uri.toString(),
|
||||
null,
|
||||
listOf(it.absolutePath + "/0.epub")
|
||||
listOf(it.uri.toString())
|
||||
)
|
||||
chapters.add(chapter)
|
||||
}
|
||||
|
@ -60,20 +61,16 @@ class OfflineNovelParser : NovelParser() {
|
|||
val returnList: MutableList<ShowResponse> = mutableListOf()
|
||||
for (title in returnTitles) {
|
||||
//need to search the subdirectories for the ShowResponses
|
||||
val directory = File(
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
|
||||
"Dantotsu/Novel/$title"
|
||||
)
|
||||
val directory = getSubDirectory(context, MediaType.NOVEL, false, title)
|
||||
val names = mutableListOf<String>()
|
||||
if (directory.exists()) {
|
||||
directory.listFiles()?.forEach {
|
||||
if (directory?.exists() == true) {
|
||||
directory.listFiles().forEach {
|
||||
if (it.isDirectory) {
|
||||
names.add(it.name)
|
||||
names.add(it.name?: "Unknown")
|
||||
}
|
||||
}
|
||||
}
|
||||
val cover =
|
||||
currContext()?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)?.absolutePath + "/Dantotsu/Novel/$title/cover.jpg"
|
||||
val cover = directory?.findFile("cover.jpg")?.uri.toString()
|
||||
names.forEach {
|
||||
returnList.add(ShowResponse(it, it, cover))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue