fix(pt/hentaistube): Update episode list selector + minor refactoration (#3191)
This commit is contained in:
parent
0fdb8d25b4
commit
d92f5ef1cc
@ -1,7 +1,7 @@
|
|||||||
ext {
|
ext {
|
||||||
extName = 'HentaisTube'
|
extName = 'HentaisTube'
|
||||||
extClass = '.HentaisTube'
|
extClass = '.HentaisTube'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.pt.hentaistube
|
package eu.kanade.tachiyomi.animeextension.pt.hentaistube
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.animeextension.pt.hentaistube.HentaisTubeFilters.applyFilterParams
|
import eu.kanade.tachiyomi.animeextension.pt.hentaistube.HentaisTubeFilters.applyFilterParams
|
||||||
@ -19,14 +18,13 @@ import eu.kanade.tachiyomi.network.await
|
|||||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import eu.kanade.tachiyomi.util.parallelCatchingFlatMapBlocking
|
import eu.kanade.tachiyomi.util.parallelCatchingFlatMapBlocking
|
||||||
import kotlinx.serialization.json.Json
|
import eu.kanade.tachiyomi.util.parseAs
|
||||||
import okhttp3.Request
|
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.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
|
||||||
|
|
||||||
class HentaisTube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
class HentaisTube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
@ -42,9 +40,7 @@ class HentaisTube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
.add("Referer", baseUrl)
|
.add("Referer", baseUrl)
|
||||||
.add("Origin", baseUrl)
|
.add("Origin", baseUrl)
|
||||||
|
|
||||||
private val json: Json by injectLazy()
|
private val preferences by lazy {
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,9 +76,7 @@ class HentaisTube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
private val animeList by lazy {
|
private val animeList by lazy {
|
||||||
val headers = headersBuilder().add("X-Requested-With", "XMLHttpRequest").build()
|
val headers = headersBuilder().add("X-Requested-With", "XMLHttpRequest").build()
|
||||||
client.newCall(GET("$baseUrl/json-lista-capas.php", headers)).execute()
|
client.newCall(GET("$baseUrl/json-lista-capas.php", headers)).execute()
|
||||||
.body.string()
|
.parseAs<ItemsListDto>().items
|
||||||
.let { json.decodeFromString<ItemsListDto>(it) }
|
|
||||||
.items
|
|
||||||
.asSequence()
|
.asSequence()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +145,7 @@ class HentaisTube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
// ============================== Episodes ==============================
|
// ============================== Episodes ==============================
|
||||||
override fun episodeListParse(response: Response) = super.episodeListParse(response).reversed()
|
override fun episodeListParse(response: Response) = super.episodeListParse(response).reversed()
|
||||||
|
|
||||||
override fun episodeListSelector() = "div.pagAniListaContainer > li > a"
|
override fun episodeListSelector() = "ul.pagAniListaContainer > li > a"
|
||||||
|
|
||||||
override fun episodeFromElement(element: Element) = SEpisode.create().apply {
|
override fun episodeFromElement(element: Element) = SEpisode.create().apply {
|
||||||
setUrlWithoutDomain(element.attr("href"))
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
@ -213,12 +207,6 @@ class HentaisTube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
entryValues = PREF_QUALITY_ENTRIES
|
entryValues = PREF_QUALITY_ENTRIES
|
||||||
setDefaultValue(PREF_QUALITY_DEFAULT)
|
setDefaultValue(PREF_QUALITY_DEFAULT)
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
|
||||||
val selected = newValue as String
|
|
||||||
val index = findIndexOfValue(selected)
|
|
||||||
val entry = entryValues[index] as String
|
|
||||||
preferences.edit().putString(key, entry).commit()
|
|
||||||
}
|
|
||||||
}.also(screen::addPreference)
|
}.also(screen::addPreference)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user