parent
288c35f951
commit
6a703ead9b
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: MangaCards (Valhalla, NANI?)'
|
||||
pkgNameSuffix = 'all.mangacards'
|
||||
extClass = '.MangaCardsFactory'
|
||||
extVersionCode = 5
|
||||
extVersionCode = 6
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import okhttp3.Request
|
|||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import java.lang.Exception
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -31,7 +32,7 @@ abstract class MangaCards(
|
|||
// Popular
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
return GET("$baseUrl/projects")
|
||||
return GET("$baseUrl/projects", headers)
|
||||
}
|
||||
|
||||
override fun popularMangaSelector() = "div.col-sm-4"
|
||||
|
@ -46,32 +47,20 @@ abstract class MangaCards(
|
|||
return manga
|
||||
}
|
||||
|
||||
override fun popularMangaNextPageSelector() = "No next page"
|
||||
override fun popularMangaNextPageSelector(): String? = null
|
||||
|
||||
// Latest
|
||||
|
||||
// Track which manga titles have been added to latestUpdates's MangasPage
|
||||
private val latestUpdatesTitles = mutableSetOf<String>()
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request {
|
||||
if (page == 1) latestUpdatesTitles.clear()
|
||||
return GET(baseUrl)
|
||||
return GET(baseUrl, headers)
|
||||
}
|
||||
|
||||
// Only add manga to MangasPage if its title is not one we've added already
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
val latestManga = mutableListOf<SManga>()
|
||||
val document = response.asJsoup()
|
||||
val mangas = response.asJsoup().select(latestUpdatesSelector())
|
||||
.distinctBy { it.select("div.pt-0 a").text() }
|
||||
.map { latestUpdatesFromElement(it) }
|
||||
|
||||
document.select(latestUpdatesSelector()).forEach { element ->
|
||||
latestUpdatesFromElement(element).let { manga ->
|
||||
if (manga.title !in latestUpdatesTitles) {
|
||||
latestManga.add(manga)
|
||||
latestUpdatesTitles.add(manga.title)
|
||||
}
|
||||
}
|
||||
}
|
||||
return MangasPage(latestManga, document.select(latestUpdatesNextPageSelector()).hasText())
|
||||
return MangasPage(mangas, false)
|
||||
}
|
||||
|
||||
override fun latestUpdatesSelector() = "div.col-sm-6"
|
||||
|
@ -86,25 +75,24 @@ abstract class MangaCards(
|
|||
return manga
|
||||
}
|
||||
|
||||
override fun latestUpdatesNextPageSelector() = "No next page"
|
||||
override fun latestUpdatesNextPageSelector(): String? = null
|
||||
|
||||
// Search
|
||||
|
||||
/* Source websites aren't able to search their whole catalog at once, instead we'd have to
|
||||
do separate searches for ongoing, hiatus, dropped, and completed and then combine those results.
|
||||
Since their catalogs are small, it seems easier to do the search client-side */
|
||||
private var searchQuery = ""
|
||||
private lateinit var searchQuery: String
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
searchQuery = query.toLowerCase()
|
||||
searchQuery = query
|
||||
return popularMangaRequest(1)
|
||||
}
|
||||
|
||||
override fun searchMangaParse(response: Response): MangasPage {
|
||||
val searchMatches = mutableListOf<SManga>()
|
||||
response.asJsoup().select(searchMangaSelector())
|
||||
.filter { it.text().toLowerCase().contains(searchQuery) }
|
||||
.map { searchMatches.add(searchMangaFromElement(it)) }
|
||||
val searchMatches = response.asJsoup().select(searchMangaSelector())
|
||||
.filter { it.text().contains(searchQuery, ignoreCase = true) }
|
||||
.map { searchMangaFromElement(it) }
|
||||
|
||||
return MangasPage(searchMatches, false)
|
||||
}
|
||||
|
@ -113,7 +101,7 @@ abstract class MangaCards(
|
|||
|
||||
override fun searchMangaFromElement(element: Element) = popularMangaFromElement(element)
|
||||
|
||||
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
||||
override fun searchMangaNextPageSelector(): String? = null
|
||||
|
||||
// Manga details
|
||||
|
||||
|
@ -151,7 +139,11 @@ abstract class MangaCards(
|
|||
}
|
||||
|
||||
private fun parseDate(date: String): Long {
|
||||
return SimpleDateFormat("dd/MM/yyyy", Locale.US).parse(date).time
|
||||
return try {
|
||||
SimpleDateFormat("dd/MM/yyyy", Locale.US).parse(date).time
|
||||
} catch (e: Exception) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
override fun pageListRequest(chapter: SChapter): Request {
|
||||
|
@ -162,12 +154,9 @@ abstract class MangaCards(
|
|||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val pages = mutableListOf<Page>()
|
||||
|
||||
document.select("div#pages img").forEachIndexed { i, element ->
|
||||
pages.add(Page(i, "", element.attr("abs:src")))
|
||||
return document.select("div#pages img").mapIndexed { i, element ->
|
||||
Page(i, "", element.attr("abs:src"))
|
||||
}
|
||||
return pages
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used")
|
||||
|
|
Loading…
Reference in New Issue