themes and various bugs

This commit is contained in:
Finnley Somdahl 2023-10-24 23:38:46 -05:00
parent dc165fa6bc
commit 63526c6ed3
114 changed files with 1719 additions and 558 deletions

View file

@ -32,8 +32,10 @@ abstract class AnimeParser : BaseParser() {
* Returns null, if no latest episode is found.
* **/
open suspend fun getLatestEpisode(animeLink: String, extra: Map<String, String>?, sAnime: SAnime, latest: Float): Episode?{
return loadEpisodes(animeLink, extra, sAnime)
val episodes = loadEpisodes(animeLink, extra, sAnime)
val max = episodes
.maxByOrNull { it.number.toFloatOrNull()?:0f }
return max
?.takeIf { latest < (it.number.toFloatOrNull() ?: 0.001f) }
}

View file

@ -38,7 +38,10 @@ import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.File
import java.io.FileOutputStream
import java.io.OutputStream
@ -498,7 +501,24 @@ class VideoServerPassthrough(val videoServer: VideoServer) : VideoExtractor() {
}
}
private fun TrackToSubtitle(track: Track, type: SubtitleType = SubtitleType.VTT): Subtitle {
return Subtitle(track.lang, track.url, type)
private fun TrackToSubtitle(track: Track): Subtitle {
//use Dispatchers.IO to make a HTTP request to determine the subtitle type
var type: SubtitleType? = null
runBlocking {
type = findSubtitleType(track.url)
}
return Subtitle(track.lang, track.url, type?: SubtitleType.SRT)
}
private fun findSubtitleType(url: String): SubtitleType? {
// First, try to determine the type based on the URL file extension
var type: SubtitleType? = when {
url.endsWith(".vtt", true) -> SubtitleType.VTT
url.endsWith(".ass", true) -> SubtitleType.ASS
url.endsWith(".srt", true) -> SubtitleType.SRT
else -> SubtitleType.UNKNOWN
}
return type
}
}

View file

@ -3,6 +3,7 @@ package ani.dantotsu.parsers
import android.graphics.Bitmap
import ani.dantotsu.FileUrl
import ani.dantotsu.media.Media
import ani.dantotsu.media.manga.MangaNameAdapter
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
@ -23,9 +24,11 @@ abstract class MangaParser : BaseParser() {
* Returns null, if no latest chapter is found.
* **/
open suspend fun getLatestChapter(mangaLink: String, extra: Map<String, String>?, sManga: SManga, latest: Float): MangaChapter? {
return loadChapters(mangaLink, extra, sManga)
.maxByOrNull { it.number.toFloatOrNull() ?: 0f }
?.takeIf { latest < (it.number.toFloatOrNull() ?: 0.001f) }
val chapter = loadChapters(mangaLink, extra, sManga)
val max = chapter
.maxByOrNull { MangaNameAdapter.findChapterNumber(it.number) ?: 0f }
return max
?.takeIf { latest < (MangaNameAdapter.findChapterNumber(it.number) ?: 0.001f) }
}
/**
@ -33,22 +36,6 @@ abstract class MangaParser : BaseParser() {
* **/
abstract suspend fun loadImages(chapterLink: String, sChapter: SChapter): List<MangaImage>
/*override suspend fun autoSearch(mediaObj: Media): ShowResponse? {
var response = loadSavedShowResponse(mediaObj.id)
if (response != null) {
saveShowResponse(mediaObj.id, response, true)
} else {
setUserText("Searching : ${mediaObj.mangaName()}")
response = search(mediaObj.mangaName()).let { if (it.isNotEmpty()) it[0] else null }
if (response == null) {
setUserText("Searching : ${mediaObj.nameRomaji}")
response = search(mediaObj.nameRomaji).let { if (it.isNotEmpty()) it[0] else null }
}
saveShowResponse(mediaObj.id, response)
}
return response
}*/
open fun getTransformation(): BitmapTransformation? = null
}

View file

@ -159,5 +159,5 @@ enum class VideoType{
}
enum class SubtitleType{
VTT, ASS, SRT
VTT, ASS, SRT, UNKNOWN
}