Update Maid Manga and Pecinta Komik (#1556)

Update Maid Manga and Pecinta Komik
This commit is contained in:
Rama Bondan Prakoso 2019-09-24 18:45:31 +07:00 committed by arkon
parent 209eaa9f1c
commit e4c9fca405
4 changed files with 49 additions and 25 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Maid - Manga' appName = 'Tachiyomi: Maid - Manga'
pkgNameSuffix = 'id.maidmanga' pkgNameSuffix = 'id.maidmanga'
extClass = '.MaidManga' extClass = '.MaidManga'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -3,12 +3,15 @@ package eu.kanade.tachiyomi.extension.id.maidmanga
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.HttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.HttpUrl import okhttp3.Response
import org.json.JSONObject
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.lang.StringBuilder import java.text.SimpleDateFormat
class MaidManga : ParsedHttpSource() { class MaidManga : ParsedHttpSource() {
@ -26,7 +29,7 @@ class MaidManga : ParsedHttpSource() {
override fun latestUpdatesRequest(page: Int): Request { override fun latestUpdatesRequest(page: Int): Request {
// The site redirects page 1 -> url-without-page so we do this redirect early for optimization // The site redirects page 1 -> url-without-page so we do this redirect early for optimization
val builtUrl = if(page == 1) "${baseUrl}" else "${baseUrl}/page/$page/" val builtUrl = if(page == 1) baseUrl else "$baseUrl/page/$page/"
return GET(builtUrl) return GET(builtUrl)
} }
@ -43,7 +46,7 @@ class MaidManga : ParsedHttpSource() {
override fun latestUpdatesNextPageSelector() = "a:containsOwn(Berikutnya)" override fun latestUpdatesNextPageSelector() = "a:containsOwn(Berikutnya)"
override fun popularMangaRequest(page: Int): Request { override fun popularMangaRequest(page: Int): Request {
val builtUrl = if(page == 1) "${baseUrl}/advanced-search/?order=popular" else "${baseUrl}/advanced-search/page/$page/?order=popular" val builtUrl = if(page == 1) "$baseUrl/advanced-search/?order=popular" else "$baseUrl/advanced-search/page/$page/?order=popular"
return GET(builtUrl) return GET(builtUrl)
} }
@ -61,7 +64,7 @@ class MaidManga : ParsedHttpSource() {
override fun popularMangaNextPageSelector() = latestUpdatesNextPageSelector() override fun popularMangaNextPageSelector() = latestUpdatesNextPageSelector()
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val builtUrl = if(page == 1) "${baseUrl}/advanced-search/" else "${baseUrl}/advanced-search/page/$page/" val builtUrl = if(page == 1) "$baseUrl/advanced-search/" else "$baseUrl/advanced-search/page/$page/"
val url = HttpUrl.parse(builtUrl)!!.newBuilder() val url = HttpUrl.parse(builtUrl)!!.newBuilder()
url.addQueryParameter("title", query) url.addQueryParameter("title", query)
url.addQueryParameter("page", page.toString()) url.addQueryParameter("page", page.toString())
@ -124,11 +127,14 @@ class MaidManga : ParsedHttpSource() {
} }
if (desc.size > 0) { if (desc.size > 0) {
desc.forEach { desc.forEach {
stringBuilder.append(cleanDesc(it.text())) stringBuilder.append(it.text())
if (it != desc.last()) if (it != desc.last())
stringBuilder.append("\n\n") stringBuilder.append("\n\n")
} }
} manga.description = stringBuilder.toString()
} else
manga.description = document.select("div.sinopsis").text()
manga.title = infoElement.select("h1").text() manga.title = infoElement.select("h1").text()
manga.author = author manga.author = author
manga.artist = author manga.artist = author
@ -153,6 +159,24 @@ class MaidManga : ParsedHttpSource() {
return super.chapterListRequest(manga) return super.chapterListRequest(manga)
} }
override fun chapterListParse(response: Response): List<SChapter> {
val document = response.asJsoup()
val chapters = mutableListOf<SChapter>()
document.select(chapterListSelector()).map { chapters.add(chapterFromElement(it)) }
// Add date for latest chapter only
document.select("script.yoast-schema-graph").html()
.let {
val date = JSONObject(it).getJSONArray("@graph").
getJSONObject(3).getString("dateModified")
chapters[0].date_upload = parseDate(date)
}
return chapters
}
private fun parseDate(date: String): Long {
return SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX").parse(date).time
}
override fun chapterListSelector() = "ul#chapter_list li a:contains(chapter)" override fun chapterListSelector() = "ul#chapter_list li a:contains(chapter)"
override fun chapterFromElement(element: Element): SChapter { override fun chapterFromElement(element: Element): SChapter {
@ -174,9 +198,7 @@ class MaidManga : ParsedHttpSource() {
val pages = mutableListOf<Page>() val pages = mutableListOf<Page>()
document.select("div#readerarea img").forEach { document.select("div#readerarea img").forEach {
val url = it.attr("src") val url = it.attr("src")
if (url != "") { pages.add(Page(pages.size, "", url))
pages.add(Page(pages.size, "", url))
}
} }
return pages return pages
} }
@ -284,6 +306,4 @@ class MaidManga : ParsedHttpSource() {
private class Tag(val id: String, name: String) : Filter.TriState(name) private class Tag(val id: String, name: String) : Filter.TriState(name)
private class GenreList(genres: List<Tag>) : Filter.Group<Tag>("Genres", genres) private class GenreList(genres: List<Tag>) : Filter.Group<Tag>("Genres", genres)
}
private fun cleanDesc(desc: String): String = desc.replace(Regex("\\(.*\\)"), "").trim()
}

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Pecinta Komik' appName = 'Tachiyomi: Pecinta Komik'
pkgNameSuffix = 'id.pecintakomik' pkgNameSuffix = 'id.pecintakomik'
extClass = '.PecintaKomik' extClass = '.PecintaKomik'
extVersionCode = 1 extVersionCode = 2
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -30,7 +30,7 @@ class PecintaKomik : ParsedHttpSource() {
return GET(builtUrl) return GET(builtUrl)
} }
override fun latestUpdatesSelector() = "div.listthumbx:eq(2) li" override fun latestUpdatesSelector() = ".releases:contains(update) + .listthumbx li"
override fun latestUpdatesFromElement(element: Element): SManga { override fun latestUpdatesFromElement(element: Element): SManga {
val manga = SManga.create() val manga = SManga.create()
@ -178,18 +178,22 @@ class PecintaKomik : ParsedHttpSource() {
val chapter = SChapter.create() val chapter = SChapter.create()
chapter.url = urlElement.attr("href") chapter.url = urlElement.attr("href")
chapter.name = urlElement.text() chapter.name = urlElement.text()
chapter.date_upload = element.select("span.dt").text().let { chapter.date_upload = element.select("span.dt").text()?.let {
SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH).parse(it chapterParseDate(it)
.replace("Mei", "May") } ?: 0
.replace("Agu", "Aug")
.replace("Okt", "Oct")
.replace("Nop", "Nov")
.replace("Des", "Dec")
).time
}
return chapter return chapter
} }
private fun chapterParseDate(date: String): Long {
return SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH).parse(date
.replace("Mei", "May")
.replace("Agu", "Aug")
.replace("Okt", "Oct")
.replace("Nop", "Nov")
.replace("Des", "Dec")
).time
}
override fun pageListRequest(chapter: SChapter): Request { override fun pageListRequest(chapter: SChapter): Request {
if (chapter.url.startsWith("http")) { if (chapter.url.startsWith("http")) {
return GET(chapter.url, headers) return GET(chapter.url, headers)