mirror of
https://github.com/keiyoushi/extensions-source.git
synced 2024-11-22 02:12:42 +01:00
Use Liste of Mirrors Urls for Mangalek "ar" (#2059)
* Use Liste of Mirrors Urls for Mangalek "ar" * Update Mangalek.kt * override baseUrl * Update Mangalek.kt * add isNsfw Co-authored-by: Vetle Ledaal <vetle.ledaal@gmail.com> * date format --------- Co-authored-by: Vetle Ledaal <vetle.ledaal@gmail.com>
This commit is contained in:
parent
8969e43e0f
commit
a80db51115
@ -3,7 +3,8 @@ ext {
|
||||
extClass = '.Mangalek'
|
||||
themePkg = 'madara'
|
||||
baseUrl = 'https://lekmanga.net'
|
||||
overrideVersionCode = 5
|
||||
overrideVersionCode = 6
|
||||
isNsfw = false
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
@ -3,8 +3,8 @@ package eu.kanade.tachiyomi.extension.ar.mangalek
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.Toast
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.extension.BuildConfig
|
||||
import eu.kanade.tachiyomi.multisrc.madara.Madara
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
@ -18,14 +18,25 @@ import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
private const val mangalekUrl = "https://lekmanga.net"
|
||||
private const val MIRROR_PREF_KEY = "MIRROR"
|
||||
private const val MIRROR_PREF_TITLE = "تعديل رابط مانجا ليك"
|
||||
internal val MIRROR_PREF_ENTRY_VALUES = arrayOf(
|
||||
"https://lekmanga.net",
|
||||
"https://lekmanga.org",
|
||||
"https://like-manga.net",
|
||||
"https://lekmanga.com",
|
||||
)
|
||||
private val MIRROR_PREF_DEFAULT_VALUE = MIRROR_PREF_ENTRY_VALUES[0]
|
||||
private const val RESTART_TACHIYOMI = ".لتطبيق الإعدادات الجديدة Tachiyomi أعد تشغيل"
|
||||
|
||||
class Mangalek :
|
||||
Madara(
|
||||
"مانجا ليك",
|
||||
mangalekUrl,
|
||||
MIRROR_PREF_DEFAULT_VALUE,
|
||||
"ar",
|
||||
SimpleDateFormat("MMMM dd, yyyy", Locale("ar")),
|
||||
),
|
||||
@ -35,38 +46,50 @@ class Mangalek :
|
||||
override val useLoadMoreRequest = LoadMoreStrategy.Always
|
||||
override val chapterUrlSuffix = ""
|
||||
|
||||
private val defaultBaseUrl = mangalekUrl
|
||||
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||
override val baseUrl by lazy {
|
||||
when {
|
||||
System.getenv("CI") == "true" -> MIRROR_PREF_ENTRY_VALUES.joinToString("#, ")
|
||||
else -> preferences.getString(MIRROR_PREF_KEY, MIRROR_PREF_DEFAULT_VALUE)!!
|
||||
}
|
||||
}
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val RESTART_TACHIYOMI = ".لتطبيق الإعدادات الجديدة Tachiyomi أعد تشغيل"
|
||||
private const val BASE_URL_PREF_TITLE = "تعديل الرابط"
|
||||
private const val BASE_URL_PREF = "overrideBaseUrl_v${BuildConfig.VERSION_CODE}"
|
||||
private const val BASE_URL_PREF_SUMMARY = ".للاستخدام المؤقت. تحديث التطبيق سيؤدي الى حذف الإعدادات"
|
||||
}
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
val baseUrlPref = androidx.preference.EditTextPreference(screen.context).apply {
|
||||
key = BASE_URL_PREF
|
||||
title = BASE_URL_PREF_TITLE
|
||||
summary = BASE_URL_PREF_SUMMARY
|
||||
this.setDefaultValue(defaultBaseUrl)
|
||||
dialogTitle = BASE_URL_PREF_TITLE
|
||||
dialogMessage = "Default: $defaultBaseUrl"
|
||||
val mirrorPref = ListPreference(screen.context).apply {
|
||||
key = MIRROR_PREF_KEY
|
||||
title = MIRROR_PREF_TITLE
|
||||
entries = MIRROR_PREF_ENTRY_VALUES
|
||||
entryValues = MIRROR_PREF_ENTRY_VALUES
|
||||
setDefaultValue(MIRROR_PREF_DEFAULT_VALUE)
|
||||
summary = "%s"
|
||||
|
||||
setOnPreferenceChangeListener { _, _ ->
|
||||
Toast.makeText(screen.context, RESTART_TACHIYOMI, Toast.LENGTH_LONG).show()
|
||||
true
|
||||
}
|
||||
}
|
||||
screen.addPreference(baseUrlPref)
|
||||
screen.addPreference(mirrorPref)
|
||||
}
|
||||
|
||||
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, defaultBaseUrl)!!
|
||||
private val formatOne = SimpleDateFormat("MMMM dd, yyyy", Locale("ar"))
|
||||
private val formatTwo = SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
||||
|
||||
override fun parseChapterDate(date: String?): Long {
|
||||
date ?: return 0L
|
||||
|
||||
return try {
|
||||
formatOne.parse(date)!!.time
|
||||
} catch (_: ParseException) {
|
||||
try {
|
||||
formatTwo.parse(date)!!.time
|
||||
} catch (_: ParseException) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request =
|
||||
POST(
|
||||
|
Loading…
Reference in New Issue
Block a user