Fix FoyScans (#5081)

* fix

* fix override on EternalMangas
This commit is contained in:
bapeey 2024-09-16 05:22:27 -05:00 committed by GitHub
parent a115c794cf
commit b908f79794
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 14 deletions

View File

@ -42,6 +42,10 @@ abstract class MangaEsp(
classLoader = this::class.java.classLoader!!,
)
protected open val apiPath = "/api"
protected open val seriesPath = "/ver"
override val client: OkHttpClient = network.client.newBuilder()
.rateLimitHost(baseUrl.toHttpUrl(), 2)
.build()
@ -49,7 +53,7 @@ abstract class MangaEsp(
override fun headersBuilder(): Headers.Builder = Headers.Builder()
.add("Referer", "$baseUrl/")
override fun popularMangaRequest(page: Int): Request = GET("$apiBaseUrl/api/topSerie", headers)
override fun popularMangaRequest(page: Int): Request = GET("$apiBaseUrl$apiPath/topSerie", headers)
override fun popularMangaParse(response: Response): MangasPage {
val responseData = json.decodeFromString<TopSeriesDto>(response.body.string())
@ -58,17 +62,17 @@ abstract class MangaEsp(
val topWeekly = responseData.response.topWeekly.flatten().map { it.data }
val topMonthly = responseData.response.topMonthly.flatten().map { it.data }
val mangas = (topDaily + topWeekly + topMonthly).distinctBy { it.slug }.map { it.toSManga() }
val mangas = (topDaily + topWeekly + topMonthly).distinctBy { it.slug }.map { it.toSManga(seriesPath) }
return MangasPage(mangas, false)
}
override fun latestUpdatesRequest(page: Int): Request = GET("$apiBaseUrl/api/lastUpdates", headers)
override fun latestUpdatesRequest(page: Int): Request = GET("$apiBaseUrl$apiPath/lastUpdates", headers)
override fun latestUpdatesParse(response: Response): MangasPage {
val responseData = json.decodeFromString<LastUpdatesDto>(response.body.string())
val mangas = responseData.response.map { it.toSManga() }
val mangas = responseData.response.map { it.toSManga(seriesPath) }
return MangasPage(mangas, false)
}
@ -151,7 +155,7 @@ abstract class MangaEsp(
return MangasPage(
filteredList.subList((page - 1) * MANGAS_PER_PAGE, min(page * MANGAS_PER_PAGE, filteredList.size))
.map { it.toSManga() },
.map { it.toSManga(seriesPath) },
hasNextPage,
)
}
@ -171,7 +175,7 @@ abstract class MangaEsp(
?: throw Exception(intl["comic_data_error"])
val unescapedJson = mangaDetailsJson.unescape()
val series = json.decodeFromString<SeriesDto>(unescapedJson)
return series.chapters.map { it.toSChapter(series.slug) }
return series.chapters.map { it.toSChapter(seriesPath, series.slug) }
}
override fun pageListParse(response: Response): List<Page> {

View File

@ -48,11 +48,11 @@ class SeriesDto(
@SerialName("idioma")
val language: String? = null,
) {
fun toSManga(): SManga {
fun toSManga(seriesPath: String): SManga {
return SManga.create().apply {
title = name
thumbnail_url = thumbnail
url = "/ver/$slug"
url = "$seriesPath/$slug"
}
}
@ -104,7 +104,7 @@ class ChapterDto(
private val slug: String,
@SerialName("created_at") private val date: String,
) {
fun toSChapter(seriesSlug: String): SChapter {
fun toSChapter(seriesPath: String, seriesSlug: String): SChapter {
return SChapter.create().apply {
name = "Capítulo ${number.toString().removeSuffix(".0")}"
if (!this@ChapterDto.name.isNullOrBlank()) {
@ -115,7 +115,7 @@ class ChapterDto(
} catch (e: Exception) {
0L
}
url = "/ver/$seriesSlug/$slug"
url = "$seriesPath/$seriesSlug/$slug"
}
}

View File

@ -32,14 +32,14 @@ open class EternalMangas(
val mangas = (topDaily + topWeekly + topMonthly).distinctBy { it.slug }
.filter { it.language == internalLang }
.map { it.toSManga() }
.map { it.toSManga(seriesPath) }
return MangasPage(mangas, false)
}
override fun latestUpdatesParse(response: Response): MangasPage {
val responseData = json.decodeFromString<LatestUpdatesDto>(response.body.string())
val mangas = responseData.updates[internalLang]?.flatten()?.map { it.toSManga() } ?: emptyList()
val mangas = responseData.updates[internalLang]?.flatten()?.map { it.toSManga(seriesPath) } ?: emptyList()
return MangasPage(mangas, false)
}

View File

@ -3,7 +3,7 @@ ext {
extClass = '.FoyScan'
themePkg = 'mangaesp'
baseUrl = 'https://foyscan.xyz'
overrideVersionCode = 0
overrideVersionCode = 1
}
apply from: "$rootDir/common.gradle"

View File

@ -2,4 +2,15 @@ package eu.kanade.tachiyomi.extension.es.foyscan
import eu.kanade.tachiyomi.multisrc.mangaesp.MangaEsp
class FoyScan : MangaEsp("Foy Scan", "https://foyscan.xyz", "es")
class FoyScan : MangaEsp(
"Foy Scan",
"https://foyscan.xyz",
"es",
"https://foyscan.xyz",
) {
// Series path changes from /ver to /serie
override val versionId = 2
override val apiPath = "/apiv1"
override val seriesPath = "/serie"
}