diff --git a/src/ru/libmanga/build.gradle b/src/ru/libmanga/build.gradle index eb4abc035..45fe09459 100644 --- a/src/ru/libmanga/build.gradle +++ b/src/ru/libmanga/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'MangaLib' pkgNameSuffix = 'ru.libmanga' extClass = '.LibManga' - extVersionCode = 26 + extVersionCode = 27 libVersion = '1.2' } 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 0517252c0..9d1d064f4 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 @@ -63,14 +63,6 @@ class LibManga : ConfigurableSource, HttpSource() { private var server: String? = preferences.getString(SERVER_PREF, null) - private val defaultServer = "https://img2.emanga.ru" - - private val servers = mapOf( - "secondary" to "https://img2.emanga.ru", - "fourth" to "https://img4.imgslib.ru", - "compress" to "https://img3.yaoilib.org", - ) - override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) { val serverPref = androidx.preference.ListPreference(screen.context).apply { key = SERVER_PREF @@ -105,10 +97,6 @@ class LibManga : ConfigurableSource, HttpSource() { screen.addPreference(serverPref) } - private fun imageServerUrl(): String { - return this.servers.getOrDefault(this.server, this.defaultServer) - } - override fun latestUpdatesRequest(page: Int) = GET(baseUrl, headers) private val latestUpdatesSelector = "div.updates__item" @@ -199,23 +187,23 @@ class LibManga : ConfigurableSource, HttpSource() { return manga } - val body = document.select("div.section__body").first() - val rawCategory = body.select(".info-list__row:has(strong:contains(Тип)) > span").text() + val body = document.select("div.media-info-list").first() + val rawCategory = body.select("div.media-info-list__title:contains(Тип) + div").text() + val category = when { rawCategory == "Комикс западный" -> "комикс" rawCategory.isNotBlank() -> rawCategory.toLowerCase() else -> "манга" } - val genres = body.select(".info-list__row:has(strong:contains(Жанры)) > a").map { it.text() } - manga.title = document.select(".manga-title small").text().substringBefore("/").trim() - manga.thumbnail_url = body.select(".manga__cover").attr("src") - manga.author = body.select(".info-list__row:nth-child(2) > a").text() - manga.artist = body.select(".info-list__row:nth-child(3) > a").text() + val genres = document.select(".media-tags > a").map { it.text() } + + manga.title = document.select(".media-name__main").text() + manga.thumbnail_url = "${baseUrl}${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 = when ( - body.select(".info-list__row:has(strong:contains(перевод))") - .first() - .select("span") + body.select("div.media-info-list__title:contains(Статус перевода) + div") .text() .toLowerCase() ) { @@ -224,40 +212,49 @@ class LibManga : ConfigurableSource, HttpSource() { else -> SManga.UNKNOWN } manga.genre = genres.plusElement(category).joinToString { it.trim() } - manga.description = body.select(".info-desc__content").text() + manga.description = document.select(".media-description__text").text() return manga } - private val chapterListSelector = "div.chapter-item" - override fun chapterListParse(response: Response): List { - val elements = response.asJsoup().select(chapterListSelector) - val chapters = elements?.map { chapterFromElement(it) } + val dataStr = response + .asJsoup() + .toString() + .substringAfter("window.__DATA__ = ") + .substringBefore(";") + + val data = jsonParser.parse(dataStr).obj + val chaptersList = data["chapters"]["list"].nullArray + val slug = data["manga"]["slug"].string + val teams = data["chapters"]["branches"].array + val teamId = if (teams.size() > 0) teams[0]["id"].int else null + + val chapters = if (teamId == null) { + chaptersList?.map { chapterFromElement(it, slug) } + } else { + chaptersList?.filter { it["branch_id"].int == teamId }?.map { chapterFromElement(it, slug, teamId) } + } + return chapters ?: emptyList() } - private fun chapterFromElement(element: Element): SChapter { - + private fun chapterFromElement(chapterItem: JsonElement, slug: String, teamIdParam: Int? = null): SChapter { val chapter = SChapter.create() - val chapterLink = element.select("div.chapter-item__name > a").first() - if (chapterLink != null) { - chapter.setUrlWithoutDomain(chapterLink.attr("href")) - } else { - // Found multiple translate. Get first one for now - val volume = element.attr("data-volume") - val number = element.attr("data-number") - val teams = jsonParser.parse(element.attr("data-teams")) - val team = teams[0]["slug"].nullString - val baseUrl = "${element.baseUri()}/v$volume/c$number" - val url = if (team != null) "$baseUrl/$team" else baseUrl + val volume = chapterItem["chapter_volume"].int + val number = chapterItem["chapter_number"].string + val teamId = if (teamIdParam != null) "?bid=$teamIdParam" else "" - chapter.setUrlWithoutDomain(url) - } + val url = "$baseUrl/$slug/v$volume/c$number$teamId" - chapter.name = element.select("div.chapter-item__name").first().text() - chapter.date_upload = SimpleDateFormat("dd.MM.yyyy", Locale.US) - .parse(element.select("div.chapter-item__date").text())?.time ?: 0L + chapter.setUrlWithoutDomain(url) + + val nameChapter = chapterItem["chapter_name"].nullString + val fullNameChapter = "Том $volume. Глава $number" + + chapter.name = if (nameChapter.isNullOrBlank()) fullNameChapter else "$fullNameChapter - $nameChapter" + chapter.date_upload = SimpleDateFormat("yyyy-MM-dd", Locale.US) + .parse(chapterItem["chapter_created_at"].string.substringBefore(" "))?.time ?: 0L return chapter }