TeamX: update domain, baseUrl config, author + status fields (#4283)
* Team X: update domain * add status, author * add baseUrl override
This commit is contained in:
parent
13fcfc6996
commit
2623bf72c5
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Team X'
|
extName = 'Team X'
|
||||||
extClass = '.TeamX'
|
extClass = '.TeamX'
|
||||||
extVersionCode = 17
|
extVersionCode = 18
|
||||||
isNsfw = false
|
isNsfw = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package eu.kanade.tachiyomi.extension.ar.teamx
|
package eu.kanade.tachiyomi.extension.ar.teamx
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
||||||
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
|
@ -14,15 +19,19 @@ import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class TeamX : ParsedHttpSource() {
|
class TeamX : ParsedHttpSource(), ConfigurableSource {
|
||||||
|
|
||||||
override val name = "Team X"
|
override val name = "Team X"
|
||||||
|
|
||||||
override val baseUrl = "https://teamxnovel.com"
|
private val defaultBaseUrl = "https://teamoney.site"
|
||||||
|
|
||||||
|
override val baseUrl by lazy { getPrefBaseUrl() }
|
||||||
|
|
||||||
override val lang = "ar"
|
override val lang = "ar"
|
||||||
|
|
||||||
|
@ -34,6 +43,10 @@ class TeamX : ParsedHttpSource() {
|
||||||
.rateLimit(10, 1, TimeUnit.SECONDS)
|
.rateLimit(10, 1, TimeUnit.SECONDS)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
private val preferences: SharedPreferences by lazy {
|
||||||
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
}
|
||||||
|
|
||||||
// Popular
|
// Popular
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int): Request {
|
||||||
|
@ -130,6 +143,14 @@ class TeamX : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
genre = document.select("div.review-author-info a").joinToString { it.text() }
|
genre = document.select("div.review-author-info a").joinToString { it.text() }
|
||||||
thumbnail_url = document.select("div.text-right img").first()!!.absUrl("src")
|
thumbnail_url = document.select("div.text-right img").first()!!.absUrl("src")
|
||||||
|
status = document
|
||||||
|
.selectFirst(".full-list-info > small:first-child:contains(الحالة) + small")
|
||||||
|
?.text()
|
||||||
|
.toStatus()
|
||||||
|
author = document
|
||||||
|
.selectFirst(".full-list-info > small:first-child:contains(الرسام) + small")
|
||||||
|
?.text()
|
||||||
|
?.takeIf { it != "غير معروف" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +208,14 @@ class TeamX : ParsedHttpSource() {
|
||||||
}.getOrNull() ?: 0
|
}.getOrNull() ?: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String?.toStatus() = when (this) {
|
||||||
|
"مستمرة" -> SManga.ONGOING
|
||||||
|
"قادم قريبًا" -> SManga.ONGOING // "coming soon"
|
||||||
|
"مكتمل" -> SManga.COMPLETED
|
||||||
|
"متوقف" -> SManga.ON_HIATUS
|
||||||
|
else -> SManga.UNKNOWN
|
||||||
|
}
|
||||||
|
|
||||||
// Pages
|
// Pages
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
|
@ -196,4 +225,41 @@ class TeamX : ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException()
|
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException()
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val RESTART_APP = ".لتطبيق الإعدادات الجديدة أعد تشغيل التطبيق"
|
||||||
|
private const val BASE_URL_PREF_TITLE = "تعديل الرابط"
|
||||||
|
private const val BASE_URL_PREF = "overrideBaseUrl"
|
||||||
|
private const val BASE_URL_PREF_SUMMARY = ".للاستخدام المؤقت. تحديث التطبيق سيؤدي الى حذف الإعدادات"
|
||||||
|
private const val DEFAULT_BASE_URL_PREF = "defaultBaseUrl"
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, _ ->
|
||||||
|
Toast.makeText(screen.context, RESTART_APP, Toast.LENGTH_LONG).show()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
screen.addPreference(baseUrlPref)
|
||||||
|
}
|
||||||
|
private fun getPrefBaseUrl(): String = preferences.getString(BASE_URL_PREF, defaultBaseUrl)!!
|
||||||
|
|
||||||
|
init {
|
||||||
|
preferences.getString(DEFAULT_BASE_URL_PREF, null).let { prefDefaultBaseUrl ->
|
||||||
|
if (prefDefaultBaseUrl != defaultBaseUrl) {
|
||||||
|
preferences.edit()
|
||||||
|
.putString(BASE_URL_PREF, defaultBaseUrl)
|
||||||
|
.putString(DEFAULT_BASE_URL_PREF, defaultBaseUrl)
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue