YugenMangas: Fix not showing new chapters (#17318)
* Use permUrl only if fetchAllTitles is true * Add extension setting * Move extension settings to Yugen * Set default to "true" so that users dont have to migrate * Import SwitchPreferenceCompact Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * Remove ChangeListener Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * Show toast --------- Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com>
This commit is contained in:
parent
66cd665b92
commit
920a2812df
|
@ -1,22 +1,38 @@
|
|||
package eu.kanade.tachiyomi.extension.es.yugenmangas
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import androidx.preference.PreferenceScreen
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
import eu.kanade.tachiyomi.multisrc.heancms.Genre
|
||||
import eu.kanade.tachiyomi.multisrc.heancms.HeanCms
|
||||
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.TimeZone
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class YugenMangas : HeanCms(
|
||||
class YugenMangas :
|
||||
HeanCms(
|
||||
"YugenMangas",
|
||||
"https://yugenmangas.net",
|
||||
"es",
|
||||
"https://api.yugenmangas.net",
|
||||
) {
|
||||
),
|
||||
ConfigurableSource {
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
// Site changed from Madara to HeanCms.
|
||||
override val versionId = 2
|
||||
|
||||
override val fetchAllTitles = getFetchAllSeriesPref()
|
||||
|
||||
override val client = super.client.newBuilder()
|
||||
.connectTimeout(60, TimeUnit.SECONDS)
|
||||
.readTimeout(90, TimeUnit.SECONDS)
|
||||
|
@ -29,6 +45,26 @@ class YugenMangas : HeanCms(
|
|||
timeZone = TimeZone.getTimeZone("UTC")
|
||||
}
|
||||
|
||||
private fun getFetchAllSeriesPref(): Boolean {
|
||||
return preferences.getBoolean(FETCH_ALL_SERIES_PREF, FETCH_ALL_SERIES_DEFAULT_VALUE)
|
||||
}
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
val fetchAllSeriesPreference = SwitchPreferenceCompat(screen.context).apply {
|
||||
key = FETCH_ALL_SERIES_PREF
|
||||
title = FETCH_ALL_SERIES_TITLE
|
||||
summary = FETCH_ALL_SERIES_SUMMARY
|
||||
setDefaultValue(FETCH_ALL_SERIES_DEFAULT_VALUE)
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
Toast.makeText(screen.context, "Reinicia la app para aplicar los cambios.", Toast.LENGTH_LONG).show()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
screen.addPreference(fetchAllSeriesPreference)
|
||||
}
|
||||
|
||||
override fun getGenreList(): List<Genre> = listOf(
|
||||
Genre("+18", 1),
|
||||
Genre("Acción", 36),
|
||||
|
@ -79,4 +115,14 @@ class YugenMangas : HeanCms(
|
|||
Genre("Yaoi", 43),
|
||||
Genre("Yuri", 44),
|
||||
)
|
||||
|
||||
companion object {
|
||||
private const val FETCH_ALL_SERIES_PREF = "fetchAllSeriesPref"
|
||||
private const val FETCH_ALL_SERIES_TITLE = "Buscar todas las series"
|
||||
private const val FETCH_ALL_SERIES_SUMMARY = "Busca las URLs actuales de las series. " +
|
||||
"Habilitar esta opción evita la necesidad de migrar, " +
|
||||
"pero puede llevar tiempo dependiendo del número total de series. \n" +
|
||||
"Tendrá que migrar cada vez que cambie esta opción."
|
||||
private const val FETCH_ALL_SERIES_DEFAULT_VALUE = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ abstract class HeanCms(
|
|||
|
||||
if (json.startsWith("{")) {
|
||||
val result = json.parseAs<HeanCmsQuerySearchDto>()
|
||||
val mangaList = result.data.map { it.toSManga(apiUrl, coverPath) }
|
||||
val mangaList = result.data.map { it.toSManga(apiUrl, coverPath, fetchAllTitles) }
|
||||
|
||||
fetchAllTitles()
|
||||
|
||||
|
@ -89,7 +89,7 @@ abstract class HeanCms(
|
|||
}
|
||||
|
||||
val mangaList = json.parseAs<List<HeanCmsSeriesDto>>()
|
||||
.map { it.toSManga(apiUrl, coverPath) }
|
||||
.map { it.toSManga(apiUrl, coverPath, fetchAllTitles) }
|
||||
|
||||
fetchAllTitles()
|
||||
|
||||
|
@ -179,14 +179,14 @@ abstract class HeanCms(
|
|||
val result = json.parseAs<List<HeanCmsSearchDto>>()
|
||||
val mangaList = result
|
||||
.filter { it.type == "Comic" }
|
||||
.map { it.toSManga(apiUrl, coverPath, seriesSlugMap.orEmpty()) }
|
||||
.map { it.toSManga(apiUrl, coverPath, seriesSlugMap.orEmpty(), fetchAllTitles) }
|
||||
|
||||
return MangasPage(mangaList, false)
|
||||
}
|
||||
|
||||
if (json.startsWith("{")) {
|
||||
val result = json.parseAs<HeanCmsQuerySearchDto>()
|
||||
val mangaList = result.data.map { it.toSManga(apiUrl, coverPath) }
|
||||
val mangaList = result.data.map { it.toSManga(apiUrl, coverPath, fetchAllTitles) }
|
||||
|
||||
fetchAllTitles()
|
||||
|
||||
|
@ -194,7 +194,7 @@ abstract class HeanCms(
|
|||
}
|
||||
|
||||
val mangaList = json.parseAs<List<HeanCmsSeriesDto>>()
|
||||
.map { it.toSManga(apiUrl, coverPath) }
|
||||
.map { it.toSManga(apiUrl, coverPath, fetchAllTitles) }
|
||||
|
||||
fetchAllTitles()
|
||||
|
||||
|
@ -206,7 +206,7 @@ abstract class HeanCms(
|
|||
.substringAfterLast("/")
|
||||
.replace(TIMESTAMP_REGEX, "")
|
||||
|
||||
val currentSlug = seriesSlugMap?.get(seriesSlug)?.slug ?: seriesSlug
|
||||
val currentSlug = seriesSlugMap?.get(seriesSlug)?.slug ?: manga.url.substringAfterLast("/")
|
||||
|
||||
return "$baseUrl/series/$currentSlug"
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ abstract class HeanCms(
|
|||
fetchAllTitles()
|
||||
|
||||
val seriesDetails = seriesSlugMap?.get(seriesSlug)
|
||||
val currentSlug = seriesDetails?.slug ?: seriesSlug
|
||||
val currentSlug = seriesDetails?.slug ?: manga.url.substringAfterLast("/")
|
||||
val currentStatus = seriesDetails?.status ?: manga.status
|
||||
|
||||
val apiHeaders = headersBuilder()
|
||||
|
@ -231,7 +231,7 @@ abstract class HeanCms(
|
|||
|
||||
override fun mangaDetailsParse(response: Response): SManga {
|
||||
val result = runCatching { response.parseAs<HeanCmsSeriesDto>() }
|
||||
val seriesDetails = result.getOrNull()?.toSManga(apiUrl, coverPath)
|
||||
val seriesDetails = result.getOrNull()?.toSManga(apiUrl, coverPath, fetchAllTitles)
|
||||
?: throw Exception(intl.urlChangedError(name))
|
||||
|
||||
return seriesDetails.apply {
|
||||
|
|
|
@ -36,14 +36,15 @@ data class HeanCmsSearchDto(
|
|||
apiUrl: String,
|
||||
coverPath: String,
|
||||
slugMap: Map<String, HeanCms.HeanCmsTitle>,
|
||||
usePermSlug: Boolean,
|
||||
): SManga = SManga.create().apply {
|
||||
val slugOnly = slug.replace(HeanCms.TIMESTAMP_REGEX, "")
|
||||
val thumbnailFileName = slugMap[slugOnly]?.thumbnailFileName
|
||||
val slug = if (!usePermSlug) slug else slug.replace(HeanCms.TIMESTAMP_REGEX, "")
|
||||
val thumbnailFileName = slugMap[slug]?.thumbnailFileName
|
||||
|
||||
title = this@HeanCmsSearchDto.title
|
||||
thumbnail_url = thumbnail?.toAbsoluteThumbnailUrl(apiUrl, coverPath)
|
||||
?: thumbnailFileName?.toAbsoluteThumbnailUrl(apiUrl, coverPath)
|
||||
url = "/series/$slugOnly"
|
||||
url = "/series/$slug"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,8 +63,9 @@ data class HeanCmsSeriesDto(
|
|||
val chapters: List<HeanCmsChapterDto>? = emptyList(),
|
||||
) {
|
||||
|
||||
fun toSManga(apiUrl: String, coverPath: String): SManga = SManga.create().apply {
|
||||
fun toSManga(apiUrl: String, coverPath: String, usePermSlug: Boolean): SManga = SManga.create().apply {
|
||||
val descriptionBody = this@HeanCmsSeriesDto.description?.let(Jsoup::parseBodyFragment)
|
||||
val slug = if (!usePermSlug) slug else slug.replace(HeanCms.TIMESTAMP_REGEX, "")
|
||||
|
||||
title = this@HeanCmsSeriesDto.title
|
||||
author = this@HeanCmsSeriesDto.author?.trim()
|
||||
|
@ -77,7 +79,7 @@ data class HeanCmsSeriesDto(
|
|||
thumbnail_url = thumbnail.ifEmpty { null }
|
||||
?.toAbsoluteThumbnailUrl(apiUrl, coverPath)
|
||||
status = this@HeanCmsSeriesDto.status?.toStatus() ?: SManga.UNKNOWN
|
||||
url = "/series/${slug.replace(HeanCms.TIMESTAMP_REGEX, "")}"
|
||||
url = "/series/$slug"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class HeanCmsGenerator : ThemeSourceGenerator {
|
|||
|
||||
override val themeClass = "HeanCms"
|
||||
|
||||
override val baseVersionCode: Int = 13
|
||||
override val baseVersionCode: Int = 14
|
||||
|
||||
override val sources = listOf(
|
||||
SingleLang("Glorious Scan", "https://gloriousscan.com", "pt-BR", overrideVersionCode = 17),
|
||||
|
|
Loading…
Reference in New Issue