From 53fa4ca33f253a2918c5c707b3e87ec5b4b93932 Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Sat, 30 Jul 2022 18:56:41 +0200 Subject: [PATCH] made inf scrolling better + fixed search bug --- .../animeproviders/GogoanimeProvider.kt | 86 ++++---- .../movieproviders/AltadefinizioneProvider.kt | 60 +++--- .../movieproviders/CinecalidadProvider.kt | 55 +++-- .../EntrepeliculasyseriesProvider.kt | 71 ++++--- .../movieproviders/FilmpertuttiProvider.kt | 189 +++++++++--------- .../movieproviders/OpenVidsProvider.kt | 1 - .../movieproviders/PeliSmartProvider.kt | 3 +- .../movieproviders/SoaptwoDayProvider.kt | 59 +++--- .../movieproviders/TantiFilmProvider.kt | 70 +++---- .../cloudstream3/utils/SubtitleHelper.kt | 7 +- 10 files changed, 298 insertions(+), 303 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt index e45976d2..b0ce2c7f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt @@ -167,7 +167,7 @@ class GogoanimeProvider : MainAPI() { } } - override var mainUrl = "https://gogoanime.sk" + override var mainUrl = "https://gogoanime.lu" override var name = "GogoAnime" override val hasQuickSearch = false override val hasMainPage = true @@ -178,52 +178,50 @@ class GogoanimeProvider : MainAPI() { TvType.OVA ) - override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { - val headers = mapOf( - "authority" to "ajax.gogo-load.com", - "sec-ch-ua" to "\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\"", - "accept" to "text/html, */*; q=0.01", - "dnt" to "1", - "sec-ch-ua-mobile" to "?0", - "user-agent" to "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36", - "origin" to mainUrl, - "sec-fetch-site" to "cross-site", - "sec-fetch-mode" to "cors", - "sec-fetch-dest" to "empty", - "referer" to "$mainUrl/" - ) - val parseRegex = - Regex("""
  • \s*\n.*\n.*\n.*?img src="(.*?)"""") + val headers = mapOf( + "authority" to "ajax.gogo-load.com", + "sec-ch-ua" to "\"Google Chrome\";v=\"89\", \"Chromium\";v=\"89\", \";Not A Brand\";v=\"99\"", + "accept" to "text/html, */*; q=0.01", + "dnt" to "1", + "sec-ch-ua-mobile" to "?0", + "user-agent" to "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36", + "origin" to mainUrl, + "sec-fetch-site" to "cross-site", + "sec-fetch-mode" to "cors", + "sec-fetch-dest" to "empty", + "referer" to "$mainUrl/" + ) + val parseRegex = + Regex("""
  • \s*\n.*\n.*\n.*?img src="(.*?)"""") - val urls = listOf( - Pair("1", "Recent Release - Sub"), - Pair("2", "Recent Release - Dub"), - Pair("3", "Recent Release - Chinese"), - ) + override val mainPage = mainPageOf( + Pair("1", "Recent Release - Sub"), + Pair("2", "Recent Release - Dub"), + Pair("3", "Recent Release - Chinese"), + ) - val items = ArrayList() - for (i in urls) { - try { - val params = mapOf("page" to "1", "type" to i.first) - val html = app.get( - "https://ajax.gogo-load.com/ajax/page-recent-release.html", - headers = headers, - params = params - ) - items.add(HomePageList(i.second, (parseRegex.findAll(html.text).map { - val (link, epNum, title, poster) = it.destructured - val isSub = listOf(1, 3).contains(i.first.toInt()) - newAnimeSearchResponse(title, link) { - this.posterUrl = poster - addDubStatus(!isSub, epNum.toIntOrNull()) - } - }).toList())) - } catch (e: Exception) { - e.printStackTrace() + override suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse { + val params = mapOf("page" to page.toString(), "type" to categoryData) + val html = app.get( + "https://ajax.gogo-load.com/ajax/page-recent-release.html", + headers = headers, + params = params + ) + val isSub = listOf(1, 3).contains(categoryData.toInt()) + + val home = parseRegex.findAll(html.text).map { + val (link, epNum, title, poster) = it.destructured + newAnimeSearchResponse(title, link) { + this.posterUrl = poster + addDubStatus(!isSub, epNum.toIntOrNull()) } - } - if (items.size <= 0) throw ErrorLoadingException() - return HomePageResponse(items) + }.toList() + + return newHomePageResponse(categoryName, home) } override suspend fun search(query: String): ArrayList { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt index ee393f7f..ba689f97 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt @@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.movieproviders import androidx.core.text.parseAsHtml import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer -import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor @@ -18,40 +17,37 @@ class AltadefinizioneProvider : MainAPI() { TvType.Movie ) - override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { - val items = ArrayList() - val urls = listOf( - Pair("$mainUrl/azione/", "Azione"), - Pair("$mainUrl/avventura/", "Avventura"), - ) - for ((url, name) in urls) { - try { - val soup = app.get(url).document - val home = soup.select("div.box").map { - val title = it.selectFirst("img")!!.attr("alt") - val link = it.selectFirst("a")!!.attr("href") - val image = mainUrl + it.selectFirst("img")!!.attr("src") - val quality = getQualityFromString(it.selectFirst("span")!!.text()) + override val mainPage = mainPageOf( + Pair("$mainUrl/azione/page/", "Azione"), + Pair("$mainUrl/avventura/page/", "Avventura"), + ) - MovieSearchResponse( - title, - link, - this.name, - TvType.Movie, - image, - null, - null, - quality, - ) - } + override suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse { + val url = categoryData + page - items.add(HomePageList(name, home)) - } catch (e: Exception) { - logError(e) - } + val soup = app.get(url).document + val home = soup.select("div.box").map { + val title = it.selectFirst("img")!!.attr("alt") + val link = it.selectFirst("a")!!.attr("href") + val image = mainUrl + it.selectFirst("img")!!.attr("src") + val quality = getQualityFromString(it.selectFirst("span")!!.text()) + + MovieSearchResponse( + title, + link, + this.name, + TvType.Movie, + image, + null, + null, + quality, + ) } - if (items.size <= 0) throw ErrorLoadingException() - return HomePageResponse(items) + return newHomePageResponse(categoryName, home) } override suspend fun search(query: String): List { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt index ff2ad22d..ee60e543 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.movieproviders import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.extractors.Cinestart -import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor @@ -19,39 +18,35 @@ class CinecalidadProvider : MainAPI() { ) override val vpnStatus = VPNStatus.MightBeNeeded //Due to evoload sometimes not loading - override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { - val items = ArrayList() - val urls = listOf( - Pair("$mainUrl/ver-serie/", "Series"), - Pair("$mainUrl/", "Peliculas"), - Pair("$mainUrl/genero-de-la-pelicula/peliculas-en-calidad-4k/", "4K UHD"), - ) + override val mainPage = mainPageOf( + Pair("$mainUrl/ver-serie/page/", "Series"), + Pair("$mainUrl/page/", "Peliculas"), + Pair("$mainUrl/genero-de-la-pelicula/peliculas-en-calidad-4k/page/", "4K UHD"), + ) - for ((url, name) in urls) { - try { - val soup = app.get(url).document - val home = soup.select(".item.movies").map { - val title = it.selectFirst("div.in_title")!!.text() - val link = it.selectFirst("a")!!.attr("href") - TvSeriesSearchResponse( - title, - link, - this.name, - if (link.contains("/ver-pelicula/")) TvType.Movie else TvType.TvSeries, - it.selectFirst(".poster.custom img")!!.attr("data-src"), - null, - null, - ) - } + override suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse { + val url = categoryData + page - items.add(HomePageList(name, home)) - } catch (e: Exception) { - logError(e) - } + val soup = app.get(url).document + val home = soup.select(".item.movies").map { + val title = it.selectFirst("div.in_title")!!.text() + val link = it.selectFirst("a")!!.attr("href") + TvSeriesSearchResponse( + title, + link, + this.name, + if (link.contains("/ver-pelicula/")) TvType.Movie else TvType.TvSeries, + it.selectFirst(".poster.custom img")!!.attr("data-src"), + null, + null, + ) } - if (items.size <= 0) throw ErrorLoadingException() - return HomePageResponse(items) + return newHomePageResponse(categoryName, home) } override suspend fun search(query: String): List { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt index 97921755..a0b82789 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt @@ -1,11 +1,10 @@ package com.lagradost.cloudstream3.movieproviders import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor -class EntrepeliculasyseriesProvider:MainAPI() { +class EntrepeliculasyseriesProvider : MainAPI() { override var mainUrl = "https://entrepeliculasyseries.nu" override var name = "EntrePeliculasySeries" override var lang = "es" @@ -18,39 +17,35 @@ class EntrepeliculasyseriesProvider:MainAPI() { ) override val vpnStatus = VPNStatus.MightBeNeeded //Due to evoload sometimes not loading - override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { - val items = ArrayList() - val urls = listOf( - Pair("$mainUrl/series/", "Series"), - Pair("$mainUrl/peliculas/", "Peliculas"), - Pair("$mainUrl/anime/", "Animes"), - ) + override val mainPage = mainPageOf( + Pair("$mainUrl/series/page/", "Series"), + Pair("$mainUrl/peliculas/page/", "Peliculas"), + Pair("$mainUrl/anime/page/", "Animes"), + ) - for ((url, name) in urls) { - try { - val soup = app.get(url).document - val home = soup.select("ul.list-movie li").map { - val title = it.selectFirst("a.link-title h2")!!.text() - val link = it.selectFirst("a")!!.attr("href") - TvSeriesSearchResponse( - title, - link, - this.name, - if (link.contains("/pelicula/")) TvType.Movie else TvType.TvSeries, - it.selectFirst("a.poster img")!!.attr("src"), - null, - null, - ) - } + override suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse { + val url = categoryData + page - items.add(HomePageList(name, home)) - } catch (e: Exception) { - logError(e) - } + val soup = app.get(url).document + val home = soup.select("ul.list-movie li").map { + val title = it.selectFirst("a.link-title h2")!!.text() + val link = it.selectFirst("a")!!.attr("href") + TvSeriesSearchResponse( + title, + link, + this.name, + if (link.contains("/pelicula/")) TvType.Movie else TvType.TvSeries, + it.selectFirst("a.poster img")!!.attr("src"), + null, + null, + ) } - if (items.size <= 0) throw ErrorLoadingException() - return HomePageResponse(items) + return newHomePageResponse(categoryName, home) } override suspend fun search(query: String): List { @@ -110,7 +105,8 @@ class EntrepeliculasyseriesProvider:MainAPI() { fixUrl(epThumb) ) } - return when (val tvType = if (url.contains("/pelicula/")) TvType.Movie else TvType.TvSeries) { + return when (val tvType = + if (url.contains("/pelicula/")) TvType.Movie else TvType.TvSeries) { TvType.TvSeries -> { TvSeriesLoadResponse( title, @@ -151,8 +147,10 @@ class EntrepeliculasyseriesProvider:MainAPI() { val doc = app.get(servers).document doc.select("input").apmap { val postkey = it.attr("value") - app.post("https://entrepeliculasyseries.nu/r.php", - headers = mapOf("Host" to "entrepeliculasyseries.nu", + app.post( + "https://entrepeliculasyseries.nu/r.php", + headers = mapOf( + "Host" to "entrepeliculasyseries.nu", "User-Agent" to USER_AGENT, "Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", "Accept-Language" to "en-US,en;q=0.5", @@ -165,9 +163,10 @@ class EntrepeliculasyseriesProvider:MainAPI() { "Sec-Fetch-Dest" to "document", "Sec-Fetch-Mode" to "navigate", "Sec-Fetch-Site" to "same-origin", - "Sec-Fetch-User" to "?1",), + "Sec-Fetch-User" to "?1", + ), //params = mapOf(Pair("h", postkey)), - data = mapOf(Pair("h", postkey)), + data = mapOf(Pair("h", postkey)), allowRedirects = false ).okhttpResponse.headers.values("location").apmap { loadExtractor(it, data, subtitleCallback, callback) diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmpertuttiProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmpertuttiProvider.kt index bce4e955..3f14622b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmpertuttiProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmpertuttiProvider.kt @@ -1,13 +1,13 @@ package com.lagradost.cloudstream3.movieproviders + import androidx.core.text.parseAsHtml import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.mvvm.logError -import com.lagradost.cloudstream3.app -import com.lagradost.cloudstream3.utils.* -import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.LoadResponse.Companion.addRating +import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.nicehttp.NiceResponse import org.jsoup.nodes.Element @@ -23,42 +23,41 @@ class FilmpertuttiProvider : MainAPI() { TvType.TvSeries ) - override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { - val items = ArrayList() - val urls = listOf( - Pair("$mainUrl/category/serie-tv/", "Serie Tv"), - Pair("$mainUrl/category/film/azione/", "Azione"), - Pair("$mainUrl/category/film/avventura/", "Avventura"), - ) - for ((url, name) in urls) { - try { - val soup = app.get(url).document - val home = soup.select("ul.posts > li").map { - val title = it.selectFirst("div.title")!!.text().substringBeforeLast("(").substringBeforeLast("[") - val link = it.selectFirst("a")!!.attr("href") - val image = it.selectFirst("a")!!.attr("data-thumbnail") - val qualitydata = it.selectFirst("div.hd") - val quality = if (qualitydata!= null) { - getQualityFromString(qualitydata?.text()) - } - else { - null - } - newTvSeriesSearchResponse( - title, - link) { - this.posterUrl = image - this.quality = quality - } - } + override val mainPage = mainPageOf( + Pair("$mainUrl/category/serie-tv/page/", "Serie Tv"), + Pair("$mainUrl/category/film/azione/page/", "Azione"), + Pair("$mainUrl/category/film/avventura/page/", "Avventura"), + ) - items.add(HomePageList(name, home)) - } catch (e: Exception) { - logError(e) + override suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse { + val url = categoryData + page + + val soup = app.get(url).document + val home = soup.select("ul.posts > li").map { + val title = it.selectFirst("div.title")!!.text().substringBeforeLast("(") + .substringBeforeLast("[") + val link = it.selectFirst("a")!!.attr("href") + val image = it.selectFirst("a")!!.attr("data-thumbnail") + val qualitydata = it.selectFirst("div.hd") + val quality = if (qualitydata != null) { + getQualityFromString(qualitydata.text()) + } else { + null + } + newTvSeriesSearchResponse( + title, + link + ) { + this.posterUrl = image + this.quality = quality } } - if (items.size <= 0) throw ErrorLoadingException() - return HomePageResponse(items) + + return newHomePageResponse(categoryName, home) } override suspend fun search(query: String): List { @@ -66,7 +65,8 @@ class FilmpertuttiProvider : MainAPI() { val url = "$mainUrl/?s=$queryformatted" val doc = app.get(url).document return doc.select("ul.posts > li").map { - val title = it.selectFirst("div.title")!!.text().substringBeforeLast("(").substringBeforeLast("[") + val title = it.selectFirst("div.title")!!.text().substringBeforeLast("(") + .substringBeforeLast("[") val link = it.selectFirst("a")!!.attr("href") val image = it.selectFirst("a")!!.attr("data-thumbnail") val quality = getQualityFromString(it.selectFirst("div.hd")?.text()) @@ -90,50 +90,58 @@ class FilmpertuttiProvider : MainAPI() { val title = document.selectFirst("#content > h1")!!.text().substringBeforeLast("(") .substringBeforeLast("[") - val description = document.selectFirst("i.fa.fa-file-text-o.fa-fw")?.parent()?.nextSibling()?.toString()?.parseAsHtml().toString() + val description = + document.selectFirst("i.fa.fa-file-text-o.fa-fw")?.parent()?.nextSibling()?.toString() + ?.parseAsHtml().toString() val rating = document.selectFirst("div.rating > div.value")?.text() val year = - document.selectFirst("#content > h1")?.text()?.substringAfterLast("(")?.filter { it.isDigit() }?.toIntOrNull() ?: - description.substringAfter("trasmessa nel").take(6).filter { it.isDigit() }.toIntOrNull() ?: - (document.selectFirst("i.fa.fa-calendar.fa-fw")?.parent()?.nextSibling() as Element?)?.text()?.substringAfterLast(" ")?.filter { it.isDigit() }?.toIntOrNull() + document.selectFirst("#content > h1")?.text()?.substringAfterLast("(") + ?.filter { it.isDigit() }?.toIntOrNull() + ?: description.substringAfter("trasmessa nel").take(6).filter { it.isDigit() } + .toIntOrNull() ?: (document.selectFirst("i.fa.fa-calendar.fa-fw")?.parent() + ?.nextSibling() as Element?)?.text()?.substringAfterLast(" ") + ?.filter { it.isDigit() }?.toIntOrNull() val poster = document.selectFirst("div.meta > div > img")?.attr("data-src") - val trailerurl = document.selectFirst("div.youtube-player")?.attr("data-id")?.let{ urldata-> - "https://www.youtube.com/watch?v=$urldata" - } + val trailerurl = + document.selectFirst("div.youtube-player")?.attr("data-id")?.let { urldata -> + "https://www.youtube.com/watch?v=$urldata" + } if (type == TvType.TvSeries) { val episodeList = ArrayList() - document.select("div.accordion-item").filter{it.selectFirst("#season > ul > li.s_title > span")!!.text().isNotEmpty()}.map { element -> - val season = - element.selectFirst("#season > ul > li.s_title > span")!!.text().toInt() - element.select("div.episode-wrap").map { episode -> - val href = - episode.select("#links > div > div > table > tbody:nth-child(2) > tr") - .map { it.selectFirst("a")!!.attr("href") }.toJson() - val epNum = episode.selectFirst("li.season-no")!!.text().substringAfter("x") - .filter { it.isDigit() }.toIntOrNull() - val epTitle = episode.selectFirst("li.other_link > a")?.text() + document.select("div.accordion-item") + .filter { it.selectFirst("#season > ul > li.s_title > span")!!.text().isNotEmpty() } + .map { element -> + val season = + element.selectFirst("#season > ul > li.s_title > span")!!.text().toInt() + element.select("div.episode-wrap").map { episode -> + val href = + episode.select("#links > div > div > table > tbody:nth-child(2) > tr") + .map { it.selectFirst("a")!!.attr("href") }.toJson() + val epNum = episode.selectFirst("li.season-no")!!.text().substringAfter("x") + .filter { it.isDigit() }.toIntOrNull() + val epTitle = episode.selectFirst("li.other_link > a")?.text() - val posterUrl = episode.selectFirst("figure > img")?.attr("data-src") - episodeList.add( - Episode( - href, - epTitle, - season, - epNum, - posterUrl, + val posterUrl = episode.selectFirst("figure > img")?.attr("data-src") + episodeList.add( + Episode( + href, + epTitle, + season, + epNum, + posterUrl, + ) ) - ) + } } - } return newTvSeriesLoadResponse( title, url, type, episodeList @@ -147,10 +155,12 @@ class FilmpertuttiProvider : MainAPI() { } else { val urls0 = document.select("div.embed-player") - val urls = if (urls0.isNotEmpty()){ - urls0.map { it.attr("data-id") }.toJson() - } - else{ document.select("#info > ul > li ").mapNotNull { it.selectFirst("a")?.attr("href") }.toJson() } + val urls = if (urls0.isNotEmpty()) { + urls0.map { it.attr("data-id") }.toJson() + } else { + document.select("#info > ul > li ").mapNotNull { it.selectFirst("a")?.attr("href") } + .toJson() + } return newMovieLoadResponse( title, @@ -168,46 +178,49 @@ class FilmpertuttiProvider : MainAPI() { } } -// to be updated when UnshortenUrl is ready + // to be updated when UnshortenUrl is ready suspend fun unshorten_linkup(uri: String): String { var r: NiceResponse? = null var uri = uri - when{ + when { uri.contains("/tv/") -> uri = uri.replace("/tv/", "/tva/") uri.contains("delta") -> uri = uri.replace("/delta/", "/adelta/") - (uri.contains("/ga/") || uri.contains("/ga2/")) -> uri = base64Decode(uri.split('/').last()).trim() - uri.contains("/speedx/") -> uri = uri.replace("http://linkup.pro/speedx", "http://speedvideo.net") + (uri.contains("/ga/") || uri.contains("/ga2/")) -> uri = + base64Decode(uri.split('/').last()).trim() + uri.contains("/speedx/") -> uri = + uri.replace("http://linkup.pro/speedx", "http://speedvideo.net") else -> { r = app.get(uri, allowRedirects = true) uri = r.url val link = - Regex("]*src=\\'([^'>]*)\\'[^<>]*>").find(r.text)?.value ?: - Regex("""action="(?:[^/]+.*?/[^/]+/([a-zA-Z0-9_]+))">""").find(r.text)?.value ?: - Regex("""href","((.|\\n)*?)"""").findAll(r.text).elementAtOrNull(1)?.groupValues?.get(1) + Regex("]*src=\\'([^'>]*)\\'[^<>]*>").find(r.text)?.value + ?: Regex("""action="(?:[^/]+.*?/[^/]+/([a-zA-Z0-9_]+))">""").find(r.text)?.value + ?: Regex("""href","((.|\\n)*?)"""").findAll(r.text) + .elementAtOrNull(1)?.groupValues?.get(1) - if (link!=null) { + if (link != null) { uri = link } } } val short = Regex("""^https?://.*?(https?://.*)""").find(uri)?.value - if (short!=null){ + if (short != null) { uri = short } - if (r==null){ + if (r == null) { r = app.get( uri, - allowRedirects = false) - if (r.headers["location"]!= null){ + allowRedirects = false + ) + if (r.headers["location"] != null) { uri = r.headers["location"].toString() } } if (uri.contains("snip.")) { if (uri.contains("out_generator")) { uri = Regex("url=(.*)\$").find(uri)!!.value - } - else if (uri.contains("/decode/")) { + } else if (uri.contains("/decode/")) { uri = app.get(uri, allowRedirects = true).url } } @@ -222,16 +235,14 @@ class FilmpertuttiProvider : MainAPI() { callback: (ExtractorLink) -> Unit ): Boolean { tryParseJson>(data)?.apmap { id -> - if (id.contains("buckler")){ - val id2 = unshorten_linkup(id).trim().replace("/v/","/e/").replace("/f/","/e/") + if (id.contains("buckler")) { + val id2 = unshorten_linkup(id).trim().replace("/v/", "/e/").replace("/f/", "/e/") loadExtractor(id2, data, subtitleCallback, callback) - } - else if (id.contains("isecure")){ + } else if (id.contains("isecure")) { val doc1 = app.get(id).document val id2 = doc1.selectFirst("iframe")!!.attr("src") loadExtractor(id2, data, subtitleCallback, callback) - } - else{ + } else { loadExtractor(id, data, subtitleCallback, callback) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/OpenVidsProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/OpenVidsProvider.kt index 569aef26..3e00011a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/OpenVidsProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/OpenVidsProvider.kt @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.movieproviders import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.animeproviders.GogoanimeProvider import com.lagradost.cloudstream3.animeproviders.GogoanimeProvider.Companion.extractVidstream import com.lagradost.cloudstream3.metaproviders.TmdbLink import com.lagradost.cloudstream3.metaproviders.TmdbProvider diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt index 1cb5e0d0..7ef4a441 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt @@ -25,7 +25,8 @@ class PeliSmartProvider: MainAPI() { Pair("$mainUrl/documentales/", "Documentales"), ) - for ((url, name) in urls) { + // has no inf loading + urls.apmap { (url, name) -> try { val soup = app.get(url).document val home = soup.select(".description-off").map { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt index 38c60be8..85687616 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.movieproviders import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.utils.AppUtils.parseJson import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.Qualities @@ -19,37 +18,35 @@ class SoaptwoDayProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { - val items = ArrayList() - val urls = listOf( - Pair("$mainUrl/movielist/", "Movies"), - Pair("$mainUrl/tvlist/", "TV Series"), - ) - for ((url, name) in urls) { - try { - val soup = app.get(url).document - val home = - soup.select("div.container div.row div.col-sm-12.col-lg-12 div.row div.col-sm-12.col-lg-12 .col-xs-6") - .map { - val title = it.selectFirst("h5 a")!!.text() - val link = it.selectFirst("a")!!.attr("href") - TvSeriesSearchResponse( - title, - link, - this.name, - TvType.TvSeries, - fixUrl(it.selectFirst("img")!!.attr("src")), - null, - null, - ) - } + override val mainPage = mainPageOf( + Pair("$mainUrl/movielist?page=", "Movies"), + Pair("$mainUrl/tvlist?page=", "TV Series"), + ) - items.add(HomePageList(name, home)) - } catch (e: Exception) { - logError(e) - } - } - return HomePageResponse(items) + override suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse { + val url = categoryData + page + + val soup = app.get(url).document + val home = + soup.select("div.container div.row div.col-sm-12.col-lg-12 div.row div.col-sm-12.col-lg-12 .col-xs-6") + .map { + val title = it.selectFirst("h5 a")!!.text() + val link = it.selectFirst("a")!!.attr("href") + TvSeriesSearchResponse( + title, + link, + this.name, + TvType.TvSeries, + fixUrl(it.selectFirst("img")!!.attr("src")), + null, + null, + ) + } + return newHomePageResponse(categoryName, home) } override suspend fun search(query: String): List { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt index 711b6895..e84e6ddf 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt @@ -1,10 +1,9 @@ package com.lagradost.cloudstream3.movieproviders import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.mvvm.logError -import com.lagradost.cloudstream3.app -import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.loadExtractor class TantifilmProvider : MainAPI() { @@ -18,37 +17,33 @@ class TantifilmProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { - val items = ArrayList() - val urls = listOf( - Pair("$mainUrl/watch-genre/serie-tv/", "Serie Tv"), - Pair("$mainUrl/watch-genre/azione/", "Azione"), - Pair("$mainUrl/watch-genre/avventura/", "Avventura"), - ) - for ((url, name) in urls) { - try { - val soup = app.get(url).document - val home = soup.select("div.media3").map { - val title = it.selectFirst("p")!!.text().substringBefore("(") - val link = it.selectFirst("a")!!.attr("href") - TvSeriesSearchResponse( - title, - link, - this.name, - TvType.Movie, - it.selectFirst("img")!!.attr("src"), - null, - null, - ) - } + override val mainPage = mainPageOf( + Pair("$mainUrl/watch-genre/serie-tv/page/", "Serie Tv"), + Pair("$mainUrl/watch-genre/azione/page/", "Azione"), + Pair("$mainUrl/watch-genre/avventura/page/", "Avventura"), + ) - items.add(HomePageList(name, home)) - } catch (e: Exception) { - logError(e) - } + override suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse { + val url = categoryData + page + val soup = app.get(url).document + val home = soup.select("div.media3").map { + val title = it.selectFirst("p")!!.text().substringBefore("(") + val link = it.selectFirst("a")!!.attr("href") + TvSeriesSearchResponse( + title, + link, + this.name, + TvType.Movie, + it.selectFirst("img")!!.attr("src"), + null, + null, + ) } - if (items.size <= 0) throw ErrorLoadingException() - return HomePageResponse(items) + return newHomePageResponse(categoryName, home) } override suspend fun search(query: String): List { @@ -125,7 +120,7 @@ class TantifilmProvider : MainAPI() { val episodeList = ArrayList() - for ((season,seasonurl) in list) { + for ((season, seasonurl) in list) { val seasonDocument = app.get(seasonurl).document val episodes = seasonDocument.select("nav.second_nav > select > option") if (episodes.isNotEmpty()) { @@ -147,11 +142,12 @@ class TantifilmProvider : MainAPI() { title, url, type, - episodeList) { - this.posterUrl= fixUrlNull(poster) + episodeList + ) { + this.posterUrl = fixUrlNull(poster) this.year = year.toIntOrNull() - this.plot= descipt[0] - this.rating= rating + this.plot = descipt[0] + this.rating = rating this.recommendations = recomm addTrailer(trailerurl) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleHelper.kt index 12236aad..0d761560 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/SubtitleHelper.kt @@ -119,8 +119,10 @@ object SubtitleHelper { private val flagRegex = Regex("[\uD83C\uDDE6-\uD83C\uDDFF]{2}") fun getFlagFromIso(inp: String?): String? { + if (inp.isNullOrBlank() || inp.length < 2) return null + try { - val ret = getFlagFromIsoShort(flags[inp ?: return null]) + val ret = getFlagFromIsoShort(flags[inp]) ?: getFlagFromIsoShort(inp.uppercase()) ?: return null return if (flagRegex.matches(ret)) { @@ -135,8 +137,9 @@ object SubtitleHelper { } private fun getFlagFromIsoShort(flagAscii: String?): String? { + if (flagAscii.isNullOrBlank() || flagAscii.length < 2) return null try { - val firstChar: Int = Character.codePointAt(flagAscii ?: return null, 0) + offset + val firstChar: Int = Character.codePointAt(flagAscii, 0) + offset val secondChar: Int = Character.codePointAt(flagAscii, 1) + offset return (String(Character.toChars(firstChar)) + String(Character.toChars(secondChar)))