parent
b19c3b30c8
commit
ceb31dd4ec
|
@ -0,0 +1,13 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
ext {
|
||||
appName = 'Tachiyomi: ComX'
|
||||
pkgNameSuffix = 'ru.comx'
|
||||
extClass = '.ComX'
|
||||
extVersionCode = 0
|
||||
extVersionSuffix = 0
|
||||
libVersion = '1.0'
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
|
@ -0,0 +1,194 @@
|
|||
package eu.kanade.tachiyomi.extension.ru.comx
|
||||
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
|
||||
class ComX : ParsedHttpSource() {
|
||||
override val name = "Com-x"
|
||||
|
||||
override val baseUrl = "https://com-x.life"
|
||||
|
||||
override val lang = "ru"
|
||||
|
||||
override val supportsLatest = true
|
||||
|
||||
override fun popularMangaSelector() = "div.shortstory1"
|
||||
|
||||
override fun latestUpdatesSelector() = "ul.last-comix li"
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request =
|
||||
GET("$baseUrl/comix/page/$page/", headers)
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request =
|
||||
GET(baseUrl, headers)
|
||||
|
||||
override fun popularMangaFromElement(element: Element): SManga {
|
||||
val manga = SManga.create()
|
||||
manga.thumbnail_url = baseUrl + element.select("img").first().attr("src")
|
||||
element.select("a").first().let {
|
||||
manga.setUrlWithoutDomain(it.attr("href"))
|
||||
manga.title = it.text()
|
||||
}
|
||||
return manga
|
||||
}
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element): SManga {
|
||||
val manga = SManga.create()
|
||||
manga.thumbnail_url = baseUrl + element.select("img").first().attr("src")
|
||||
element.select("a.comix-last-title").first().let {
|
||||
manga.setUrlWithoutDomain(it.attr("href"))
|
||||
manga.title = it.text()
|
||||
}
|
||||
return manga
|
||||
}
|
||||
|
||||
|
||||
override fun popularMangaNextPageSelector() = "div.nextprev:last-child"
|
||||
|
||||
override fun latestUpdatesNextPageSelector(): Nothing? = null
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
return POST("$baseUrl/comix/",
|
||||
body = FormBody.Builder()
|
||||
.add("do", "search")
|
||||
.add("story", query)
|
||||
.add("subaction", "search")
|
||||
.build(),
|
||||
headers = headers
|
||||
)
|
||||
}
|
||||
|
||||
override fun searchMangaSelector() = popularMangaSelector()
|
||||
|
||||
override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element)
|
||||
|
||||
// max 200 results
|
||||
override fun searchMangaNextPageSelector(): Nothing? = null
|
||||
|
||||
override fun mangaDetailsParse(document: Document): SManga {
|
||||
val infoElement = document.select("div.maincont").first()
|
||||
|
||||
val manga = SManga.create()
|
||||
manga.author = infoElement.select("p:eq(2)").text().removePrefix("Издатель: ")
|
||||
manga.genre = infoElement.select("p:eq(3)").text()
|
||||
.removePrefix("Жанр: ")
|
||||
|
||||
manga.status = parseStatus(infoElement.select("p:eq(4)").text()
|
||||
.removePrefix("Статус: "))
|
||||
|
||||
val text = infoElement.select("*").text()
|
||||
if (!text.contains("Добавить описание на комикс")) {
|
||||
manga.description = text
|
||||
.removeRange(0, text.indexOf("Отслеживать"))
|
||||
.removeRange(text.indexOf("Читать комикс"), text.length)
|
||||
}
|
||||
|
||||
val src = infoElement.select("img").attr("src")
|
||||
if (src.contains(baseUrl)) {
|
||||
manga.thumbnail_url = src
|
||||
} else {
|
||||
manga.thumbnail_url = baseUrl + src
|
||||
}
|
||||
return manga
|
||||
}
|
||||
|
||||
private fun parseStatus(element: String): Int = when {
|
||||
element.contains("Продолжается") -> SManga.ONGOING
|
||||
element.contains("Завершён") ||
|
||||
element.contains("Лимитка") ||
|
||||
element.contains("Ван шот") ||
|
||||
element.contains("Графический роман") -> SManga.COMPLETED
|
||||
|
||||
else -> SManga.UNKNOWN
|
||||
}
|
||||
|
||||
override fun chapterListSelector() = "li[id^=cmx-]"
|
||||
|
||||
private fun chapterResponseParse(document: Document) : List<SChapter> {
|
||||
return document.select(chapterListSelector()).map { chapterFromElement(it) }
|
||||
}
|
||||
|
||||
private fun chapterPageListParse(document: Document) : List<String> {
|
||||
return document.select("span[class=\"\"]").map { it -> it.text() }
|
||||
}
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val document = response.asJsoup()
|
||||
val id = response.request().url().toString().removePrefix("$baseUrl/").split('-')[0]
|
||||
|
||||
val list = mutableListOf<SChapter>()
|
||||
list += chapterResponseParse(document)
|
||||
|
||||
val pages = chapterPageListParse(document).distinct()
|
||||
|
||||
for (page in pages) {
|
||||
val post = POST("$baseUrl/engine/mods/comix/listPages.php",
|
||||
body = FormBody.Builder()
|
||||
.add("newsid", id)
|
||||
.add("page", page)
|
||||
.build(),
|
||||
headers = headers)
|
||||
|
||||
list += chapterResponseParse(client.newCall(post).execute().asJsoup())
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
override fun chapterFromElement(element: Element): SChapter {
|
||||
val urlElement = element.select("a").first()
|
||||
val urlText = urlElement.text()
|
||||
val chapter = SChapter.create()
|
||||
chapter.name = urlText
|
||||
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
||||
chapter.date_upload = 0
|
||||
return chapter
|
||||
}
|
||||
|
||||
override fun pageListParse(response: Response): List<Page> {
|
||||
val html = response.body()!!.string()
|
||||
val beginTag = "comix_images=["
|
||||
val beginIndex = html.indexOf(beginTag)
|
||||
val endTag = "], comix_link='"
|
||||
val endIndex = html.indexOf(endTag, beginIndex)
|
||||
val comixIndex = html.indexOf("', page=", endIndex)
|
||||
|
||||
val link = html.substring(endIndex + endTag.length, comixIndex)
|
||||
val urls: List<String> = html.substring(beginIndex + beginTag.length, endIndex)
|
||||
.split(',')
|
||||
|
||||
|
||||
val pages = mutableListOf<Page>()
|
||||
for (i in 0 until urls.size) {
|
||||
pages.add(Page(i, "", link+(urls[i].removeSurrounding("'"))))
|
||||
}
|
||||
|
||||
return pages
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
throw Exception("Not used")
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document) = ""
|
||||
|
||||
override fun imageRequest(page: Page): Request {
|
||||
val imgHeader = Headers.Builder().apply {
|
||||
add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64)")
|
||||
add("Referer", baseUrl)
|
||||
}.build()
|
||||
return GET(page.imageUrl!!, imgHeader)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue