MangaLib changes (#1607)
* MangaLib: Fixed status parsing, added the image server selecting in extension config, deleted "Factory" class(useless(?)), changed the name of extension * Revert the name change
This commit is contained in:
parent
3ecce8dd18
commit
07da5693d0
@ -2,10 +2,10 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
ext {
|
||||
appName = 'Tachiyomi: LibManga'
|
||||
appName = 'Tachiyomi: MangaLib'
|
||||
pkgNameSuffix = 'ru.libmanga'
|
||||
extClass = '.LibMangaFactory'
|
||||
extVersionCode = 6
|
||||
extClass = '.LibManga'
|
||||
extVersionCode = 7
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,36 @@
|
||||
package eu.kanade.tachiyomi.extension.ru.libmanga
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v7.preference.ListPreference
|
||||
import android.support.v7.preference.PreferenceScreen
|
||||
import com.github.salomonbrys.kotson.*
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonParser
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.model.*
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.*
|
||||
import org.jsoup.nodes.Element
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import android.util.Base64.decode as base64Decode
|
||||
|
||||
|
||||
open class LibManga(override val name: String, override val baseUrl: String, private val staticUrl: String) : HttpSource() {
|
||||
class LibManga : ConfigurableSource, HttpSource() {
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
override val name: String = "Mangalib"
|
||||
|
||||
override val lang = "ru"
|
||||
|
||||
@ -25,8 +38,38 @@ open class LibManga(override val name: String, override val baseUrl: String, pri
|
||||
|
||||
override val client: OkHttpClient = network.cloudflareClient
|
||||
|
||||
override val baseUrl: String = "https://mangalib.me"
|
||||
|
||||
private var imageServerUrl: String = when(preferences.getString(SERVER_PREF, "main")){
|
||||
"main" -> "https://img2.mangalib.me"
|
||||
else -> "https://img3.mangalib.me"
|
||||
}
|
||||
|
||||
private val jsonParser = JsonParser()
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
val serverPref = ListPreference(screen.context).apply {
|
||||
key = SERVER_PREF
|
||||
title = SERVER_PREF_Title
|
||||
entries = arrayOf("Основной", "Второй")
|
||||
entryValues = arrayOf("main", "alt")
|
||||
summary = "%s"
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
imageServerUrl = when(newValue){
|
||||
"main" -> "https://img2.mangalib.me"
|
||||
else -> "https://img3.mangalib.me"
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
if(!preferences.contains(SERVER_PREF))
|
||||
preferences.edit().putString(SERVER_PREF, "main").apply()
|
||||
|
||||
screen.addPreference(serverPref)
|
||||
}
|
||||
|
||||
override fun latestUpdatesRequest(page: Int) = GET(baseUrl, headers)
|
||||
|
||||
private val latestUpdatesSelector = "div.updates__left"
|
||||
@ -116,7 +159,7 @@ open class LibManga(override val name: String, override val baseUrl: String, pri
|
||||
manga.status = when (
|
||||
body.select(".info-list__row:has(strong:contains(Перевод))")
|
||||
.first()
|
||||
.select("span.m-label_info")
|
||||
.select("span.m-label")
|
||||
.text())
|
||||
{
|
||||
"продолжается" -> SManga.ONGOING
|
||||
@ -177,7 +220,7 @@ open class LibManga(override val name: String, override val baseUrl: String, pri
|
||||
|
||||
val pages = mutableListOf<Page>()
|
||||
pagesJson.forEach { page ->
|
||||
pages.add(Page(page["p"].int, "", staticUrl + chapInfoJson["imgUrl"].string + page["u"].string))
|
||||
pages.add(Page(page["p"].int, "", imageServerUrl + chapInfoJson["imgUrl"].string + page["u"].string))
|
||||
}
|
||||
|
||||
return pages
|
||||
@ -349,4 +392,9 @@ open class LibManga(override val name: String, override val baseUrl: String, pri
|
||||
SearchFilter("юри", "73"),
|
||||
SearchFilter("яой", "74")
|
||||
)
|
||||
|
||||
companion object {
|
||||
private const val SERVER_PREF_Title = "Сервер изображений"
|
||||
private const val SERVER_PREF = "imageServer"
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package eu.kanade.tachiyomi.extension.ru.libmanga
|
||||
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
|
||||
class LibMangaFactory : SourceFactory {
|
||||
override fun createSources(): List<Source> = getAllLibManga()
|
||||
}
|
||||
|
||||
fun getAllLibManga(): List<Source> {
|
||||
return listOf(
|
||||
Mangalib()
|
||||
)
|
||||
}
|
||||
|
||||
class Mangalib : LibManga("Mangalib", "https://mangalib.me", "https://img3.mangalib.me")
|
Loading…
x
Reference in New Issue
Block a user