added movie support for WatchCartoonsOnline

This commit is contained in:
ArjixWasTaken 2021-09-29 20:55:28 +03:00
parent 9d19f4cde7
commit 1948a2c2d9

View file

@ -26,15 +26,14 @@ class WatchCartoonOnlineProvider : MainAPI() {
override fun search(query: String): List<SearchResponse> {
val url = "https://www.wcostream.com/search"
val response =
var response =
khttp.post(
url,
headers = mapOf("Referer" to url),
data = mapOf("catara" to query, "konuara" to "series")
)
val document = Jsoup.parse(response.text)
val items = document.select("div#blog > div.cerceve")
if (items.isNullOrEmpty()) return ArrayList()
var document = Jsoup.parse(response.text)
var items = document.select("div#blog > div.cerceve").toList()
val returnValue = ArrayList<SearchResponse>()
for (item in items) {
@ -66,13 +65,49 @@ class WatchCartoonOnlineProvider : MainAPI() {
)
}
}
// "episodes-search", is used for finding movies, anime episodes should be filtered out
response =
khttp.post(
url,
headers = mapOf("Referer" to url),
data = mapOf("catara" to query, "konuara" to "episodes")
)
document = Jsoup.parse(response.text)
items = document.select("#catlist-listview2 > ul > li").filter { it?.text() != null && !it?.text().toString().contains("Episode") }
for (item in items) {
val titleHeader = item.selectFirst("a")
val title = titleHeader.text()
val href = fixUrl(titleHeader.attr("href"))
val isDubbed = title.contains("dubbed")
val set: EnumSet<DubStatus> =
EnumSet.of(if (isDubbed) DubStatus.Dubbed else DubStatus.Subbed)
returnValue.add(
TvSeriesSearchResponse(
title,
href,
this.name,
TvType.AnimeMovie,
null,
null,
null,
)
)
}
return returnValue
}
override fun load(url: String): LoadResponse {
val isMovie = !url.contains("/anime/")
val response = khttp.get(url)
val document = Jsoup.parse(response.text)
return if (!isMovie) {
val title = document.selectFirst("td.vsbaslik > h2").text()
val poster = fixUrl(document.selectFirst("div#cat-img-desc > div > img").attr("src"))
val plot = document.selectFirst("div.iltext").text()
@ -107,8 +142,7 @@ class WatchCartoonOnlineProvider : MainAPI() {
href
)
}
return TvSeriesLoadResponse(
TvSeriesLoadResponse(
title,
url,
this.name,
@ -121,6 +155,26 @@ class WatchCartoonOnlineProvider : MainAPI() {
null,
tags = genres
)
} else {
val title = document.selectFirst(".iltext .Apple-style-span")?.text().toString()
val b = document.select(".iltext b")
val description = if (b.isNotEmpty()) {
b.last().html().split("<br>")[0]
} else null
TvSeriesLoadResponse(
title,
url,
this.name,
TvType.TvSeries,
listOf(TvSeriesEpisode(title, null, null, url)),
null,
null,
description,
null,
null
)
}
}
data class LinkResponse(