some changes [OnePace] (#690)

* some changes [OnePace]

* update version [OnePace]
This commit is contained in:
Diego Peña Y Lillo
2022-07-24 05:45:09 -04:00
committed by GitHub
parent 617c5c7ba1
commit 187509ed53
2 changed files with 22 additions and 33 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Onepace' extName = 'Onepace'
pkgNameSuffix = 'all.onepace' pkgNameSuffix = 'all.onepace'
extClass = '.OnepaceFactory' extClass = '.OnepaceFactory'
extVersionCode = 1 extVersionCode = 2
libVersion = '12' libVersion = '12'
containsNsfw = false containsNsfw = false
} }

View File

@ -1,7 +1,5 @@
package eu.kanade.tachiyomi.animeextension.all.onepace package eu.kanade.tachiyomi.animeextension.all.onepace
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
import eu.kanade.tachiyomi.animesource.model.AnimesPage import eu.kanade.tachiyomi.animesource.model.AnimesPage
import eu.kanade.tachiyomi.animesource.model.SAnime import eu.kanade.tachiyomi.animesource.model.SAnime
@ -20,12 +18,11 @@ 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.api.get
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.lang.Exception import java.lang.Exception
import java.net.URLEncoder import java.net.URLEncoder
open class Onepace(override val lang: String, override val name: String) : ConfigurableAnimeSource, ParsedAnimeHttpSource() { open class Onepace(override val lang: String, override val name: String) : ParsedAnimeHttpSource() {
override val baseUrl = "https://www.zippyshare.com/rest/public/getTree?user=onepace&ident=kbvatgfc&id=%23" override val baseUrl = "https://www.zippyshare.com/rest/public/getTree?user=onepace&ident=kbvatgfc&id=%23"
@ -36,7 +33,6 @@ open class Onepace(override val lang: String, override val name: String) : Confi
private val json: Json by injectLazy() private val json: Json by injectLazy()
override fun popularAnimeParse(response: Response): AnimesPage { override fun popularAnimeParse(response: Response): AnimesPage {
val animes = mutableListOf<SAnime>()
val document = client.newCall(GET(baseUrl)).execute().asJsoup() val document = client.newCall(GET(baseUrl)).execute().asJsoup()
val responseJson = json.decodeFromString<JsonObject>(document.select("body").text().dropLast(1).drop(1)) val responseJson = json.decodeFromString<JsonObject>(document.select("body").text().dropLast(1).drop(1))
val childrenJson = responseJson["children"]?.jsonArray val childrenJson = responseJson["children"]?.jsonArray
@ -48,26 +44,24 @@ open class Onepace(override val lang: String, override val name: String) : Confi
else -> 0 else -> 0
} }
val langAnJson = childrenJson!![langId].jsonObject["children"]!!.jsonArray val langAnJson = childrenJson!![langId].jsonObject["children"]!!.jsonArray
langAnJson.forEach { val thumJson = client.newCall(GET("https://onepace.net/_next/data/BM0nGdjN96o4xOSQR37x8/es/watch.json")).execute().asJsoup()
val anName = it.jsonObject["text"].toString().replace("\"", "") return AnimesPage(
val anId = it.jsonObject["li_attr"]!!.jsonObject["ident"].toString().replace("\"", "") langAnJson.map {
val anStatus = if (anName.contains("Completo")) SAnime.COMPLETED else SAnime.ONGOING val anName = it.jsonObject["text"].toString().replace("\"", "")
val thumUrl = thumAnimeParser(anName) val anId = it.jsonObject["li_attr"]!!.jsonObject["ident"].toString().replace("\"", "")
animes.add( val anStatus = if (anName.contains("Completo")) SAnime.COMPLETED else SAnime.ONGOING
SAnime.create().apply { SAnime.create().apply {
title = anName title = anName
status = anStatus status = anStatus
url = "https://www.zippyshare.com/onepace/$anId/dir.html" url = "https://www.zippyshare.com/onepace/$anId/dir.html"
thumbnail_url = thumUrl thumbnail_url = thumAnimeParser(anName, thumJson)
} }
) },
} false
)
return AnimesPage(animes, false)
} }
private fun thumAnimeParser(animeName: String): String { private fun thumAnimeParser(animeName: String, document: Document): String {
val document = client.newCall(GET("https://onepace.net/_next/data/BM0nGdjN96o4xOSQR37x8/es/watch.json")).execute().asJsoup()
val jsonResponse = json.decodeFromString<JsonObject>(document.body().text())["pageProps"]!! val jsonResponse = json.decodeFromString<JsonObject>(document.body().text())["pageProps"]!!
val arcsJson = jsonResponse.jsonObject["arcs"]!!.jsonArray val arcsJson = jsonResponse.jsonObject["arcs"]!!.jsonArray
arcsJson.forEach { arcsJson.forEach {
@ -93,23 +87,18 @@ open class Onepace(override val lang: String, override val name: String) : Confi
override fun popularAnimeFromElement(element: Element) = throw Exception("not used") override fun popularAnimeFromElement(element: Element) = throw Exception("not used")
override fun episodeListParse(response: Response): List<SEpisode> { override fun episodeListParse(response: Response): List<SEpisode> {
val episodes = mutableListOf<SEpisode>()
val Realurl = response.request.url.toString().substringAfter("%23") val Realurl = response.request.url.toString().substringAfter("%23")
val jsoup = client.newCall(GET(Realurl)).execute().asJsoup() val jsoup = client.newCall(GET(Realurl)).execute().asJsoup()
jsoup.select("table.listingplikow tbody tr.filerow.even").forEach { return jsoup.select("table.listingplikow tbody tr.filerow.even").map {
val epName = it.select("td.cien a.name").text().replace(".mp4", "") val epName = it.select("td.cien a.name").text().replace(".mp4", "")
val epNum = epName.substringAfter("][").substringBefore("]").replace("-", ".").replace(",", ".").toFloat() val epNum = epName.substringAfter("][").substringBefore("]").replace("-", ".").replace(",", ".").toFloat()
val epUrl = it.select("td.cien a.name").attr("href") val epUrl = it.select("td.cien a.name").attr("href")
episodes.add( SEpisode.create().apply {
SEpisode.create().apply { name = epName
name = epName url = epUrl
url = epUrl episode_number = epNum
episode_number = epNum }
}
)
} }
return episodes
} }
override fun episodeListSelector() = throw Exception("not used") override fun episodeListSelector() = throw Exception("not used")
@ -150,7 +139,7 @@ open class Onepace(override val lang: String, override val name: String) : Confi
override fun latestUpdatesSelector() = throw Exception("not used") override fun latestUpdatesSelector() = throw Exception("not used")
override fun animeDetailsParse(document: Document) = throw Exception("") override fun animeDetailsParse(document: Document): SAnime {
return SAnime.create().apply { title = "OnePace" }
override fun setupPreferenceScreen(screen: PreferenceScreen) = throw Exception("not used") }
} }