From d11cfb8114a6e15e7df783edaa5c2854977774c7 Mon Sep 17 00:00:00 2001 From: e-shl <35057681+e-shl@users.noreply.github.com> Date: Mon, 31 Jan 2022 17:12:40 +0500 Subject: [PATCH] [RU]Libmanga fix "changing cover language" (#10612) * [RU]Libmanga fix "changing cover language" * +[RU]Libhentai --- src/ru/libhentai/build.gradle | 2 +- .../tachiyomi/extension/ru/libhentai/LibHentai.kt | 13 ++++++------- .../tachiyomi/extension/ru/libmanga/LibManga.kt | 13 ++++++------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/ru/libhentai/build.gradle b/src/ru/libhentai/build.gradle index 7469d3b1b..fcec8cc30 100644 --- a/src/ru/libhentai/build.gradle +++ b/src/ru/libhentai/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'HentaiLib' pkgNameSuffix = 'ru.libhentai' extClass = '.LibHentai' - extVersionCode = 2 + extVersionCode = 3 isNsfw = true } diff --git a/src/ru/libhentai/src/eu/kanade/tachiyomi/extension/ru/libhentai/LibHentai.kt b/src/ru/libhentai/src/eu/kanade/tachiyomi/extension/ru/libhentai/LibHentai.kt index 0c199dc55..bda44f920 100644 --- a/src/ru/libhentai/src/eu/kanade/tachiyomi/extension/ru/libhentai/LibHentai.kt +++ b/src/ru/libhentai/src/eu/kanade/tachiyomi/extension/ru/libhentai/LibHentai.kt @@ -91,7 +91,7 @@ class LibHentai : ConfigurableSource, HttpSource() { element.select("a").first().let { link -> manga.setUrlWithoutDomain(link.attr("href")) - manga.title = if (titleLanguage.equals("rus") || element.select(".updates__name_rus").isNullOrEmpty()) { element.select("h4").first().text() } else element.select(".updates__name_rus").first().text() + manga.title = if (preferences.getString(LANGUAGE_PREF, "rus").equals("rus") || element.select(".updates__name_rus").isNullOrEmpty()) { element.select("h4").first().text() } else element.select(".updates__name_rus").first().text() } return manga } @@ -146,7 +146,7 @@ class LibHentai : ConfigurableSource, HttpSource() { private fun popularMangaFromElement(el: JsonElement) = SManga.create().apply { val slug = el.jsonObject["slug"]!!.jsonPrimitive.content val cover = el.jsonObject["cover"]!!.jsonPrimitive.content - title = if (titleLanguage.equals("rus")) el.jsonObject["rus_name"]!!.jsonPrimitive.content else el.jsonObject["name"]!!.jsonPrimitive.content + title = if (preferences.getString(LANGUAGE_PREF, "rus").equals("rus")) el.jsonObject["rus_name"]!!.jsonPrimitive.content else el.jsonObject["name"]!!.jsonPrimitive.content thumbnail_url = "$COVER_URL/huploads/cover/$slug/cover/${cover}_250x350.jpg" url = "/$slug" } @@ -187,7 +187,7 @@ class LibHentai : ConfigurableSource, HttpSource() { else -> "☆☆☆☆☆" } val genres = document.select(".media-tags > a").map { it.text().capitalize() } - manga.title = if (titleLanguage.equals("rus")) document.select(".media-name__main").text() else document.select(".media-name__alt").text() + manga.title = if (preferences.getString(LANGUAGE_PREF, "rus").equals("rus")) document.select(".media-name__main").text() else document.select(".media-name__alt").text() 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() @@ -211,7 +211,7 @@ class LibHentai : ConfigurableSource, HttpSource() { if (altSelector.isNotEmpty()) { altName = "Альтернативные названия:\n" + altSelector.map { it.text() }.joinToString(" / ") + "\n\n" } - val mediaNameLanguage = if (titleLanguage.equals("rus")) document.select(".media-name__alt").text() else document.select(".media-name__main").text() + val mediaNameLanguage = if (preferences.getString(LANGUAGE_PREF, "rus").equals("rus")) document.select(".media-name__alt").text() else document.select(".media-name__main").text() manga.description = mediaNameLanguage + "\n" + ratingStar + " " + ratingValue + " (голосов: " + ratingVotes + ")\n" + altName + document.select(".media-description__text").text() return manga } @@ -851,7 +851,6 @@ class LibHentai : ConfigurableSource, HttpSource() { } private var server: String? = preferences.getString(SERVER_PREF, null) - private var titleLanguage: String? = preferences.getString(LANGUAGE_PREF, null) override fun setupPreferenceScreen(screen: PreferenceScreen) { val serverPref = ListPreference(screen.context).apply { key = SERVER_PREF @@ -889,10 +888,10 @@ class LibHentai : ConfigurableSource, HttpSource() { summary = "%s" setDefaultValue("eng") setOnPreferenceChangeListener { _, newValue -> - titleLanguage = newValue.toString() + val titleLanguage = preferences.edit().putString(LANGUAGE_PREF, newValue as String).commit() val warning = "Если язык обложки не изменился очистите базу данных в приложении (Настройки -> Дополнительно -> Очистить базу данных)" Toast.makeText(screen.context, warning, Toast.LENGTH_LONG).show() - true + titleLanguage } } screen.addPreference(serverPref) 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 b408912e9..66ab39df4 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 @@ -93,7 +93,7 @@ class LibManga : ConfigurableSource, HttpSource() { element.select("a").first().let { link -> manga.setUrlWithoutDomain(link.attr("href")) - manga.title = if (titleLanguage.equals("rus") || element.select(".updates__name_rus").isNullOrEmpty()) { element.select("h4").first().text() } else element.select(".updates__name_rus").first().text() + manga.title = if (preferences.getString(LANGUAGE_PREF, "rus").equals("rus") || element.select(".updates__name_rus").isNullOrEmpty()) { element.select("h4").first().text() } else element.select(".updates__name_rus").first().text() } return manga } @@ -148,7 +148,7 @@ class LibManga : ConfigurableSource, HttpSource() { private fun popularMangaFromElement(el: JsonElement) = SManga.create().apply { val slug = el.jsonObject["slug"]!!.jsonPrimitive.content val cover = el.jsonObject["cover"]!!.jsonPrimitive.content - title = if (titleLanguage.equals("rus")) el.jsonObject["rus_name"]!!.jsonPrimitive.content else el.jsonObject["name"]!!.jsonPrimitive.content + title = if (preferences.getString(LANGUAGE_PREF, "rus").equals("rus")) el.jsonObject["rus_name"]!!.jsonPrimitive.content else el.jsonObject["name"]!!.jsonPrimitive.content thumbnail_url = "$COVER_URL/uploads/cover/$slug/cover/${cover}_250x350.jpg" url = "/$slug" } @@ -189,7 +189,7 @@ class LibManga : ConfigurableSource, HttpSource() { else -> "☆☆☆☆☆" } val genres = document.select(".media-tags > a").map { it.text().capitalize() } - manga.title = if (titleLanguage.equals("rus")) document.select(".media-name__main").text() else document.select(".media-name__alt").text() + manga.title = if (preferences.getString(LANGUAGE_PREF, "rus").equals("rus")) document.select(".media-name__main").text() else document.select(".media-name__alt").text() 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() @@ -213,7 +213,7 @@ class LibManga : ConfigurableSource, HttpSource() { if (altSelector.isNotEmpty()) { altName = "Альтернативные названия:\n" + altSelector.map { it.text() }.joinToString(" / ") + "\n\n" } - val mediaNameLanguage = if (titleLanguage.equals("rus")) document.select(".media-name__alt").text() else document.select(".media-name__main").text() + val mediaNameLanguage = if (preferences.getString(LANGUAGE_PREF, "rus").equals("rus")) document.select(".media-name__alt").text() else document.select(".media-name__main").text() manga.description = mediaNameLanguage + "\n" + ratingStar + " " + ratingValue + " (голосов: " + ratingVotes + ")\n" + altName + document.select(".media-description__text").text() return manga } @@ -801,7 +801,6 @@ class LibManga : ConfigurableSource, HttpSource() { } private var server: String? = preferences.getString(SERVER_PREF, null) - private var titleLanguage: String? = preferences.getString(LANGUAGE_PREF, null) override fun setupPreferenceScreen(screen: PreferenceScreen) { val serverPref = ListPreference(screen.context).apply { key = SERVER_PREF @@ -858,10 +857,10 @@ class LibManga : ConfigurableSource, HttpSource() { summary = "%s" setDefaultValue("eng") setOnPreferenceChangeListener { _, newValue -> - titleLanguage = newValue.toString() + val titleLanguage = preferences.edit().putString(LANGUAGE_PREF, newValue as String).commit() val warning = "Если язык обложки не изменился очистите базу данных в приложении (Настройки -> Дополнительно -> Очистить базу данных)" Toast.makeText(screen.context, warning, Toast.LENGTH_LONG).show() - true + titleLanguage } }