aniwave fix
This commit is contained in:
parent
9416c88511
commit
3693179c78
2 changed files with 58 additions and 56 deletions
|
@ -126,5 +126,6 @@ dependencies {
|
||||||
implementation 'com.github.tachiyomiorg:unifile:17bec43'
|
implementation 'com.github.tachiyomiorg:unifile:17bec43'
|
||||||
implementation 'com.github.gpanther:java-nat-sort:natural-comparator-1.1'
|
implementation 'com.github.gpanther:java-nat-sort:natural-comparator-1.1'
|
||||||
implementation 'androidx.preference:preference-ktx:1.2.1'
|
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||||
|
implementation 'app.cash.quickjs:quickjs-android:0.9.2'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||||
import eu.kanade.tachiyomi.animesource.model.Track
|
import eu.kanade.tachiyomi.animesource.model.Track
|
||||||
import eu.kanade.tachiyomi.animesource.model.Video
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
|
import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
|
||||||
import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension
|
import eu.kanade.tachiyomi.extension.anime.model.AnimeExtension
|
||||||
import eu.kanade.tachiyomi.extension.manga.model.MangaExtension
|
import eu.kanade.tachiyomi.extension.manga.model.MangaExtension
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
|
@ -84,57 +85,55 @@ class DynamicAnimeParser(extension: AnimeExtension.Installed) : AnimeParser() {
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
sourceLanguage = 0
|
sourceLanguage = 0
|
||||||
extension.sources[sourceLanguage]
|
extension.sources[sourceLanguage]
|
||||||
}
|
} as? AnimeHttpSource ?: (extension.sources[sourceLanguage] as? AnimeCatalogueSource
|
||||||
if (source is AnimeCatalogueSource) {
|
?: return emptyList())
|
||||||
try {
|
try {
|
||||||
val res = source.getEpisodeList(sAnime)
|
val res = source.getEpisodeList(sAnime)
|
||||||
|
|
||||||
val sortedEpisodes = if (res[0].episode_number == -1f) {
|
val sortedEpisodes = if (res[0].episode_number == -1f) {
|
||||||
// Find the number in the string and sort by that number
|
// Find the number in the string and sort by that number
|
||||||
val sortedByStringNumber = res.sortedBy {
|
val sortedByStringNumber = res.sortedBy {
|
||||||
val matchResult = "\\d+".toRegex().find(it.name)
|
val matchResult = "\\d+".toRegex().find(it.name)
|
||||||
val number = matchResult?.value?.toFloat() ?: Float.MAX_VALUE
|
val number = matchResult?.value?.toFloat() ?: Float.MAX_VALUE
|
||||||
it.episode_number = number // Store the found number in episode_number
|
it.episode_number = number // Store the found number in episode_number
|
||||||
number
|
number
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no number, reverse the order and give them an incrementing number
|
// If there is no number, reverse the order and give them an incrementing number
|
||||||
var incrementingNumber = 1f
|
var incrementingNumber = 1f
|
||||||
sortedByStringNumber.map {
|
sortedByStringNumber.map {
|
||||||
if (it.episode_number == Float.MAX_VALUE) {
|
if (it.episode_number == Float.MAX_VALUE) {
|
||||||
it.episode_number =
|
it.episode_number =
|
||||||
incrementingNumber++ // Update episode_number with the incrementing number
|
incrementingNumber++ // Update episode_number with the incrementing number
|
||||||
}
|
}
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var episodeCounter = 1f
|
var episodeCounter = 1f
|
||||||
// Group by season, sort within each season, and then renumber while keeping episode number 0 as is
|
// Group by season, sort within each season, and then renumber while keeping episode number 0 as is
|
||||||
val seasonGroups =
|
val seasonGroups =
|
||||||
res.groupBy { AnimeNameAdapter.findSeasonNumber(it.name) ?: 0 }
|
res.groupBy { AnimeNameAdapter.findSeasonNumber(it.name) ?: 0 }
|
||||||
seasonGroups.keys.sorted().flatMap { season ->
|
seasonGroups.keys.sorted().flatMap { season ->
|
||||||
seasonGroups[season]?.sortedBy { it.episode_number }?.map { episode ->
|
seasonGroups[season]?.sortedBy { it.episode_number }?.map { episode ->
|
||||||
if (episode.episode_number != 0f) { // Skip renumbering for episode number 0
|
if (episode.episode_number != 0f) { // Skip renumbering for episode number 0
|
||||||
val potentialNumber =
|
val potentialNumber =
|
||||||
AnimeNameAdapter.findEpisodeNumber(episode.name)
|
AnimeNameAdapter.findEpisodeNumber(episode.name)
|
||||||
if (potentialNumber != null) {
|
if (potentialNumber != null) {
|
||||||
episode.episode_number = potentialNumber
|
episode.episode_number = potentialNumber
|
||||||
} else {
|
} else {
|
||||||
episode.episode_number = episodeCounter
|
episode.episode_number = episodeCounter
|
||||||
}
|
}
|
||||||
episodeCounter++
|
episodeCounter++
|
||||||
}
|
}
|
||||||
episode
|
episode
|
||||||
} ?: emptyList()
|
} ?: emptyList()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return sortedEpisodes.map { SEpisodeToEpisode(it) }
|
|
||||||
} catch (e: Exception) {
|
|
||||||
println("Exception: $e")
|
|
||||||
}
|
}
|
||||||
return emptyList()
|
return sortedEpisodes.map { SEpisodeToEpisode(it) }
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logger("Exception: $e")
|
||||||
}
|
}
|
||||||
return emptyList() // Return an empty list if source is not an AnimeCatalogueSource
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun loadVideoServers(
|
override suspend fun loadVideoServers(
|
||||||
|
@ -147,7 +146,8 @@ class DynamicAnimeParser(extension: AnimeExtension.Installed) : AnimeParser() {
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
sourceLanguage = 0
|
sourceLanguage = 0
|
||||||
extension.sources[sourceLanguage]
|
extension.sources[sourceLanguage]
|
||||||
} as? AnimeCatalogueSource ?: return emptyList()
|
} as? AnimeHttpSource ?: (extension.sources[sourceLanguage] as? AnimeCatalogueSource
|
||||||
|
?: return emptyList())
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
val videos = source.getVideoList(sEpisode)
|
val videos = source.getVideoList(sEpisode)
|
||||||
|
@ -169,9 +169,10 @@ class DynamicAnimeParser(extension: AnimeExtension.Installed) : AnimeParser() {
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
sourceLanguage = 0
|
sourceLanguage = 0
|
||||||
extension.sources[sourceLanguage]
|
extension.sources[sourceLanguage]
|
||||||
} as? AnimeCatalogueSource ?: return emptyList()
|
} as? AnimeHttpSource ?: (extension.sources[sourceLanguage] as? AnimeCatalogueSource ?: return emptyList())
|
||||||
return try {
|
return try {
|
||||||
val res = source.fetchSearchAnime(1, query, source.getFilterList()).awaitSingle()
|
val res = source.fetchSearchAnime(1, query, source.getFilterList()).awaitSingle()
|
||||||
|
logger("query: $query")
|
||||||
convertAnimesPageToShowResponse(res)
|
convertAnimesPageToShowResponse(res)
|
||||||
} catch (e: CloudflareBypassException) {
|
} catch (e: CloudflareBypassException) {
|
||||||
logger("Exception in search: $e")
|
logger("Exception in search: $e")
|
||||||
|
@ -291,7 +292,7 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() {
|
||||||
var imageDataList: List<ImageData> = listOf()
|
var imageDataList: List<ImageData> = listOf()
|
||||||
val ret = coroutineScope {
|
val ret = coroutineScope {
|
||||||
try {
|
try {
|
||||||
println("source.name " + source.name)
|
logger("source.name " + source.name)
|
||||||
val res = source.getPageList(sChapter)
|
val res = source.getPageList(sChapter)
|
||||||
val reIndexedPages =
|
val reIndexedPages =
|
||||||
res.mapIndexed { index, page -> Page(index, page.url, page.imageUrl, page.uri) }
|
res.mapIndexed { index, page -> Page(index, page.url, page.imageUrl, page.uri) }
|
||||||
|
@ -327,7 +328,7 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() {
|
||||||
|
|
||||||
return coroutineScope {
|
return coroutineScope {
|
||||||
try {
|
try {
|
||||||
println("source.name " + source.name)
|
logger("source.name " + source.name)
|
||||||
val res = source.getPageList(sChapter)
|
val res = source.getPageList(sChapter)
|
||||||
val reIndexedPages =
|
val reIndexedPages =
|
||||||
res.mapIndexed { index, page -> Page(index, page.url, page.imageUrl, page.uri) }
|
res.mapIndexed { index, page -> Page(index, page.url, page.imageUrl, page.uri) }
|
||||||
|
@ -359,8 +360,8 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() {
|
||||||
try {
|
try {
|
||||||
// Fetch the image
|
// Fetch the image
|
||||||
val response = httpSource.getImage(page)
|
val response = httpSource.getImage(page)
|
||||||
println("Response: ${response.code}")
|
logger("Response: ${response.code}")
|
||||||
println("Response: ${response.message}")
|
logger("Response: ${response.message}")
|
||||||
|
|
||||||
// Convert the Response to an InputStream
|
// Convert the Response to an InputStream
|
||||||
val inputStream = response.body.byteStream()
|
val inputStream = response.body.byteStream()
|
||||||
|
@ -380,7 +381,7 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() {
|
||||||
return@withContext bitmap
|
return@withContext bitmap
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// Handle any exceptions
|
// Handle any exceptions
|
||||||
println("An error occurred: ${e.message}")
|
logger("An error occurred: ${e.message}")
|
||||||
return@withContext null
|
return@withContext null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,7 +414,7 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() {
|
||||||
inputStream.close()
|
inputStream.close()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// Handle any exceptions
|
// Handle any exceptions
|
||||||
println("An error occurred: ${e.message}")
|
logger("An error occurred: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,7 +461,7 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() {
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// Handle exception here
|
// Handle exception here
|
||||||
println("Exception while saving image: ${e.message}")
|
logger("Exception while saving image: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue