Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daily update #1154

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
override val availableSortOrders: Set<SortOrder> = EnumSet.of(
SortOrder.UPDATED,
SortOrder.POPULARITY,
SortOrder.ALPHABETICAL
SortOrder.ALPHABETICAL,
SortOrder.NEWEST,
SortOrder.RATING_ASC
)

override val filterCapabilities: MangaListFilterCapabilities
Expand Down Expand Up @@ -60,10 +62,12 @@
append("/")

when (order) {
SortOrder.UPDATED -> append("?sort=last_update")
SortOrder.UPDATED -> append("?sort=latest-updated")
SortOrder.POPULARITY -> append("?sort=views")
SortOrder.ALPHABETICAL -> append("?sort=name")
else -> append("?sort=last_update")
SortOrder.ALPHABETICAL -> append("?sort=az")
SortOrder.NEWEST -> append("?sort=new")
SortOrder.RATING_ASC -> append("?sort=score")
else -> append("?sort=default")
}

filter.tags.forEach { tag ->
Expand All @@ -74,8 +78,10 @@
if (filter.states.isNotEmpty()) {
append("&status=")
append(when (filter.states.first()) {
MangaState.ONGOING -> "ongoing"
MangaState.ONGOING -> "on-going"
MangaState.FINISHED -> "completed"
MangaState.PAUSED -> "on-hold"
MangaState.ABANDONED -> "canceled"
else -> "all"
})
}
Expand Down Expand Up @@ -119,16 +125,18 @@
it.equals("updating", true)
},
state = when (doc.selectFirst("div.y6x11p i.fas.fa-rss + span.dt")?.text()?.lowercase()) {
"ongoing", "đang tiến hành", "進行中" -> MangaState.ONGOING
"on-going", "đang tiến hành", "進行中" -> MangaState.ONGOING
"completed", "hoàn thành", "完了" -> MangaState.FINISHED
"on-hold", "tạm dừng", "一時停止" -> MangaState.PAUSED
"canceled", "đã huỷ bỏ", "キャンセル" -> MangaState.ABANDONED
else -> null
},
chapters = doc.select("ul > li.chapter").mapChapters { i, element ->
val href = element.selectFirstOrThrow("a").attrAsRelativeUrl("href")
MangaChapter(
id = generateUid(href),
name = element.selectFirst("a")?.text().orEmpty(),
number = i + 1f,
number = doc.select("ul > li.chapter").size - i.toFloat(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move doc.select("ul > li.chapter").size out of the loop

url = href,
scanlator = null,
uploadDate = element.selectFirst("time[datetime]")?.attr("datetime")?.toLongOrNull()?.times(1000) ?: 0L,
Expand All @@ -143,6 +151,7 @@
override suspend fun getPages(chapter: MangaChapter): List<MangaPage> {
val fullUrl = chapter.url.toAbsoluteUrl(domain)
val doc = webClient.httpGet(fullUrl).parseHtml()

val script = doc.selectFirst("script:containsData(const CHAPTER_ID)")?.data()
?: throw Exception("Failed to get chapter id")

Expand All @@ -164,8 +173,10 @@
val pageListHtml = responseJson.getString("html")
val pageListDoc = Jsoup.parse(pageListHtml)

return pageListDoc.select("div.separator[data-index]").mapIndexed { index, page ->
val url = page.selectFirstOrThrow("a").attr("abs:href")
return pageListDoc.select("div.iv-card").mapIndexed { index, div ->
val img = div.selectFirst("img")
val url = img?.attr("data-src") ?: img?.attr("src") ?: throw Exception("Failed to get image url")

MangaPage(
id = generateUid(url),
url = url,
Expand All @@ -188,6 +199,6 @@

override suspend fun getFilterOptions(): MangaListFilterOptions = MangaListFilterOptions(
availableTags = getAvailableTags(),
availableStates = setOf(MangaState.ONGOING, MangaState.FINISHED)
availableStates = setOf(MangaState.ONGOING, MangaState.FINISHED, MangaState.PAUSED, MangaState.ABANDONED)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import org.koitharu.kotatsu.parsers.network.UserAgents
import org.koitharu.kotatsu.parsers.util.*
import java.text.SimpleDateFormat
import java.util.*
import org.koitharu.kotatsu.parsers.Broken

@Broken
@MangaSourceParser("LXMANGA", "LxManga", "vi")
internal class LxManga(context: MangaLoaderContext) : PagedMangaParser(context, MangaParserSource.LXMANGA, 60) {

Expand Down
Loading