[RU] Mangalib. Fixed getting chapters(1+ translators) (#5517)

* [RU] Mangalib. Minor changes in SharedPreferences

* [RU] Mangalib. Fix getting chapters(1+ translators)

* [RU] Mangalib. Replacing Russian names with original ones

* [RU] Mangalib. Revert version update
This commit is contained in:
Blue cat 2021-01-23 18:07:49 +03:00 committed by GitHub
parent 23bb281e95
commit 23d2e65aa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 54 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'MangaLib' extName = 'MangaLib'
pkgNameSuffix = 'ru.libmanga' pkgNameSuffix = 'ru.libmanga'
extClass = '.LibManga' extClass = '.LibManga'
extVersionCode = 28 extVersionCode = 29
libVersion = '1.2' libVersion = '1.2'
} }

View File

@ -2,8 +2,8 @@ package eu.kanade.tachiyomi.extension.ru.libmanga
import android.app.Application import android.app.Application
import android.content.SharedPreferences import android.content.SharedPreferences
import android.support.v7.preference.ListPreference import androidx.preference.ListPreference
import android.support.v7.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import com.github.salomonbrys.kotson.array import com.github.salomonbrys.kotson.array
import com.github.salomonbrys.kotson.get import com.github.salomonbrys.kotson.get
import com.github.salomonbrys.kotson.int import com.github.salomonbrys.kotson.int
@ -36,6 +36,8 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
import android.support.v7.preference.ListPreference as LegacyListPreference
import android.support.v7.preference.PreferenceScreen as LegacyPreferenceScreen
class LibManga : ConfigurableSource, HttpSource() { class LibManga : ConfigurableSource, HttpSource() {
@ -61,42 +63,6 @@ class LibManga : ConfigurableSource, HttpSource() {
private val jsonParser = JsonParser() private val jsonParser = JsonParser()
private var server: String? = preferences.getString(SERVER_PREF, null)
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
val serverPref = androidx.preference.ListPreference(screen.context).apply {
key = SERVER_PREF
title = SERVER_PREF_Title
entries = arrayOf("Основной", "Второй (тестовый)", "Третий (эконом трафика)")
entryValues = arrayOf("secondary", "fourth", "compress")
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
server = newValue.toString()
true
}
}
screen.addPreference(serverPref)
}
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val serverPref = ListPreference(screen.context).apply {
key = SERVER_PREF
title = SERVER_PREF_Title
entries = arrayOf("Основной", "Второй (тестовый)", "Третий (эконом трафика)")
entryValues = arrayOf("secondary", "fourth", "compress")
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
server = newValue.toString()
true
}
}
screen.addPreference(serverPref)
}
override fun latestUpdatesRequest(page: Int) = GET(baseUrl, headers) override fun latestUpdatesRequest(page: Int) = GET(baseUrl, headers)
private val latestUpdatesSelector = "div.updates__item" private val latestUpdatesSelector = "div.updates__item"
@ -198,7 +164,7 @@ class LibManga : ConfigurableSource, HttpSource() {
val genres = document.select(".media-tags > a").map { it.text() } val genres = document.select(".media-tags > a").map { it.text() }
manga.title = document.select(".media-name__main").text() manga.title = document.select(".media-name__alt").text()
manga.thumbnail_url = document.select(".media-sidebar__cover > img").attr("src") 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()
@ -227,26 +193,17 @@ class LibManga : ConfigurableSource, HttpSource() {
val data = jsonParser.parse(dataStr).obj val data = jsonParser.parse(dataStr).obj
val chaptersList = data["chapters"]["list"].nullArray val chaptersList = data["chapters"]["list"].nullArray
val slug = data["manga"]["slug"].string 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) { return chaptersList?.map { chapterFromElement(it, slug) } ?: emptyList()
chaptersList?.map { chapterFromElement(it, slug) }
} else {
chaptersList?.filter { it["branch_id"].int == teamId }?.map { chapterFromElement(it, slug, teamId) }
}
return chapters ?: emptyList()
} }
private fun chapterFromElement(chapterItem: JsonElement, slug: String, teamIdParam: Int? = null): SChapter { private fun chapterFromElement(chapterItem: JsonElement, slug: String): SChapter {
val chapter = SChapter.create() val chapter = SChapter.create()
val volume = chapterItem["chapter_volume"].int val volume = chapterItem["chapter_volume"].int
val number = chapterItem["chapter_number"].string val number = chapterItem["chapter_number"].string
val teamId = if (teamIdParam != null) "?bid=$teamIdParam" else ""
val url = "$baseUrl/$slug/v$volume/c$number$teamId" val url = "$baseUrl/$slug/v$volume/c$number"
chapter.setUrlWithoutDomain(url) chapter.setUrlWithoutDomain(url)
@ -501,8 +458,44 @@ class LibManga : ConfigurableSource, HttpSource() {
) )
companion object { companion object {
private const val SERVER_PREF_Title = "Сервер изображений"
private const val SERVER_PREF = "MangaLibImageServer"
const val PREFIX_SLUG_SEARCH = "slug:" const val PREFIX_SLUG_SEARCH = "slug:"
private const val SERVER_PREF = "MangaLibImageServer"
private const val SERVER_PREF_Title = "Сервер изображений"
}
private var server: String? = preferences.getString(SERVER_PREF, null)
override fun setupPreferenceScreen(screen: PreferenceScreen) {
val serverPref = ListPreference(screen.context).apply {
key = SERVER_PREF
title = SERVER_PREF_Title
entries = arrayOf("Основной", "Второй (тестовый)", "Третий (эконом трафика)")
entryValues = arrayOf("secondary", "fourth", "compress")
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
server = newValue.toString()
true
}
}
screen.addPreference(serverPref)
}
override fun setupPreferenceScreen(screen: LegacyPreferenceScreen) {
val serverPref = LegacyListPreference(screen.context).apply {
key = SERVER_PREF
title = SERVER_PREF_Title
entries = arrayOf("Основной", "Второй (тестовый)", "Третий (эконом трафика)")
entryValues = arrayOf("secondary", "fourth", "compress")
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
server = newValue.toString()
true
}
}
screen.addPreference(serverPref)
} }
} }