From 8aa907d1d95a9e65a64871f7dfc20fd9859f9099 Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Thu, 3 Mar 2022 12:26:26 +0100 Subject: [PATCH] moved to List + animations --- .../lagradost/cloudstream3/MainActivity.kt | 46 +++++ .../animeproviders/AnimePaheProvider.kt | 6 +- .../animeproviders/AnimeflvProvider.kt | 7 +- .../animeproviders/DubbedAnimeProvider.kt | 81 ++++----- .../animeproviders/TenshiProvider.kt | 10 +- .../animeproviders/WcoProvider.kt | 83 ++++----- .../movieproviders/AllMoviesForYouProvider.kt | 26 ++- .../movieproviders/DoramasYTProvider.kt | 37 ++-- .../movieproviders/FilmanProvider.kt | 57 +++--- .../movieproviders/HDMProvider.kt | 12 +- .../movieproviders/LookMovieProvider.kt | 27 ++- .../movieproviders/french-stream.kt | 6 +- .../main/res/navigation/mobile_navigation.xml | 165 ++++++++++-------- 13 files changed, 296 insertions(+), 267 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index f81f9965..9ec6df47 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -6,10 +6,17 @@ import android.content.res.ColorStateList import android.content.res.Configuration import android.os.Bundle import android.view.KeyEvent +import android.view.Menu +import android.view.MenuItem import android.view.WindowManager +import androidx.annotation.IdRes import androidx.appcompat.app.AppCompatActivity import androidx.core.view.isVisible +import androidx.navigation.NavController import androidx.navigation.NavDestination +import androidx.navigation.NavDestination.Companion.hierarchy +import androidx.navigation.NavGraph.Companion.findStartDestination +import androidx.navigation.NavOptions import androidx.navigation.findNavController import androidx.navigation.ui.setupWithNavController import androidx.preference.PreferenceManager @@ -270,6 +277,31 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { } } + private fun NavDestination.matchDestination(@IdRes destId: Int): Boolean = + hierarchy.any { it.id == destId } + + private fun onNavDestinationSelected(item: MenuItem, navController: NavController): Boolean { + val builder = NavOptions.Builder().setLaunchSingleTop(true).setRestoreState(true) + .setEnterAnim(R.anim.enter_anim) + .setExitAnim(R.anim.exit_anim) + .setPopEnterAnim(R.anim.pop_enter) + .setPopExitAnim(R.anim.pop_exit) + if (item.order and Menu.CATEGORY_SECONDARY == 0) { + builder.setPopUpTo( + navController.graph.findStartDestination().id, + inclusive = false, + saveState = true + ) + } + val options = builder.build() + return try { + navController.navigate(item.itemId, null, options) + navController.currentDestination?.matchDestination(item.itemId) == true + } catch (e: IllegalArgumentException) { + false + } + } + override fun onCreate(savedInstanceState: Bundle?) { // init accounts for (api in OAuth2accountApis) { @@ -315,9 +347,23 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { nav_view?.setupWithNavController(navController) val navRail = findViewById(R.id.nav_rail_view) navRail?.setupWithNavController(navController) + + navRail?.setOnItemSelectedListener { item -> + onNavDestinationSelected( + item, + navController + ) + } + nav_view?.setOnItemSelectedListener { item -> + onNavDestinationSelected( + item, + navController + ) + } navController.addOnDestinationChangedListener { _, destination, _ -> updateNavBar(destination) } + loadCache() /*nav_view.setOnNavigationItemSelectedListener { item -> diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimePaheProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimePaheProvider.kt index 2b78ccc6..ed239b14 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimePaheProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimePaheProvider.kt @@ -140,14 +140,14 @@ class AnimePaheProvider : MainAPI() { } - override suspend fun search(query: String): ArrayList { + override suspend fun search(query: String): List { val url = "$mainUrl/api?m=search&l=8&q=$query" val headers = mapOf("referer" to "$mainUrl/") val req = app.get(url, headers = headers).text val data = req.let { mapper.readValue(it) } - return ArrayList(data.data.map { + return data.data.map { AnimeSearchResponse( it.title, "https://pahe.win/a/${it.id}?slug=${it.title}", @@ -160,7 +160,7 @@ class AnimePaheProvider : MainAPI() { null, it.episodes ) - }) + } } private data class AnimeData( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt index b8209e91..f40b4f9a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt @@ -4,7 +4,6 @@ import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor import java.util.* -import kotlin.collections.ArrayList class AnimeflvnetProvider : MainAPI() { companion object { @@ -63,11 +62,10 @@ class AnimeflvnetProvider : MainAPI() { return HomePageResponse(items) } - override suspend fun search(query: String): ArrayList { - + override suspend fun search(query: String): List { val url = "${mainUrl}/browse?q=${query}" val doc = app.get(url).document - val episodes = doc.select("ul.List-Animes li.Anime").map { + return doc.select("ul.List-Animes li.Anime").map { val title = it.selectFirst("h2.title").text() val href = fixUrl(it.selectFirst("a").attr("href")) val image = it.selectFirst(".Image img").attr("src") @@ -83,7 +81,6 @@ class AnimeflvnetProvider : MainAPI() { ), ) } - return ArrayList(episodes) } override suspend fun load(url: String): LoadResponse { diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt index 893d83b6..d6a4760f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt @@ -73,7 +73,10 @@ class DubbedAnimeProvider : MainAPI() { } } - private suspend fun parseDocument(url: String, trimEpisode: Boolean = false): List { + private suspend fun parseDocument( + url: String, + trimEpisode: Boolean = false + ): List { val response = app.get(url).text val document = Jsoup.parse(response) return document.select("a.grid__link").map { @@ -131,31 +134,28 @@ class DubbedAnimeProvider : MainAPI() { val response = app.get(url).text val document = Jsoup.parse(response) val items = document.select("div.grid__item > a") - if (items.isEmpty()) return ArrayList() - val returnValue = ArrayList() - for (i in items) { + if (items.isEmpty()) return emptyList() + return items.map { i -> val href = fixUrl(i.attr("href")) val title = i.selectFirst("div.gridtitlek").text() val img = fixUrlNull(i.selectFirst("img.grid__img")?.attr("src")) - returnValue.add( - if (getIsMovie(href)) { - MovieSearchResponse( - title, href, this.name, TvType.AnimeMovie, img, null - ) - } else { - AnimeSearchResponse( - title, - href, - this.name, - TvType.Anime, - img, - null, - EnumSet.of(DubStatus.Dubbed), - ) - } - ) + + if (getIsMovie(href)) { + MovieSearchResponse( + title, href, this.name, TvType.AnimeMovie, img, null + ) + } else { + AnimeSearchResponse( + title, + href, + this.name, + TvType.Anime, + img, + null, + EnumSet.of(DubStatus.Dubbed), + ) + } } - return returnValue } override suspend fun search(query: String): List { @@ -164,33 +164,28 @@ class DubbedAnimeProvider : MainAPI() { val document = Jsoup.parse(response) val items = document.select("div.resultinner > a.resulta") if (items.isEmpty()) return ArrayList() - val returnValue = ArrayList() - for (i in items) { + return items.map { i -> val innerDiv = i.selectFirst("> div.result") val href = fixUrl(i.attr("href")) val img = fixUrl(innerDiv.selectFirst("> div.imgkz > img").attr("src")) val title = innerDiv.selectFirst("> div.titleresults").text() - returnValue.add( - if (getIsMovie(href)) { - MovieSearchResponse( - title, href, this.name, TvType.AnimeMovie, img, null - ) - } else { - AnimeSearchResponse( - title, - href, - this.name, - TvType.Anime, - img, - null, - EnumSet.of(DubStatus.Dubbed), - ) - } - ) + if (getIsMovie(href)) { + MovieSearchResponse( + title, href, this.name, TvType.AnimeMovie, img, null + ) + } else { + AnimeSearchResponse( + title, + href, + this.name, + TvType.Anime, + img, + null, + EnumSet.of(DubStatus.Dubbed), + ) + } } - - return returnValue } override suspend fun loadLinks( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt index 40b2f87b..d17a6d23 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt @@ -191,7 +191,7 @@ class TenshiProvider : MainAPI() { // return returnValue // } - override suspend fun search(query: String): ArrayList { + override suspend fun search(query: String): List { val url = "$mainUrl/anime" var document = app.get( url, @@ -203,10 +203,10 @@ class TenshiProvider : MainAPI() { val returnValue = parseSearchPage(document).toMutableList() while (!document.select("""a.page-link[rel="next"]""").isEmpty()) { - val link = document.select("""a.page-link[rel="next"]""") - if (link != null && !link.isEmpty()) { + val link = document.selectFirst("""a.page-link[rel="next"]""")?.attr("href") + if (!link.isNullOrBlank()) { document = app.get( - link[0].attr("href"), + link, cookies = mapOf("loop-view" to "thumb"), interceptor = ddosGuardKiller ).document @@ -216,7 +216,7 @@ class TenshiProvider : MainAPI() { } } - return ArrayList(returnValue) + return returnValue } override suspend fun load(url: String): LoadResponse { diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/WcoProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/WcoProvider.kt index c461e560..77f913fd 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/WcoProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/WcoProvider.kt @@ -79,11 +79,10 @@ class WcoProvider : MainAPI() { return "$mainUrl/anime/$aniId" } - private fun parseSearchPage(soup: Document): ArrayList { + private fun parseSearchPage(soup: Document): List { val items = soup.select(".film_list-wrap > .flw-item") if (items.isEmpty()) return ArrayList() - val returnValue = ArrayList() - for (i in items) { + return items.map { i -> val href = fixAnimeLink(i.selectFirst("a").attr("href")) val img = fixUrl(i.selectFirst("img").attr("data-src")) val title = i.selectFirst("img").attr("title") @@ -94,25 +93,22 @@ class WcoProvider : MainAPI() { val type = i.selectFirst(".film-detail.film-detail-fix > div > span:nth-child(3)").text() - returnValue.add( - if (getType(type) == TvType.AnimeMovie) { - MovieSearchResponse( - title, href, this.name, TvType.AnimeMovie, img, year - ) - } else { - AnimeSearchResponse( - title, - href, - this.name, - TvType.Anime, - img, - year, - EnumSet.of(if (isDub) DubStatus.Dubbed else DubStatus.Subbed), - ) - } - ) + if (getType(type) == TvType.AnimeMovie) { + MovieSearchResponse( + title, href, this.name, TvType.AnimeMovie, img, year + ) + } else { + AnimeSearchResponse( + title, + href, + this.name, + TvType.Anime, + img, + year, + EnumSet.of(if (isDub) DubStatus.Dubbed else DubStatus.Subbed), + ) + } } - return returnValue } override suspend fun search(query: String): List { @@ -120,7 +116,7 @@ class WcoProvider : MainAPI() { val response = app.get(url, params = mapOf("keyword" to query)) var document = Jsoup.parse(response.text) - val returnValue = parseSearchPage(document) + val returnValue = parseSearchPage(document).toMutableList() while (!document.select(".pagination").isEmpty()) { val link = document.select("a.page-link[rel=\"next\"]") @@ -136,8 +132,6 @@ class WcoProvider : MainAPI() { } override suspend fun quickSearch(query: String): List { - val returnValue: ArrayList = ArrayList() - val response = JSONObject( app.post( "https://wcostream.cc/ajax/search", @@ -146,35 +140,30 @@ class WcoProvider : MainAPI() { ).getString("html") // I won't make a dataclass for this shit val document = Jsoup.parse(response) - document.select("a.nav-item").forEach { - val title = it.selectFirst("img")?.attr("title").toString() - val img = it?.selectFirst("img")?.attr("src") - val href = it?.attr("href").toString() + return document.select("a.nav-item").mapNotNull { + val title = it.selectFirst("img")?.attr("title") ?: return@mapNotNull null + val img = it?.selectFirst("img")?.attr("src") ?: return@mapNotNull null + val href = it?.attr("href") ?: return@mapNotNull null val isDub = title.contains("(Dub)") - val filmInfo = it?.selectFirst(".film-infor") + val filmInfo = it.selectFirst(".film-infor") val year = filmInfo?.select("span")?.get(0)?.text()?.toIntOrNull() val type = filmInfo?.select("span")?.get(1)?.text().toString() - if (title != "null") { - returnValue.add( - if (getType(type) == TvType.AnimeMovie) { - MovieSearchResponse( - title, href, this.name, TvType.AnimeMovie, img, year - ) - } else { - AnimeSearchResponse( - title, - href, - this.name, - TvType.Anime, - img, - year, - EnumSet.of(if (isDub) DubStatus.Dubbed else DubStatus.Subbed), - ) - } + if (getType(type) == TvType.AnimeMovie) { + MovieSearchResponse( + title, href, this.name, TvType.AnimeMovie, img, year + ) + } else { + AnimeSearchResponse( + title, + href, + this.name, + TvType.Anime, + img, + year, + EnumSet.of(if (isDub) DubStatus.Dubbed else DubStatus.Subbed), ) } } - return returnValue } override suspend fun load(url: String): LoadResponse { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt index 5e0f538f..9deb4e05 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt @@ -37,29 +37,25 @@ class AllMoviesForYouProvider : MainAPI() { val document = app.get(url).document val items = document.select("ul.MovieList > li > article > a") - val returnValue = ArrayList() - for (item in items) { + return items.map { item -> val href = item.attr("href") val title = item.selectFirst("> h2.Title").text() val img = fixUrl(item.selectFirst("> div.Image > figure > img").attr("data-src")) val type = getType(href) if (type == TvType.Movie) { - returnValue.add(MovieSearchResponse(title, href, this.name, type, img, null)) - } else if (type == TvType.TvSeries) { - returnValue.add( - TvSeriesSearchResponse( - title, - href, - this.name, - type, - img, - null, - null - ) + MovieSearchResponse(title, href, this.name, type, img, null) + } else { + TvSeriesSearchResponse( + title, + href, + this.name, + type, + img, + null, + null ) } } - return returnValue } private fun getLink(document: Document): List? { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt index 1c1c0d1a..9a621b6d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt @@ -5,7 +5,6 @@ import com.lagradost.cloudstream3.extractors.FEmbed import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.loadExtractor import java.util.* -import kotlin.collections.ArrayList class DoramasYTProvider : MainAPI() { @@ -99,25 +98,23 @@ class DoramasYTProvider : MainAPI() { return HomePageResponse(items) } - override suspend fun search(query: String): ArrayList { - val search = - app.get("$mainUrl/buscar?q=$query", timeout = 120).document.select(".col-6").map { - val title = it.selectFirst(".animedtls p").text() - val href = it.selectFirst("a").attr("href") - val image = it.selectFirst(".animes img").attr("src") - AnimeSearchResponse( - title, - href, - this.name, - TvType.Anime, - image, - null, - if (title.contains("Latino") || title.contains("Castellano")) EnumSet.of( - DubStatus.Dubbed - ) else EnumSet.of(DubStatus.Subbed), - ) - } - return ArrayList(search) + override suspend fun search(query: String): List { + return app.get("$mainUrl/buscar?q=$query", timeout = 120).document.select(".col-6").map { + val title = it.selectFirst(".animedtls p").text() + val href = it.selectFirst("a").attr("href") + val image = it.selectFirst(".animes img").attr("src") + AnimeSearchResponse( + title, + href, + this.name, + TvType.Anime, + image, + null, + if (title.contains("Latino") || title.contains("Castellano")) EnumSet.of( + DubStatus.Dubbed + ) else EnumSet.of(DubStatus.Subbed), + ) + } } override suspend fun load(url: String): LoadResponse { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt index 4164f545..68e60dba 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt @@ -25,13 +25,12 @@ class FilmanProvider : MainAPI() { val categories = ArrayList() for (l in lists) { val title = l.parent().select("h3").text() - val items = ArrayList() - for (i in l.select(".poster")) { + val items = l.select(".poster").map { i -> 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() - val returnValue = if (l.hasClass("series-list")) TvSeriesSearchResponse( + if (l.hasClass("series-list")) TvSeriesSearchResponse( name, href, this.name, @@ -47,7 +46,6 @@ class FilmanProvider : MainAPI() { poster, year ) - items.add(returnValue) } categories.add(HomePageList(title, items)) } @@ -62,29 +60,25 @@ class FilmanProvider : MainAPI() { val movies = lists[1].select(".item") val series = lists[3].select(".item") if (movies.isEmpty() && series.isEmpty()) return ArrayList() - fun getVideos(type: TvType, items: Elements): ArrayList { - val returnValue = ArrayList() - for (i in items) { + fun getVideos(type: TvType, items: Elements): List { + return items.map { i -> val href = i.attr("href") val img = i.selectFirst("> img").attr("src").replace("/thumb/", "/big/") val name = i.selectFirst(".title").text() if (type === TvType.TvSeries) { - returnValue.add( - TvSeriesSearchResponse( - name, - href, - this.name, - type, - img, - null, - null - ) + TvSeriesSearchResponse( + name, + href, + this.name, + type, + img, + null, + null ) } else { - returnValue.add(MovieSearchResponse(name, href, this.name, type, img, null)) + MovieSearchResponse(name, href, this.name, type, img, null) } } - return returnValue } return getVideos(TvType.Movie, movies) + getVideos(TvType.TvSeries, series) } @@ -102,22 +96,17 @@ class FilmanProvider : MainAPI() { return MovieLoadResponse(title, url, name, TvType.Movie, data, posterUrl, year, plot) } title = document.selectFirst(".info").parent().select("h2").text() - val episodes = ArrayList() - for (episode in episodesElements) { + val episodes = episodesElements.mapNotNull { episode -> val e = episode.text() - val regex = Regex("""\[s(\d{1,3})e(\d{1,3})]""").find(e) - if (regex != null) { - val eid = regex.groups - episodes.add( - TvSeriesEpisode( - e.split("]")[1].trim(), - eid[1]?.value?.toInt(), - eid[2]?.value?.toInt(), - episode.attr("href"), - ) - ) - } - } + val regex = Regex("""\[s(\d{1,3})e(\d{1,3})]""").find(e) ?: return@mapNotNull null + val eid = regex.groups + TvSeriesEpisode( + e.split("]")[1].trim(), + eid[1]?.value?.toInt(), + eid[2]?.value?.toInt(), + episode.attr("href"), + ) + }.toMutableList() episodes.sortBy { (it.season?.times(10000) ?: 0) + (it.episode ?: 0) } return TvSeriesLoadResponse( title, diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMProvider.kt index 009372d8..cf57cceb 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMProvider.kt @@ -19,17 +19,15 @@ class HDMProvider : MainAPI() { val response = app.get(url).text val document = Jsoup.parse(response) val items = document.select("div.col-md-2 > article > a") - if (items.isEmpty()) return ArrayList() - val returnValue = ArrayList() - for (i in items) { + if (items.isEmpty()) return emptyList() + + return items.map { i -> val href = i.attr("href") val data = i.selectFirst("> div.item") val img = data.selectFirst("> img").attr("src") val name = data.selectFirst("> div.movie-details").text() - returnValue.add(MovieSearchResponse(name, href, this.name, TvType.Movie, img, null)) + MovieSearchResponse(name, href, this.name, TvType.Movie, img, null) } - - return returnValue } override suspend fun loadLinks( @@ -72,7 +70,7 @@ class HDMProvider : MainAPI() { } override suspend fun getMainPage(): HomePageResponse { - val html = app.get("$mainUrl", timeout = 25).text + val html = app.get(mainUrl, timeout = 25).text val document = Jsoup.parse(html) val all = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LookMovieProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LookMovieProvider.kt index 4278f2b5..9322daba 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LookMovieProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LookMovieProvider.kt @@ -110,36 +110,31 @@ class LookMovieProvider : MainAPI() { } override suspend fun search(query: String): List { - suspend fun search(query: String, isMovie: Boolean): ArrayList { + suspend fun search(query: String, isMovie: Boolean): List { val url = "$mainUrl/${if (isMovie) "movies" else "shows"}/search/?q=$query" val response = app.get(url).text val document = Jsoup.parse(response) val items = document.select("div.flex-wrap-movielist > div.movie-item-style-1") - val returnValue = ArrayList() - items.forEach { item -> + return items.map { item -> val titleHolder = item.selectFirst("> div.mv-item-infor > h6 > a") val href = fixUrl(titleHolder.attr("href")) val name = titleHolder.text() val posterHolder = item.selectFirst("> div.image__placeholder > a") val poster = posterHolder.selectFirst("> img")?.attr("data-src") val year = posterHolder.selectFirst("> p.year")?.text()?.toIntOrNull() - - returnValue.add( - if (isMovie) { - MovieSearchResponse( - name, href, this.name, TvType.Movie, poster, year - ) - } else - TvSeriesSearchResponse( - name, href, this.name, TvType.TvSeries, poster, year, null - ) - ) + if (isMovie) { + MovieSearchResponse( + name, href, this.name, TvType.Movie, poster, year + ) + } else + TvSeriesSearchResponse( + name, href, this.name, TvType.TvSeries, poster, year, null + ) } - return returnValue } - val movieList = search(query, true) + val movieList = search(query, true).toMutableList() val seriesList = search(query, false) movieList.addAll(seriesList) return movieList diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/french-stream.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/french-stream.kt index 3c340ec5..69b2291b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/french-stream.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/french-stream.kt @@ -13,11 +13,11 @@ class FrenchStreamProvider : MainAPI() { override val lang = "fr" override val supportedTypes = setOf(TvType.AnimeMovie, TvType.TvSeries, TvType.Movie) - override suspend fun search(query: String): ArrayList { + override suspend fun search(query: String): List { val link = "$mainUrl/?do=search&subaction=search&story=$query" val soup = app.post(link).document - return ArrayList(soup.select("div.short-in.nl").map { li -> + return soup.select("div.short-in.nl").map { li -> val href = fixUrl(li.selectFirst("a.short-poster").attr("href")) val poster = li.selectFirst("img")?.attr("src") val title = li.selectFirst("> a.short-poster").text().toString().replace(". ", "") @@ -46,7 +46,7 @@ class FrenchStreamProvider : MainAPI() { year, ) } - }) + } } override suspend fun load(url: String): LoadResponse { diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index bee3f681..7ea867f8 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -1,74 +1,67 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/mobile_navigation" + app:startDestination="@+id/navigation_home"> - + app:popExitAnim="@anim/exit_anim"> + app:argType="string" /> + app:argType="string" /> + android:defaultValue="0" /> + android:defaultValue="0" /> + android:defaultValue="false" /> - + app:popExitAnim="@anim/exit_anim"> + android:defaultValue="@null" /> + android:defaultValue="@null" /> + android:defaultValue="0L" /> - - + app:popExitAnim="@anim/exit_anim" /> - + android:defaultValue="true" /> - + android:defaultValue="true" /> - + android:defaultValue="true" /> + android:name="autosearch" + app:argType="string" + android:defaultValue="@null" /> - - + app:popExitAnim="@anim/exit_anim" /> - - + app:popExitAnim="@anim/exit_anim" /> - - + app:popExitAnim="@anim/exit_anim" /> + tools:layout="@layout/fragment_home" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + tools:layout="@layout/fragment_search" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + tools:layout="@layout/fragment_downloads" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim"> - + app:argType="string" /> + app:argType="string" /> + android:label="@string/title_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + android:label="@string/subtitles_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + android:label="@string/chromecast_subtitles_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" + android:label="@string/search" /> + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" + android:label="@string/title_settings" /> + android:name="com.lagradost.cloudstream3.ui.result.ResultFragment" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + android:name="com.lagradost.cloudstream3.ui.player.GeneratorPlayer" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> \ No newline at end of file