diff --git a/multisrc/overrides/mangareader/mangafire/src/MangaFire.kt b/multisrc/overrides/mangareader/mangafire/src/MangaFire.kt index 5459e630f..262ded34c 100644 --- a/multisrc/overrides/mangareader/mangafire/src/MangaFire.kt +++ b/multisrc/overrides/mangareader/mangafire/src/MangaFire.kt @@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.util.asJsoup import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json @@ -20,6 +21,8 @@ import org.jsoup.nodes.Document import org.jsoup.nodes.Element import org.jsoup.select.Evaluator import uy.kohesive.injekt.injectLazy +import java.text.SimpleDateFormat +import java.util.Locale open class MangaFire( override val lang: String, @@ -31,7 +34,7 @@ open class MangaFire( private val json: Json by injectLazy() - override val client = network.client.newBuilder() + override val client = network.cloudflareClient.newBuilder() .addInterceptor(ImageInterceptor) .build() @@ -140,6 +143,26 @@ open class MangaFire( return container.children().map { it.child(0) } } + override fun updateChapterList(manga: SManga, chapters: List) { + val document = client.newCall(mangaDetailsRequest(manga)).execute().asJsoup() + val elements = document.selectFirst(".chapter-list[data-name=$langCode]")!!.children() + val chapterCount = chapters.size + if (elements.size != chapterCount) throw Exception("Chapter count doesn't match. Try updating again.") + val dateFormat = SimpleDateFormat("MMM dd, yyyy", Locale.US) + for (i in 0 until chapterCount) { + val chapter = chapters[i] + val element = elements[i] + val number = element.attr("data-number").toFloatOrNull() ?: -1f + if (chapter.chapter_number != number) throw Exception("Chapter number doesn't match. Try updating again.") + val date = element.select(Evaluator.Tag("span"))[1].ownText() + chapter.date_upload = try { + dateFormat.parse(date)!!.time + } catch (_: Throwable) { + 0 + } + } + } + override fun pageListRequest(chapter: SChapter): Request { val typeAndId = chapter.url.substringAfterLast('#') return GET("$baseUrl/ajax/read/$typeAndId", headers) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangareader/MangaReader.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangareader/MangaReader.kt index 1008ac308..8cc3831c0 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangareader/MangaReader.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangareader/MangaReader.kt @@ -71,6 +71,8 @@ abstract class MangaReader : HttpSource(), ConfigurableSource { override fun chapterListParse(response: Response) = throw UnsupportedOperationException() + open fun updateChapterList(manga: SManga, chapters: List) = Unit + final override fun fetchChapterList(manga: SManga): Observable> = Observable.fromCallable { val path = manga.url val isVolume = path.endsWith(VOLUME_URL_SUFFIX) @@ -96,7 +98,7 @@ abstract class MangaReader : HttpSource(), ConfigurableSource { } setUrlWithoutDomain(link.attr("href") + '#' + type + '/' + element.attr("data-id")) } - } + }.also { if (!isVolume && it.isNotEmpty()) updateChapterList(manga, it) } } final override fun getChapterUrl(chapter: SChapter) = baseUrl + chapter.url.substringBeforeLast('#') diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangareader/MangaReaderGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangareader/MangaReaderGenerator.kt index 2f200b9fd..63bcb401f 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangareader/MangaReaderGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangareader/MangaReaderGenerator.kt @@ -21,6 +21,7 @@ class MangaReaderGenerator : ThemeSourceGenerator { baseUrl = "https://mangafire.to", langs = listOf("en", "es", "es-419", "fr", "ja", "pt", "pt-BR"), isNsfw = true, + overrideVersionCode = 1, ), )