mirror of
https://github.com/recloudstream/cloudstream-extensions.git
synced 2024-08-15 03:03:54 +00:00
Fixed WatchCartoonOnline homepage
This commit is contained in:
parent
b9d86b5be2
commit
1fa527454c
2 changed files with 21 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 2
|
version = 3
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -22,7 +22,7 @@ class WatchCartoonOnlineProvider : MainAPI() {
|
||||||
TvType.TvSeries
|
TvType.TvSeries
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse? {
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
||||||
val doc = app.get(mainUrl).document
|
val doc = app.get(mainUrl).document
|
||||||
val rows = doc.select("div.recent-release").mapNotNull {
|
val rows = doc.select("div.recent-release").mapNotNull {
|
||||||
val rowName = it.text()
|
val rowName = it.text()
|
||||||
|
@ -121,8 +121,19 @@ class WatchCartoonOnlineProvider : MainAPI() {
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse {
|
override suspend fun load(url: String): LoadResponse {
|
||||||
val isSeries = url.contains("/anime/")
|
val isSeries = url.contains("/anime/")
|
||||||
|
val episodeRegex = Regex("""-episode-\d+""")
|
||||||
val document = app.get(url).document
|
val document = app.get(url).document
|
||||||
|
|
||||||
|
// Retries link loading when an episode page is opened, usually from home.
|
||||||
|
// The slug system is too unpredictable to skip this step.
|
||||||
|
if (url.contains(episodeRegex)) {
|
||||||
|
val link = document.select("div.ildate > a").attr("href")
|
||||||
|
// Must not contain the episode regex, otherwise infinite recursion.
|
||||||
|
if (!link.contains(episodeRegex)) {
|
||||||
|
return load(link)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return if (isSeries) {
|
return if (isSeries) {
|
||||||
val title = document.selectFirst("td.vsbaslik > h2")!!.text()
|
val title = document.selectFirst("td.vsbaslik > h2")!!.text()
|
||||||
val poster =
|
val poster =
|
||||||
|
@ -148,7 +159,7 @@ class WatchCartoonOnlineProvider : MainAPI() {
|
||||||
return@map Episode(
|
return@map Episode(
|
||||||
href,
|
href,
|
||||||
if (last.startsWith("English")) null else last,
|
if (last.startsWith("English")) null else last,
|
||||||
null,
|
1,
|
||||||
match2.groupValues[1].toIntOrNull(),
|
match2.groupValues[1].toIntOrNull(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -202,15 +213,16 @@ class WatchCartoonOnlineProvider : MainAPI() {
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val document = app.get(data).document
|
val document = app.get(data).document
|
||||||
val foundJS = document.select("div.iltext > script").html()
|
|
||||||
|
|
||||||
// Find the variable name, eg: var HAi = "";
|
val src = document.select("iframe#frameNewAnimeuploads0").attr("src").ifBlank { null } ?: mainWork {
|
||||||
val varRegex = Regex("""var (\S*)""")
|
val foundJS = document.select("div.iltext > script").html()
|
||||||
|
|
||||||
val varName = varRegex.find(foundJS)?.groupValues?.get(1)
|
// Find the variable name, eg: var HAi = "";
|
||||||
?: throw RuntimeException("Cannot find var name!")
|
val varRegex = Regex("""var (\S*)""")
|
||||||
|
|
||||||
|
val varName = varRegex.find(foundJS)?.groupValues?.get(1)
|
||||||
|
?: throw RuntimeException("Cannot find var name!")
|
||||||
|
|
||||||
val src = document.select("iframe#frameNewAnimeuploads0").attr("src") ?: mainWork {
|
|
||||||
// Rhino needs to be on main
|
// Rhino needs to be on main
|
||||||
val rhino = Context.enter()
|
val rhino = Context.enter()
|
||||||
rhino.optimizationLevel = -1
|
rhino.optimizationLevel = -1
|
||||||
|
|
Loading…
Reference in a new issue