From 3a811582b06fb3c27d53da6a0523bfc84a7e6a83 Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Mon, 16 Sep 2024 05:22:27 -0500 Subject: [PATCH] Fix FoyScans (#5081) * fix * fix override on EternalMangas --- .../tachiyomi/multisrc/mangaesp/MangaEsp.kt | 16 ++++++++++------ .../tachiyomi/multisrc/mangaesp/MangaEspDto.kt | 8 ++++---- .../extension/all/eternalmangas/EternalMangas.kt | 4 ++-- src/es/foyscan/build.gradle | 2 +- .../tachiyomi/extension/es/foyscan/FoyScan.kt | 13 ++++++++++++- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/lib-multisrc/mangaesp/src/eu/kanade/tachiyomi/multisrc/mangaesp/MangaEsp.kt b/lib-multisrc/mangaesp/src/eu/kanade/tachiyomi/multisrc/mangaesp/MangaEsp.kt index afdb15678..2cea58bb1 100644 --- a/lib-multisrc/mangaesp/src/eu/kanade/tachiyomi/multisrc/mangaesp/MangaEsp.kt +++ b/lib-multisrc/mangaesp/src/eu/kanade/tachiyomi/multisrc/mangaesp/MangaEsp.kt @@ -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(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(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(unescapedJson) - return series.chapters.map { it.toSChapter(series.slug) } + return series.chapters.map { it.toSChapter(seriesPath, series.slug) } } override fun pageListParse(response: Response): List { diff --git a/lib-multisrc/mangaesp/src/eu/kanade/tachiyomi/multisrc/mangaesp/MangaEspDto.kt b/lib-multisrc/mangaesp/src/eu/kanade/tachiyomi/multisrc/mangaesp/MangaEspDto.kt index a844ed863..4764d5350 100644 --- a/lib-multisrc/mangaesp/src/eu/kanade/tachiyomi/multisrc/mangaesp/MangaEspDto.kt +++ b/lib-multisrc/mangaesp/src/eu/kanade/tachiyomi/multisrc/mangaesp/MangaEspDto.kt @@ -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" } } diff --git a/src/all/eternalmangas/src/eu/kanade/tachiyomi/extension/all/eternalmangas/EternalMangas.kt b/src/all/eternalmangas/src/eu/kanade/tachiyomi/extension/all/eternalmangas/EternalMangas.kt index 5d433267a..64734ad2a 100644 --- a/src/all/eternalmangas/src/eu/kanade/tachiyomi/extension/all/eternalmangas/EternalMangas.kt +++ b/src/all/eternalmangas/src/eu/kanade/tachiyomi/extension/all/eternalmangas/EternalMangas.kt @@ -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(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) } diff --git a/src/es/foyscan/build.gradle b/src/es/foyscan/build.gradle index 1f7fac513..1b2078d3d 100644 --- a/src/es/foyscan/build.gradle +++ b/src/es/foyscan/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.FoyScan' themePkg = 'mangaesp' baseUrl = 'https://foyscan.xyz' - overrideVersionCode = 0 + overrideVersionCode = 1 } apply from: "$rootDir/common.gradle" diff --git a/src/es/foyscan/src/eu/kanade/tachiyomi/extension/es/foyscan/FoyScan.kt b/src/es/foyscan/src/eu/kanade/tachiyomi/extension/es/foyscan/FoyScan.kt index f0eed4de6..08b055ef9 100644 --- a/src/es/foyscan/src/eu/kanade/tachiyomi/extension/es/foyscan/FoyScan.kt +++ b/src/es/foyscan/src/eu/kanade/tachiyomi/extension/es/foyscan/FoyScan.kt @@ -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" +}