Update NX URL and fix chapter parsing. (#11994)
This commit is contained in:
parent
d1abd5cf30
commit
ee952d142b
@ -16,6 +16,9 @@ import eu.kanade.tachiyomi.source.model.MangasPage
|
|||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
|
import kotlinx.serialization.json.jsonArray
|
||||||
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
import kotlinx.serialization.json.jsonPrimitive
|
||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
@ -26,6 +29,7 @@ import okhttp3.Response
|
|||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.io.IOException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
@ -37,7 +41,7 @@ class NeoxScanlator :
|
|||||||
"Neox Scanlator",
|
"Neox Scanlator",
|
||||||
DEFAULT_BASE_URL,
|
DEFAULT_BASE_URL,
|
||||||
"pt-BR",
|
"pt-BR",
|
||||||
SimpleDateFormat("dd/MM/yyyy", Locale("pt", "BR"))
|
SimpleDateFormat("MMMMM dd, yyyy", Locale("pt", "BR"))
|
||||||
),
|
),
|
||||||
ConfigurableSource {
|
ConfigurableSource {
|
||||||
|
|
||||||
@ -45,11 +49,14 @@ class NeoxScanlator :
|
|||||||
.connectTimeout(1, TimeUnit.MINUTES)
|
.connectTimeout(1, TimeUnit.MINUTES)
|
||||||
.readTimeout(1, TimeUnit.MINUTES)
|
.readTimeout(1, TimeUnit.MINUTES)
|
||||||
.addInterceptor(::titleCollectionIntercept)
|
.addInterceptor(::titleCollectionIntercept)
|
||||||
|
.addInterceptor(::obsoleteCheckIntercept)
|
||||||
.addInterceptor(RateLimitInterceptor(1, 3, TimeUnit.SECONDS))
|
.addInterceptor(RateLimitInterceptor(1, 3, TimeUnit.SECONDS))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
override val altNameSelector = ".post-content_item:contains(Alternativo) .summary-content"
|
override val altNameSelector = ".post-content_item:contains(Alternativo) .summary-content"
|
||||||
|
|
||||||
|
override val chapterUrlSelector = "a:not(:has(img.thumb))"
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
private val preferences: SharedPreferences by lazy {
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
}
|
}
|
||||||
@ -60,6 +67,8 @@ class NeoxScanlator :
|
|||||||
|
|
||||||
private var titleCollectionPath: String? = null
|
private var titleCollectionPath: String? = null
|
||||||
|
|
||||||
|
private var extIsObsolete: Boolean? = null
|
||||||
|
|
||||||
override fun headersBuilder(): Headers.Builder = super.headersBuilder()
|
override fun headersBuilder(): Headers.Builder = super.headersBuilder()
|
||||||
.add("Accept", ACCEPT)
|
.add("Accept", ACCEPT)
|
||||||
.add("Accept-Language", ACCEPT_LANGUAGE)
|
.add("Accept-Language", ACCEPT_LANGUAGE)
|
||||||
@ -214,6 +223,25 @@ class NeoxScanlator :
|
|||||||
return chain.proceed(fixedRequest)
|
return chain.proceed(fixedRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun obsoleteCheckIntercept(chain: Interceptor.Chain): Response {
|
||||||
|
if (extIsObsolete == null) {
|
||||||
|
val repoRequest = GET(EXT_REPO_JSON)
|
||||||
|
val repoResponse = chain.proceed(repoRequest)
|
||||||
|
val repoJson = json.parseToJsonElement(repoResponse.body!!.string()).jsonArray
|
||||||
|
|
||||||
|
val extDetails = repoJson.firstOrNull { it.jsonObject["pkg"]!!.jsonPrimitive.content == EXT_PKG }
|
||||||
|
extIsObsolete = extDetails == null
|
||||||
|
|
||||||
|
repoResponse.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extIsObsolete == true) {
|
||||||
|
throw IOException(OBSOLETE_ERROR)
|
||||||
|
}
|
||||||
|
|
||||||
|
return chain.proceed(chain.request())
|
||||||
|
}
|
||||||
|
|
||||||
private fun Call.asCustomObservable(): Observable<Response> {
|
private fun Call.asCustomObservable(): Observable<Response> {
|
||||||
return asObservable().doOnNext { response ->
|
return asObservable().doOnNext { response ->
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
@ -245,7 +273,7 @@ class NeoxScanlator :
|
|||||||
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,es;q=0.6,gl;q=0.5"
|
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,es;q=0.6,gl;q=0.5"
|
||||||
private const val REFERER = "https://google.com/"
|
private const val REFERER = "https://google.com/"
|
||||||
|
|
||||||
private const val DEFAULT_BASE_URL = "https://neoxscan.net"
|
private const val DEFAULT_BASE_URL = "https://neoxscans.net"
|
||||||
private val BASE_URL_PREF_KEY = "base_url_${BuildConfig.VERSION_NAME}"
|
private val BASE_URL_PREF_KEY = "base_url_${BuildConfig.VERSION_NAME}"
|
||||||
private const val BASE_URL_PREF_TITLE = "URL da fonte"
|
private const val BASE_URL_PREF_TITLE = "URL da fonte"
|
||||||
private const val BASE_URL_PREF_SUMMARY = "Para uso temporário. Quando você atualizar a " +
|
private const val BASE_URL_PREF_SUMMARY = "Para uso temporário. Quando você atualizar a " +
|
||||||
@ -254,5 +282,9 @@ class NeoxScanlator :
|
|||||||
private const val RESTART_TACHIYOMI = "Reinicie o Tachiyomi para aplicar as configurações."
|
private const val RESTART_TACHIYOMI = "Reinicie o Tachiyomi para aplicar as configurações."
|
||||||
|
|
||||||
private val TITLE_PATH_PLACEHOLDER = UUID.randomUUID().toString()
|
private val TITLE_PATH_PLACEHOLDER = UUID.randomUUID().toString()
|
||||||
|
|
||||||
|
private const val EXT_REPO_JSON = "https://raw.githubusercontent.com/tachiyomiorg/tachiyomi-extensions/repo/index.json"
|
||||||
|
private const val EXT_PKG = "eu.kanade.tachiyomi.extension.pt.neoxscanlator"
|
||||||
|
private const val OBSOLETE_ERROR = "Extensão obsoleta. Migre para fontes melhores."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,9 +609,9 @@ abstract class Madara(
|
|||||||
)
|
)
|
||||||
|
|
||||||
protected val ongoingStatusList: Array<String> = arrayOf(
|
protected val ongoingStatusList: Array<String> = arrayOf(
|
||||||
"OnGoing", "Продолжается", "Updating", "Em Lançamento", "Em andamento", "Em Andamento",
|
"OnGoing", "Продолжается", "Updating", "Em Lançamento", "Em lançamento", "Em andamento",
|
||||||
"En cours", "Ativo", "Lançando", "Đang Tiến Hành", "Devam Ediyor", "Devam ediyor",
|
"Em Andamento", "En cours", "Ativo", "Lançando", "Đang Tiến Hành", "Devam Ediyor",
|
||||||
"In Corso", "In Arrivo", "مستمرة"
|
"Devam ediyor", "In Corso", "In Arrivo", "مستمرة"
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun mangaDetailsParse(document: Document): SManga {
|
override fun mangaDetailsParse(document: Document): SManga {
|
||||||
@ -812,7 +812,7 @@ abstract class Madara(
|
|||||||
// Added "title" alternative
|
// Added "title" alternative
|
||||||
chapter.date_upload = select("img:not(.thumb)").firstOrNull()?.attr("alt")?.let { parseRelativeDate(it) }
|
chapter.date_upload = select("img:not(.thumb)").firstOrNull()?.attr("alt")?.let { parseRelativeDate(it) }
|
||||||
?: select("span a").firstOrNull()?.attr("title")?.let { parseRelativeDate(it) }
|
?: select("span a").firstOrNull()?.attr("title")?.let { parseRelativeDate(it) }
|
||||||
?: parseChapterDate(select(chapterDateSelector()).firstOrNull()?.text())
|
?: parseChapterDate(select(chapterDateSelector()).firstOrNull()?.text())
|
||||||
}
|
}
|
||||||
|
|
||||||
return chapter
|
return chapter
|
||||||
|
@ -345,7 +345,7 @@ class MadaraGenerator : ThemeSourceGenerator {
|
|||||||
SingleLang("NeatManga", "https://neatmanga.com", "en", overrideVersionCode = 2),
|
SingleLang("NeatManga", "https://neatmanga.com", "en", overrideVersionCode = 2),
|
||||||
SingleLang("NekoBreaker Scan", "https://nekobreakerscan.com", "pt-BR", overrideVersionCode = 1),
|
SingleLang("NekoBreaker Scan", "https://nekobreakerscan.com", "pt-BR", overrideVersionCode = 1),
|
||||||
SingleLang("NekoScan", "https://nekoscan.com", "en", overrideVersionCode = 2),
|
SingleLang("NekoScan", "https://nekoscan.com", "en", overrideVersionCode = 2),
|
||||||
SingleLang("Neox Scanlator", "https://neoxscan.net", "pt-BR", overrideVersionCode = 13),
|
SingleLang("Neox Scanlator", "https://neoxscans.net", "pt-BR", overrideVersionCode = 14),
|
||||||
SingleLang("Night Comic", "https://www.nightcomic.com", "en", overrideVersionCode = 1),
|
SingleLang("Night Comic", "https://www.nightcomic.com", "en", overrideVersionCode = 1),
|
||||||
SingleLang("Niji Translations", "https://niji-translations.com", "ar", overrideVersionCode = 1),
|
SingleLang("Niji Translations", "https://niji-translations.com", "ar", overrideVersionCode = 1),
|
||||||
SingleLang("Ninja Scan", "https://ninjascan.xyz", "pt-BR", overrideVersionCode = 1),
|
SingleLang("Ninja Scan", "https://ninjascan.xyz", "pt-BR", overrideVersionCode = 1),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user