MMRCMS - fewer dupes in latest (#2639)

This commit is contained in:
Mike 2020-04-11 05:19:13 -04:00 committed by GitHub
parent 4f8fe13829
commit c5a090fab2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: My Manga Reader CMS (Many sources)'
pkgNameSuffix = 'all.mmrcms'
extClass = '.MyMangaReaderCMSSources'
extVersionCode = 34
extVersionCode = 35
libVersion = '1.2'
}

View File

@ -80,18 +80,19 @@ class MyMangaReaderCMSSource(override val lang: String,
}
}
private val latestTitles = mutableSetOf<String>()
override fun latestUpdatesParse(response: Response): MangasPage {
val document = response.asJsoup()
val mangas = document.select(latestUpdatesSelector()).map { element ->
latestUpdatesFromElement(element)
}.distinctBy { manga -> manga.url }
if (document.location().contains("page=1")) latestTitles.clear()
val hasNextPage = latestUpdatesNextPageSelector()?.let { selector ->
document.select(selector).first()
} != null
val mangas = document.select(latestUpdatesSelector()).map { element -> latestUpdatesFromElement(element) }
.distinctBy { manga -> manga.title }
.filterNot { manga -> manga.title in latestTitles }
.also { list -> latestTitles.addAll(list.map { it.title }) }
return MangasPage(mangas, hasNextPage)
return MangasPage(mangas, document.select(latestUpdatesNextPageSelector()) != null)
}
private fun latestUpdatesSelector() = "div.mangalist div.manga-item"
private fun latestUpdatesNextPageSelector() = "a[rel=next]"
@ -165,7 +166,7 @@ class MyMangaReaderCMSSource(override val lang: String,
@SuppressLint("DefaultLocale")
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
val document = response.asJsoup()
title = document.select("h2.listmanga-header, h2.widget-title").first().text().trim()
document.select("h2.listmanga-header, h2.widget-title").firstOrNull()?.text()?.trim()?.let { title = it }
thumbnail_url = coverGuess(document.select(".row [class^=img-responsive]").firstOrNull()?.attr("abs:src"), document.location())
description = document.select(".row .well p").text().trim()