From 7dbb146399b84a3f95f600696128b38a3de025f0 Mon Sep 17 00:00:00 2001 From: antonydp <38143733+antonydp@users.noreply.github.com> Date: Sat, 27 Aug 2022 16:27:45 +0200 Subject: [PATCH] Tantifilm (cloudflare) and IlGenioDelloStreamingProvider fixes (#4) --- EurostreamingProvider/build.gradle.kts | 26 ++++ .../src/main/AndroidManifest.xml | 2 + .../com/lagradost/EurostreamingProvider.kt | 113 ++++++++++++++++++ .../lagradost/EurostreamingProviderPlugin.kt | 14 +++ .../IlGenioDelloStreamingProvider.kt | 48 +++++--- TantiFilmProvider/build.gradle.kts | 2 +- .../kotlin/com/lagradost/TantiFilmProvider.kt | 31 +++-- 7 files changed, 208 insertions(+), 28 deletions(-) create mode 100644 EurostreamingProvider/build.gradle.kts create mode 100644 EurostreamingProvider/src/main/AndroidManifest.xml create mode 100644 EurostreamingProvider/src/main/kotlin/com/lagradost/EurostreamingProvider.kt create mode 100644 EurostreamingProvider/src/main/kotlin/com/lagradost/EurostreamingProviderPlugin.kt diff --git a/EurostreamingProvider/build.gradle.kts b/EurostreamingProvider/build.gradle.kts new file mode 100644 index 0000000..fa19a12 --- /dev/null +++ b/EurostreamingProvider/build.gradle.kts @@ -0,0 +1,26 @@ +// use an integer for version numbers +version = 1 + + +cloudstream { + language = "it" + // All of these properties are optional, you can safely remove them + + // description = "Lorem Ipsum" + // authors = listOf("Cloudburst") + + /** + * Status int as the following: + * 0: Down + * 1: Ok + * 2: Slow + * 3: Beta only + * */ + status = 1 // will be 3 if unspecified + tvTypes = listOf( + "TvSeries" + ) + + + iconUrl = "https://www.google.com/s2/favicons?domain=eurostreaming.social&sz=%size%" +} \ No newline at end of file diff --git a/EurostreamingProvider/src/main/AndroidManifest.xml b/EurostreamingProvider/src/main/AndroidManifest.xml new file mode 100644 index 0000000..29aec9d --- /dev/null +++ b/EurostreamingProvider/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/EurostreamingProvider/src/main/kotlin/com/lagradost/EurostreamingProvider.kt b/EurostreamingProvider/src/main/kotlin/com/lagradost/EurostreamingProvider.kt new file mode 100644 index 0000000..ec81f4e --- /dev/null +++ b/EurostreamingProvider/src/main/kotlin/com/lagradost/EurostreamingProvider.kt @@ -0,0 +1,113 @@ +package com.lagradost + +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.loadExtractor +import com.lagradost.cloudstream3.utils.AppUtils.parseJson +import com.lagradost.cloudstream3.utils.AppUtils.toJson + + +class EurostreamingProvider : MainAPI() { + override var lang = "it" + override var mainUrl = "https://eurostreaming.social" + override var name = "Eurostreaming" + override val hasMainPage = true + override val hasChromecastSupport = true + override val supportedTypes = setOf( + TvType.TvSeries + ) + + override val mainPage = mainPageOf( + Pair("$mainUrl/serie-tv-archive/page/", "Ultime serie Tv"), + Pair("$mainUrl/animazione/page/", "Ultime serie Animazione"), + + ) + + override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { + val url = request.data + page + + val soup = app.get(url).document + val home = soup.select("div.post-thumb").map { + val title = it.selectFirst("img")!!.attr("alt") + val link = it.selectFirst("a")!!.attr("href") + val image = fixUrl(it.selectFirst("img")!!.attr("src")) + + MovieSearchResponse( + title, + link, + this.name, + TvType.Movie, + image + ) + } + return newHomePageResponse(request.name, home) + } + + override suspend fun search(query: String): List { + val doc = app.post( + "$mainUrl/index.php", data = mapOf( + "do" to "search", + "subaction" to "search", + "story" to query, + "sortby" to "news_read" + ) + ).document + return doc.select("div.post-thumb").map { + val title = it.selectFirst("img")!!.attr("alt") + val link = it.selectFirst("a")!!.attr("href") + val image = mainUrl + it.selectFirst("img")!!.attr("src") + + MovieSearchResponse( + title, + link, + this.name, + TvType.Movie, + image + ) + } + } + + override suspend fun load(url: String): LoadResponse { + val page = app.get(url) + val document = page.document + val title = document.selectFirst("h2")!!.text().replace("^([1-9+]]$","") + val style = document.selectFirst("div.entry-cover")!!.attr("style") + val poster = fixUrl(Regex("(/upload.+\\))").find(style)!!.value.dropLast(1)) + val episodeList = ArrayList() + document.select("div.tab-pane.fade").map { element -> + val season = element.attr("id").filter { it.isDigit() }.toInt() + element.select("li").filter { it-> it.selectFirst("a")?.hasAttr("data-title")?:false }.map{episode -> + val data = episode.select("div.mirrors > a").map { it.attr("data-link") }.toJson() + val epnameData = episode.selectFirst("a") + val epTitle = epnameData!!.attr("data-title") + val epNum = epnameData.text().toInt() + episodeList.add( + Episode( + data, + epTitle, + season, + epNum + + ) + ) + } + } + return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodeList) { + posterUrl = poster + } + + } + + + override suspend fun loadLinks( + data: String, + isCasting: Boolean, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ): Boolean { + parseJson>(data).map { videoUrl -> + loadExtractor(videoUrl, data, subtitleCallback, callback) + } + return true + } +} diff --git a/EurostreamingProvider/src/main/kotlin/com/lagradost/EurostreamingProviderPlugin.kt b/EurostreamingProvider/src/main/kotlin/com/lagradost/EurostreamingProviderPlugin.kt new file mode 100644 index 0000000..7a18c9b --- /dev/null +++ b/EurostreamingProvider/src/main/kotlin/com/lagradost/EurostreamingProviderPlugin.kt @@ -0,0 +1,14 @@ + +package com.lagradost + +import com.lagradost.cloudstream3.plugins.CloudstreamPlugin +import com.lagradost.cloudstream3.plugins.Plugin +import android.content.Context + +@CloudstreamPlugin +class EurostreamingProviderPlugin: Plugin() { + override fun load(context: Context) { + // All providers should be added in this manner. Please don't edit the providers list directly. + registerMainAPI(EurostreamingProvider()) + } +} \ No newline at end of file diff --git a/IlGenioDelloStreamingProvider/src/main/kotlin/com/lagradost/IlGenioDelloStreamingProvider.kt b/IlGenioDelloStreamingProvider/src/main/kotlin/com/lagradost/IlGenioDelloStreamingProvider.kt index 5d8d417..b747ab4 100644 --- a/IlGenioDelloStreamingProvider/src/main/kotlin/com/lagradost/IlGenioDelloStreamingProvider.kt +++ b/IlGenioDelloStreamingProvider/src/main/kotlin/com/lagradost/IlGenioDelloStreamingProvider.kt @@ -9,6 +9,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ShortLink import com.lagradost.cloudstream3.utils.loadExtractor import org.jsoup.Jsoup +import org.jsoup.nodes.Element class IlGenioDelloStreamingProvider : MainAPI() { @@ -74,7 +75,7 @@ class IlGenioDelloStreamingProvider : MainAPI() { override suspend fun load(url: String): LoadResponse { val page = app.get(url) val document = page.document - val type = if (document.selectFirst("div.sgeneros")?.text() == "Serie TV"){TvType.TvSeries} else{TvType.Movie} + val type = if (document.select("div.seasons-wraper").isNotEmpty()){TvType.TvSeries} else{TvType.Movie} val title = document.selectFirst("div.data > h1")!!.text().substringBefore("(").substringBefore("[") val description = document.selectFirst("div#info")?.selectFirst("p")?.html() val rating = document.select("span.valor").last()?.text()?.split(" ")?.get(0) @@ -104,23 +105,36 @@ class IlGenioDelloStreamingProvider : MainAPI() { if (type == TvType.TvSeries) { val episodeList = ArrayList() - val seasons = document.selectFirst("div#info")?.select("p")?.map {it.children() } - ?.filter { it.size > 1 && it.first()!!.hasAttr("href") } - ?.map{(it.toString().split("
")) - .map{Jsoup.parse(it).select("a") - ?.map { it?.attr("href") }}} - seasons?.mapIndexed { season, element -> - element.mapIndexed { index, list -> - val urls = list?.toJson()?:url - episodeList.add( - Episode( - data = urls, - episode = index + 1, - season = season + 1 - ) - ) + document.selectFirst("div.seasons-wraper") + ?.select("div.accordion-item ")?.groupBy {it.selectFirst("span.season-title")!!.text() }?.map { seasons -> + seasons.value.map {season -> season.select("div.episode-wrap")}.flatten() + .groupBy { it.selectFirst("li.season-no")?.text()?.substringBeforeLast(" ") } + .map { episodeItaSub -> + val episodes = episodeItaSub.value + val posterUrl = episodes.firstNotNullOf { it.selectFirst("img")?.attr("src")} + val epName = episodes.firstNotNullOf{it.selectFirst("li.other_link")?.text()?:""} + + episodes.map{ episode -> + val seasonNo = episode.selectFirst("li.season-no") + val subtag = seasonNo?.text()?.takeIf {it.contains("Sub")}?.substringAfter(" ") ?: "" + val urls = episode.getElementsByAttributeValue("target", "_blank").map { it.attr("href").trim() } + .filter { it.isNotEmpty()}.toJson() + episodeList.add(Episode( + data = urls, + posterUrl = posterUrl, + season = seasons.key.toIntOrNull(), + name = "$epName ${subtag.uppercase()}", + episode = seasonNo?.text()?.substringAfter("x")?.filter { it.isDigit() }?.toIntOrNull() + + )) + } + + + + } } - } + + val seasonnames = document.selectFirst("div#info")?.select("p")?.map {it.children() } ?.filter { it.size<3 && it.isNotEmpty()}?.map{it.text()} diff --git a/TantiFilmProvider/build.gradle.kts b/TantiFilmProvider/build.gradle.kts index 7106ffe..f98a6f1 100644 --- a/TantiFilmProvider/build.gradle.kts +++ b/TantiFilmProvider/build.gradle.kts @@ -16,7 +16,7 @@ cloudstream { * 2: Slow * 3: Beta only * */ - status = 0 // will be 3 if unspecified + status = 1 // will be 3 if unspecified tvTypes = listOf( "TvSeries", "Movie", diff --git a/TantiFilmProvider/src/main/kotlin/com/lagradost/TantiFilmProvider.kt b/TantiFilmProvider/src/main/kotlin/com/lagradost/TantiFilmProvider.kt index f030606..ed1c6e6 100644 --- a/TantiFilmProvider/src/main/kotlin/com/lagradost/TantiFilmProvider.kt +++ b/TantiFilmProvider/src/main/kotlin/com/lagradost/TantiFilmProvider.kt @@ -4,6 +4,7 @@ import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor +import com.lagradost.cloudstream3.network.CloudflareKiller class TantifilmProvider : MainAPI() { @@ -23,23 +24,27 @@ class TantifilmProvider : MainAPI() { Pair("$mainUrl/watch-genre/film-aggiornati/page/", "Ultimi Film Aggiornati"), ) + private val interceptor = CloudflareKiller() + override suspend fun getMainPage( page: Int, - request : MainPageRequest + request: MainPageRequest ): HomePageResponse { val url = request.data + page - val soup = app.get(url).document + val soup = app.get(url, interceptor = interceptor).document val home = soup.select("div.media3").map { val title = it.selectFirst("p")!!.text().substringBefore("(") val link = it.selectFirst("a")!!.attr("href") + val posterUrl = it.selectFirst("img")!!.attr("src") TvSeriesSearchResponse( title, link, this.name, TvType.Movie, - it.selectFirst("img")!!.attr("src"), + posterUrl, null, null, + posterHeaders = interceptor.getCookieHeaders(url).toMap() ) } return newHomePageResponse(request.name, home) @@ -48,7 +53,8 @@ class TantifilmProvider : MainAPI() { override suspend fun search(query: String): List { val queryformatted = query.replace(" ", "+") val url = "$mainUrl/search/$queryformatted" - val doc = app.get(url).document + + val doc = app.get(url, interceptor = interceptor).document return doc.select("div.film.film-2").map { val href = it.selectFirst("a")!!.attr("href") val poster = it.selectFirst("img")!!.attr("src") @@ -59,14 +65,16 @@ class TantifilmProvider : MainAPI() { this.name, TvType.Movie, poster, - null + null, + posterHeaders = interceptor.getCookieHeaders(url).toMap() ) } } override suspend fun load(url: String): LoadResponse { - val document = app.get(url).document + + val document = app.get(url, interceptor = interceptor).document val type = if (document.selectFirst("div.category-film")!!.text().contains("Serie") .not() ) TvType.Movie else TvType.TvSeries @@ -97,7 +105,8 @@ class TantifilmProvider : MainAPI() { this.name, TvType.Movie, poster, - null + null, + posterHeaders = interceptor.getCookieHeaders(url).toMap() ) } @@ -149,6 +158,7 @@ class TantifilmProvider : MainAPI() { this.rating = rating this.recommendations = recomm addTrailer(trailerurl) + this.posterHeaders = interceptor.getCookieHeaders(url).toMap() } } else { val url2 = document.selectFirst("iframe")!!.attr("src") @@ -161,8 +171,8 @@ class TantifilmProvider : MainAPI() { val actors: List? = if (Linkactor.isNotEmpty()) { val actorpage = app.get(Linkactor + "cast/").document - actorpage.select("article.membro-cast").filter { - it -> it.selectFirst("img") + actorpage.select("article.membro-cast").filter { it -> + it.selectFirst("img") ?.attr("src") != "https://www.filmtv.it/imgbank/DUMMY/no_portrait.jpg" }.mapNotNull { val name = it.selectFirst("div.info > h3")!!.text() @@ -209,6 +219,7 @@ class TantifilmProvider : MainAPI() { this.tags = tags this.duration = duratio this.actors = actors + this.posterHeaders = interceptor.getCookieHeaders(url).toMap() addTrailer(trailerurl) } @@ -223,7 +234,7 @@ class TantifilmProvider : MainAPI() { ): Boolean { val doc = app.get(data).document val iframe = - doc.select("option").map { fixUrl(it.attr("value")) }.filter { it.contains("label") } + doc.select("option").map { it.attr("value") }.filter { it.contains("label") } iframe.forEach { id -> val doc2 = app.get(id).document val id2 = app.get(doc2.selectFirst("iframe")!!.attr("src")).url