[RU]LibManga, ComX. Limit connect and fixes selectors. (#9482)
* [RU]LibManga, ComX. Limit connect and fixes selectors. * ONGOING?
This commit is contained in:
parent
403cfa3c06
commit
6c721039ff
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'ComX'
|
extName = 'ComX'
|
||||||
pkgNameSuffix = 'ru.comx'
|
pkgNameSuffix = 'ru.comx'
|
||||||
extClass = '.ComX'
|
extClass = '.ComX'
|
||||||
extVersionCode = 8
|
extVersionCode = 9
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -19,6 +19,10 @@ import okhttp3.Request
|
|||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class ComX : ParsedHttpSource() {
|
class ComX : ParsedHttpSource() {
|
||||||
override val name = "Com-x"
|
override val name = "Com-x"
|
||||||
@ -32,7 +36,9 @@ class ComX : ParsedHttpSource() {
|
|||||||
private val userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0"
|
private val userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0"
|
||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||||
.addNetworkInterceptor(RateLimitInterceptor(2))
|
.connectTimeout(10, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.addNetworkInterceptor(RateLimitInterceptor(3))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
||||||
@ -132,14 +138,11 @@ class ComX : ParsedHttpSource() {
|
|||||||
val infoElement = document.select("div.maincont").first()
|
val infoElement = document.select("div.maincont").first()
|
||||||
|
|
||||||
val manga = SManga.create()
|
val manga = SManga.create()
|
||||||
manga.author = infoElement.select("p:eq(2)").text().removePrefix("Издатель: ")
|
manga.author = infoElement.select(".fullstory__infoSection:eq(1) > .fullstory__infoSectionContent").text()
|
||||||
manga.genre = infoElement.select("p:eq(3)").text()
|
manga.genre = infoElement.select(".fullstory__infoSection:eq(2) > .fullstory__infoSectionContent").text()
|
||||||
.removePrefix("Жанр: ").split(",").plusElement("Комикс").joinToString { it.trim() }
|
.split(",").plusElement("Комикс").joinToString { it.trim() }
|
||||||
|
|
||||||
manga.status = parseStatus(
|
manga.status = parseStatus(infoElement.select(".fullstory__infoSection:eq(3) > .fullstory__infoSectionContent").text())
|
||||||
infoElement.select("p:eq(4)").text()
|
|
||||||
.removePrefix("Статус: ")
|
|
||||||
)
|
|
||||||
|
|
||||||
val text = infoElement.select("*").text()
|
val text = infoElement.select("*").text()
|
||||||
if (!text.contains("Добавить описание на комикс")) {
|
if (!text.contains("Добавить описание на комикс")) {
|
||||||
@ -159,8 +162,9 @@ class ComX : ParsedHttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun parseStatus(element: String): Int = when {
|
private fun parseStatus(element: String): Int = when {
|
||||||
element.contains("Продолжается") -> SManga.ONGOING
|
element.contains("Продолжается") ||
|
||||||
element.contains("Завершён") ||
|
element.contains(" из ") -> SManga.ONGOING
|
||||||
|
element.contains("Заверш") ||
|
||||||
element.contains("Лимитка") ||
|
element.contains("Лимитка") ||
|
||||||
element.contains("Ван шот") ||
|
element.contains("Ван шот") ||
|
||||||
element.contains("Графический роман") -> SManga.COMPLETED
|
element.contains("Графический роман") -> SManga.COMPLETED
|
||||||
@ -202,14 +206,22 @@ class ComX : ParsedHttpSource() {
|
|||||||
|
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
private val simpleDateFormat by lazy { SimpleDateFormat("dd.MM.yyyy", Locale.US) }
|
||||||
|
private fun parseDate(date: String?): Long {
|
||||||
|
date ?: return 0L
|
||||||
|
return try {
|
||||||
|
simpleDateFormat.parse(date)!!.time
|
||||||
|
} catch (_: Exception) {
|
||||||
|
Date().time
|
||||||
|
}
|
||||||
|
}
|
||||||
override fun chapterFromElement(element: Element): SChapter {
|
override fun chapterFromElement(element: Element): SChapter {
|
||||||
val urlElement = element.select("a").first()
|
val urlElement = element.select("a").first()
|
||||||
val urlText = urlElement.text()
|
val urlText = urlElement.text()
|
||||||
val chapter = SChapter.create()
|
val chapter = SChapter.create()
|
||||||
chapter.name = urlText.split('/')[0] // Remove english part of name
|
chapter.name = urlText.split('/')[0] // Remove english part of name
|
||||||
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
||||||
chapter.date_upload = 0
|
chapter.date_upload = parseDate(element.select("span:eq(2)").text())
|
||||||
return chapter
|
return chapter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,11 @@ ext {
|
|||||||
extName = 'MangaLib'
|
extName = 'MangaLib'
|
||||||
pkgNameSuffix = 'ru.libmanga'
|
pkgNameSuffix = 'ru.libmanga'
|
||||||
extClass = '.LibManga'
|
extClass = '.LibManga'
|
||||||
extVersionCode = 55
|
extVersionCode = 56
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(path: ':lib-ratelimit')
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
@ -17,6 +17,7 @@ import com.github.salomonbrys.kotson.toMap
|
|||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
import com.google.gson.JsonElement
|
import com.google.gson.JsonElement
|
||||||
import com.google.gson.JsonParser
|
import com.google.gson.JsonParser
|
||||||
|
import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
@ -57,6 +58,7 @@ class LibManga : ConfigurableSource, HttpSource() {
|
|||||||
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
|
||||||
.connectTimeout(10, TimeUnit.SECONDS)
|
.connectTimeout(10, TimeUnit.SECONDS)
|
||||||
.readTimeout(30, TimeUnit.SECONDS)
|
.readTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.addNetworkInterceptor(RateLimitInterceptor(3))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private val baseOrig: String = "https://mangalib.me"
|
private val baseOrig: String = "https://mangalib.me"
|
||||||
@ -189,7 +191,7 @@ class LibManga : ConfigurableSource, HttpSource() {
|
|||||||
}
|
}
|
||||||
val genres = document.select(".media-tags > a").map { it.text().capitalize() }
|
val genres = document.select(".media-tags > a").map { it.text().capitalize() }
|
||||||
manga.title = document.select(".media-name__alt").text()
|
manga.title = document.select(".media-name__alt").text()
|
||||||
manga.thumbnail_url = document.select(".media-sidebar__cover > img").attr("src").substringAfter(baseOrig)
|
manga.thumbnail_url = document.select(".media-sidebar__cover > img").attr("src")
|
||||||
manga.author = body.select("div.media-info-list__title:contains(Автор) + div").text()
|
manga.author = body.select("div.media-info-list__title:contains(Автор) + div").text()
|
||||||
manga.artist = body.select("div.media-info-list__title:contains(Художник) + div").text()
|
manga.artist = body.select("div.media-info-list__title:contains(Художник) + div").text()
|
||||||
manga.status = if (document.html().contains("Манга удалена по просьбе правообладателей") ||
|
manga.status = if (document.html().contains("Манга удалена по просьбе правообладателей") ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user