2021-12-21 17:58:42 +00:00
|
|
|
package com.lagradost.cloudstream3.movieproviders
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty
|
|
|
|
import com.lagradost.cloudstream3.*
|
2022-07-11 15:37:06 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.*
|
2022-07-09 13:24:12 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
2021-12-21 17:58:42 +00:00
|
|
|
import org.jsoup.Jsoup
|
|
|
|
import org.jsoup.select.Elements
|
|
|
|
|
|
|
|
class FilmanProvider : MainAPI() {
|
2022-03-16 15:29:11 +00:00
|
|
|
override var mainUrl = "https://filman.cc"
|
|
|
|
override var name = "filman.cc"
|
2022-06-16 22:07:07 +00:00
|
|
|
override var lang = "pl"
|
2021-12-21 17:58:42 +00:00
|
|
|
override val hasMainPage = true
|
|
|
|
override val supportedTypes = setOf(
|
|
|
|
TvType.Movie,
|
|
|
|
TvType.TvSeries
|
|
|
|
)
|
|
|
|
|
2022-01-16 22:31:42 +00:00
|
|
|
override suspend fun getMainPage(): HomePageResponse {
|
2021-12-21 17:58:42 +00:00
|
|
|
val response = app.get(mainUrl).text
|
|
|
|
val document = Jsoup.parse(response)
|
|
|
|
val lists = document.select(".item-list,.series-list")
|
|
|
|
val categories = ArrayList<HomePageList>()
|
|
|
|
for (l in lists) {
|
2022-05-02 16:58:27 +00:00
|
|
|
val title = l.parent()!!.select("h3").text()
|
2022-03-03 11:26:26 +00:00
|
|
|
val items = l.select(".poster").map { i ->
|
2021-12-21 17:58:42 +00:00
|
|
|
val name = i.select("a[href]").attr("title")
|
|
|
|
val href = i.select("a[href]").attr("href")
|
|
|
|
val poster = i.select("img[src]").attr("src")
|
|
|
|
val year = l.select(".film_year").text().toIntOrNull()
|
2022-03-03 11:26:26 +00:00
|
|
|
if (l.hasClass("series-list")) TvSeriesSearchResponse(
|
2021-12-21 17:58:42 +00:00
|
|
|
name,
|
|
|
|
href,
|
|
|
|
this.name,
|
|
|
|
TvType.TvSeries,
|
|
|
|
poster,
|
|
|
|
year,
|
|
|
|
null
|
|
|
|
) else MovieSearchResponse(
|
|
|
|
name,
|
|
|
|
href,
|
|
|
|
this.name,
|
|
|
|
TvType.Movie,
|
|
|
|
poster,
|
|
|
|
year
|
|
|
|
)
|
|
|
|
}
|
|
|
|
categories.add(HomePageList(title, items))
|
|
|
|
}
|
|
|
|
return HomePageResponse(categories)
|
|
|
|
}
|
|
|
|
|
2022-01-16 22:31:42 +00:00
|
|
|
override suspend fun search(query: String): List<SearchResponse> {
|
2021-12-21 17:58:42 +00:00
|
|
|
val url = "$mainUrl/wyszukiwarka?phrase=$query"
|
|
|
|
val response = app.get(url).text
|
|
|
|
val document = Jsoup.parse(response)
|
|
|
|
val lists = document.select("#advanced-search > div")
|
|
|
|
val movies = lists[1].select(".item")
|
|
|
|
val series = lists[3].select(".item")
|
|
|
|
if (movies.isEmpty() && series.isEmpty()) return ArrayList()
|
2022-03-03 11:26:26 +00:00
|
|
|
fun getVideos(type: TvType, items: Elements): List<SearchResponse> {
|
|
|
|
return items.map { i ->
|
2021-12-21 17:58:42 +00:00
|
|
|
val href = i.attr("href")
|
2022-05-02 16:58:27 +00:00
|
|
|
val img = i.selectFirst("> img")!!.attr("src").replace("/thumb/", "/big/")
|
|
|
|
val name = i.selectFirst(".title")!!.text()
|
2021-12-21 17:58:42 +00:00
|
|
|
if (type === TvType.TvSeries) {
|
2022-03-03 11:26:26 +00:00
|
|
|
TvSeriesSearchResponse(
|
|
|
|
name,
|
|
|
|
href,
|
|
|
|
this.name,
|
|
|
|
type,
|
|
|
|
img,
|
|
|
|
null,
|
|
|
|
null
|
2022-01-30 01:50:49 +00:00
|
|
|
)
|
2021-12-21 17:58:42 +00:00
|
|
|
} else {
|
2022-03-03 11:26:26 +00:00
|
|
|
MovieSearchResponse(name, href, this.name, type, img, null)
|
2021-12-21 17:58:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return getVideos(TvType.Movie, movies) + getVideos(TvType.TvSeries, series)
|
|
|
|
}
|
|
|
|
|
2022-01-16 22:31:42 +00:00
|
|
|
override suspend fun load(url: String): LoadResponse {
|
2021-12-21 17:58:42 +00:00
|
|
|
val response = app.get(url).text
|
|
|
|
val document = Jsoup.parse(response)
|
2022-07-09 13:24:12 +00:00
|
|
|
val documentTitle = document.select("title").text().trim()
|
|
|
|
|
2022-07-11 15:37:06 +00:00
|
|
|
if (documentTitle.startsWith("Logowanie")) {
|
2022-07-09 13:24:12 +00:00
|
|
|
throw RuntimeException("This page seems to be locked behind a login-wall on the website, unable to scrape it. If it is not please report it.")
|
|
|
|
}
|
|
|
|
|
2021-12-21 17:58:42 +00:00
|
|
|
var title = document.select("span[itemprop=title]").text()
|
|
|
|
val data = document.select("#links").outerHtml()
|
|
|
|
val posterUrl = document.select("#single-poster > img").attr("src")
|
2022-07-09 13:24:12 +00:00
|
|
|
val year = document.select(".info > ul li").getOrNull(0)?.text()?.toIntOrNull()
|
2021-12-21 17:58:42 +00:00
|
|
|
val plot = document.select(".description").text()
|
|
|
|
val episodesElements = document.select("#episode-list a[href]")
|
|
|
|
if (episodesElements.isEmpty()) {
|
|
|
|
return MovieLoadResponse(title, url, name, TvType.Movie, data, posterUrl, year, plot)
|
|
|
|
}
|
2022-05-02 16:58:27 +00:00
|
|
|
title = document.selectFirst(".info")?.parent()?.select("h2")?.text() ?: ""
|
2022-03-03 11:26:26 +00:00
|
|
|
val episodes = episodesElements.mapNotNull { episode ->
|
2021-12-21 17:58:42 +00:00
|
|
|
val e = episode.text()
|
2022-03-03 11:26:26 +00:00
|
|
|
val regex = Regex("""\[s(\d{1,3})e(\d{1,3})]""").find(e) ?: return@mapNotNull null
|
|
|
|
val eid = regex.groups
|
2022-04-09 14:50:04 +00:00
|
|
|
Episode(
|
|
|
|
episode.attr("href"),
|
2022-03-03 11:26:26 +00:00
|
|
|
e.split("]")[1].trim(),
|
|
|
|
eid[1]?.value?.toInt(),
|
|
|
|
eid[2]?.value?.toInt(),
|
|
|
|
)
|
|
|
|
}.toMutableList()
|
2022-03-12 14:34:44 +00:00
|
|
|
|
2022-01-30 01:50:49 +00:00
|
|
|
return TvSeriesLoadResponse(
|
|
|
|
title,
|
|
|
|
url,
|
|
|
|
name,
|
|
|
|
TvType.TvSeries,
|
|
|
|
episodes,
|
|
|
|
posterUrl,
|
|
|
|
year,
|
|
|
|
plot
|
|
|
|
)
|
2021-12-21 17:58:42 +00:00
|
|
|
}
|
|
|
|
|
2022-01-16 22:31:42 +00:00
|
|
|
override suspend fun loadLinks(
|
2021-12-21 17:58:42 +00:00
|
|
|
data: String,
|
|
|
|
isCasting: Boolean,
|
|
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
|
|
callback: (ExtractorLink) -> Unit
|
|
|
|
): Boolean {
|
|
|
|
val document = if (data.startsWith("http"))
|
2022-01-30 01:50:49 +00:00
|
|
|
app.get(data).document.select("#links").first()
|
|
|
|
else Jsoup.parse(data)
|
2021-12-21 17:58:42 +00:00
|
|
|
|
2022-05-02 16:58:27 +00:00
|
|
|
document?.select(".link-to-video")?.apmap { item ->
|
2022-01-30 01:50:49 +00:00
|
|
|
val decoded = base64Decode(item.select("a").attr("data-iframe"))
|
2022-07-09 13:24:12 +00:00
|
|
|
val link = tryParseJson<LinkElement>(decoded)?.src ?: return@apmap
|
2021-12-21 17:58:42 +00:00
|
|
|
loadExtractor(link, null, callback)
|
|
|
|
}
|
2022-01-30 01:50:49 +00:00
|
|
|
return true
|
2021-12-21 17:58:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data class LinkElement(
|
|
|
|
@JsonProperty("src") val src: String
|
|
|
|
)
|