diff --git a/src/ru/comx/build.gradle b/src/ru/comx/build.gradle index ecc09bdd4..b33b0b323 100644 --- a/src/ru/comx/build.gradle +++ b/src/ru/comx/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'ComX' pkgNameSuffix = 'ru.comx' extClass = '.ComX' - extVersionCode = 8 + extVersionCode = 9 } dependencies { diff --git a/src/ru/comx/src/eu/kanade/tachiyomi/extension/ru/comx/ComX.kt b/src/ru/comx/src/eu/kanade/tachiyomi/extension/ru/comx/ComX.kt index d967faba9..81e8ebb38 100644 --- a/src/ru/comx/src/eu/kanade/tachiyomi/extension/ru/comx/ComX.kt +++ b/src/ru/comx/src/eu/kanade/tachiyomi/extension/ru/comx/ComX.kt @@ -19,6 +19,10 @@ import okhttp3.Request import okhttp3.Response import org.jsoup.nodes.Document 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() { 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" override val client: OkHttpClient = network.cloudflareClient.newBuilder() - .addNetworkInterceptor(RateLimitInterceptor(2)) + .connectTimeout(10, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .addNetworkInterceptor(RateLimitInterceptor(3)) .build() override fun headersBuilder(): Headers.Builder = Headers.Builder() @@ -132,14 +138,11 @@ class ComX : ParsedHttpSource() { 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("Жанр: ").split(",").plusElement("Комикс").joinToString { it.trim() } + manga.author = infoElement.select(".fullstory__infoSection:eq(1) > .fullstory__infoSectionContent").text() + manga.genre = infoElement.select(".fullstory__infoSection:eq(2) > .fullstory__infoSectionContent").text() + .split(",").plusElement("Комикс").joinToString { it.trim() } - manga.status = parseStatus( - infoElement.select("p:eq(4)").text() - .removePrefix("Статус: ") - ) + manga.status = parseStatus(infoElement.select(".fullstory__infoSection:eq(3) > .fullstory__infoSectionContent").text()) val text = infoElement.select("*").text() if (!text.contains("Добавить описание на комикс")) { @@ -159,8 +162,9 @@ class ComX : ParsedHttpSource() { } 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("Графический роман") -> SManga.COMPLETED @@ -202,14 +206,22 @@ class ComX : ParsedHttpSource() { 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 { val urlElement = element.select("a").first() val urlText = urlElement.text() val chapter = SChapter.create() chapter.name = urlText.split('/')[0] // Remove english part of name chapter.setUrlWithoutDomain(urlElement.attr("href")) - chapter.date_upload = 0 + chapter.date_upload = parseDate(element.select("span:eq(2)").text()) return chapter } diff --git a/src/ru/libmanga/build.gradle b/src/ru/libmanga/build.gradle index 1a0c7f5ea..b48ca4018 100644 --- a/src/ru/libmanga/build.gradle +++ b/src/ru/libmanga/build.gradle @@ -5,7 +5,11 @@ ext { extName = 'MangaLib' pkgNameSuffix = 'ru.libmanga' extClass = '.LibManga' - extVersionCode = 55 + extVersionCode = 56 +} + +dependencies { + implementation project(path: ':lib-ratelimit') } apply from: "$rootDir/common.gradle" diff --git a/src/ru/libmanga/src/eu/kanade/tachiyomi/extension/ru/libmanga/LibManga.kt b/src/ru/libmanga/src/eu/kanade/tachiyomi/extension/ru/libmanga/LibManga.kt index 855798235..584b66651 100644 --- a/src/ru/libmanga/src/eu/kanade/tachiyomi/extension/ru/libmanga/LibManga.kt +++ b/src/ru/libmanga/src/eu/kanade/tachiyomi/extension/ru/libmanga/LibManga.kt @@ -17,6 +17,7 @@ import com.github.salomonbrys.kotson.toMap import com.google.gson.JsonArray import com.google.gson.JsonElement import com.google.gson.JsonParser +import eu.kanade.tachiyomi.lib.ratelimit.RateLimitInterceptor import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.asObservableSuccess @@ -57,6 +58,7 @@ class LibManga : ConfigurableSource, HttpSource() { override val client: OkHttpClient = network.cloudflareClient.newBuilder() .connectTimeout(10, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) + .addNetworkInterceptor(RateLimitInterceptor(3)) .build() 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() } 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.artist = body.select("div.media-info-list__title:contains(Художник) + div").text() manga.status = if (document.html().contains("Манга удалена по просьбе правообладателей") ||