TeamX fix search and chapter listing of greater than 100 (#14827)

* Use alternative search, get all chapters when paged

* bump version
This commit is contained in:
Carlos 2023-01-06 09:47:07 -05:00 committed by GitHub
parent cb1b9aa683
commit 5c4123a582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 18 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Team X' extName = 'Team X'
pkgNameSuffix = 'ar.teamx' pkgNameSuffix = 'ar.teamx'
extClass = '.TeamX' extClass = '.TeamX'
extVersionCode = 10 extVersionCode = 11
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -99,17 +99,22 @@ class TeamX : ParsedHttpSource() {
// Search // Search
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
if (page == 1) titlesAdded.clear() return GET("$baseUrl/ajax/search?keyword=$query", headers)
return GET("$baseUrl/series" + "?search=$query" + (if (page > 1) "&page=$page" else ""), headers)
} }
override fun searchMangaParse(response: Response): MangasPage = popularMangaParse(response) override fun searchMangaSelector() = "li.list-group-item"
override fun searchMangaSelector() = popularMangaSelector() override fun searchMangaFromElement(element: Element): SManga {
return SManga.create().apply {
val urlAndText = element.select("div.ms-2 a")
title = urlAndText.text()
setUrlWithoutDomain(urlAndText.first().absUrl("href"))
thumbnail_url = element.select("a img").first().absUrl("src")
}
}
override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element) // doesnt matter as there is no next page
override fun searchMangaNextPageSelector(): String? = null
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
// Details // Details
@ -126,31 +131,33 @@ class TeamX : ParsedHttpSource() {
} }
// Chapters // Chapters
private fun chapterNextPageSelector() = "span.nextx_text a:contains(»)" private fun chapterNextPageSelector() = popularMangaNextPageSelector()
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> {
val allChapters = mutableListOf<SChapter>() val allElements = mutableListOf<Element>()
var document = response.asJsoup() var document = response.asJsoup()
while (true) { while (true) {
val pageChapters = document.select(chapterListSelector()).map { chapterFromElement(it) } val pageChapters = document.select(chapterListSelector())
if (pageChapters.isEmpty()) if (pageChapters.isEmpty())
break break
allChapters += pageChapters allElements += pageChapters
val hasNextPage = document.select(chapterNextPageSelector()).isNotEmpty() val hasNextPage = document.select(chapterNextPageSelector()).isNotEmpty()
if (!hasNextPage) if (!hasNextPage) {
break break
}
val nextUrl = document.select(chapterNextPageSelector()).attr("href") val nextUrl = document.select(chapterNextPageSelector()).attr("href")
document = client.newCall(GET(nextUrl, headers)).execute().asJsoup() document = client.newCall(GET(nextUrl, headers)).execute().asJsoup()
} }
return allChapters return allElements.map { chapterFromElement(it) }
} }
val chapterFormat = SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()) private val chapterFormat = SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault())
override fun chapterListSelector() = "div.eplister ul a" override fun chapterListSelector() = "div.eplister ul a"
@ -171,7 +178,6 @@ class TeamX : ParsedHttpSource() {
} }
} }
private fun parseChapterDate(date: String): Long { private fun parseChapterDate(date: String): Long {
return kotlin.runCatching { return kotlin.runCatching {
chapterFormat.parse(date)?.time chapterFormat.parse(date)?.time
@ -187,6 +193,4 @@ class TeamX : ParsedHttpSource() {
} }
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used") override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
} }