From e64c84500d7550f4765b8cf5b6e27b0a6671d4eb Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Sat, 30 Jul 2022 05:43:57 +0200 Subject: [PATCH 1/4] experimental inf homepage (9anime test) --- .../com/lagradost/cloudstream3/MainAPI.kt | 37 +++++- .../animeproviders/AllAnimeProvider.kt | 2 +- .../animeproviders/AniPlayProvider.kt | 2 +- .../animeproviders/AniflixProvider.kt | 2 +- .../animeproviders/AnimeIndoProvider.kt | 2 +- .../animeproviders/AnimePaheProvider.kt | 2 +- .../animeproviders/AnimeSailProvider.kt | 2 +- .../animeproviders/AnimeSaturnProvider.kt | 2 +- .../animeproviders/AnimeWorldProvider.kt | 2 +- .../animeproviders/AnimefenixProvider.kt | 2 +- .../animeproviders/AnimeflvIOProvider.kt | 2 +- .../animeproviders/AnimeflvProvider.kt | 2 +- .../animeproviders/AnimekisaProvider.kt | 2 +- .../animeproviders/DubbedAnimeProvider.kt | 2 +- .../animeproviders/GogoanimeProvider.kt | 2 +- .../animeproviders/GomunimeProvider.kt | 2 +- .../animeproviders/JKAnimeProvider.kt | 2 +- .../animeproviders/KawaiifuProvider.kt | 2 +- .../animeproviders/KimCartoonProvider.kt | 2 +- .../animeproviders/KuramanimeProvider.kt | 2 +- .../animeproviders/KuronimeProvider.kt | 2 +- .../animeproviders/MonoschinosProvider.kt | 2 +- .../animeproviders/MundoDonghuaProvider.kt | 2 +- .../animeproviders/NeonimeProvider.kt | 2 +- .../animeproviders/NineAnimeProvider.kt | 69 ++++++------ .../animeproviders/NontonAnimeIDProvider.kt | 2 +- .../animeproviders/OploverzProvider.kt | 2 +- .../animeproviders/OtakudesuProvider.kt | 2 +- .../animeproviders/TenshiProvider.kt | 2 +- .../animeproviders/TocanimeProvider.kt | 2 +- .../animeproviders/WcoProvider.kt | 2 +- .../animeproviders/ZoroProvider.kt | 2 +- .../cloudstream3/liveproviders/EjaTv.kt | 2 +- .../metaproviders/TmdbProvider.kt | 2 +- .../movieproviders/AkwamProvider.kt | 2 +- .../movieproviders/AllMoviesForYouProvider.kt | 2 +- .../movieproviders/AltadefinizioneProvider.kt | 2 +- .../movieproviders/AsiaFlixProvider.kt | 2 +- .../movieproviders/BflixProvider.kt | 2 +- .../movieproviders/CimaNowProvider.kt | 2 +- .../movieproviders/CineblogProvider.kt | 2 +- .../movieproviders/CinecalidadProvider.kt | 2 +- .../movieproviders/CuevanaProvider.kt | 2 +- .../movieproviders/DoramasYTProvider.kt | 2 +- .../movieproviders/DramaSeeProvider.kt | 2 +- .../movieproviders/DramaidProvider.kt | 2 +- .../movieproviders/EgyBestProvider.kt | 2 +- .../movieproviders/ElifilmsProvider.kt | 2 +- .../EntrepeliculasyseriesProvider.kt | 2 +- .../movieproviders/EstrenosDoramasProvider.kt | 2 +- .../movieproviders/FaselHDProvider.kt | 2 +- .../movieproviders/FilmanProvider.kt | 2 +- .../movieproviders/FilmpertuttiProvider.kt | 2 +- .../movieproviders/FrenchStreamProvider.kt | 2 +- .../movieproviders/HDMProvider.kt | 2 +- .../cloudstream3/movieproviders/HDMovie5.kt | 2 +- .../movieproviders/HDrezkaProvider.kt | 2 +- .../movieproviders/IHaveNoTvProvider.kt | 2 +- .../movieproviders/IdlixProvider.kt | 2 +- .../movieproviders/KdramaHoodProvider.kt | 2 +- .../movieproviders/LayarKacaProvider.kt | 2 +- .../movieproviders/MultiplexProvider.kt | 2 +- .../movieproviders/MyCimaProvider.kt | 2 +- .../movieproviders/NginxProvider.kt | 2 +- .../movieproviders/PeliSmartProvider.kt | 2 +- .../movieproviders/PelisflixProvider.kt | 2 +- .../movieproviders/PelisplusHDProvider.kt | 2 +- .../PelisplusProviderTemplate.kt | 2 +- .../movieproviders/PhimmoichillProvider.kt | 2 +- .../movieproviders/PinoyHDXyzProvider.kt | 2 +- .../movieproviders/PinoyMoviePediaProvider.kt | 2 +- .../movieproviders/PinoyMoviesEsProvider.kt | 2 +- .../movieproviders/RebahinProvider.kt | 2 +- .../movieproviders/SeriesflixProvider.kt | 2 +- .../movieproviders/SflixProvider.kt | 2 +- .../movieproviders/SoaptwoDayProvider.kt | 2 +- .../StreamingcommunityProvider.kt | 2 +- .../movieproviders/TantiFilmProvider.kt | 2 +- .../movieproviders/TheFlixToProvider.kt | 2 +- .../movieproviders/UakinoProvider.kt | 2 +- .../VidstreamProviderTemplate.kt | 2 +- .../movieproviders/WatchAsianProvider.kt | 2 +- .../movieproviders/XcineProvider.kt | 3 +- .../movieproviders/YomoviesProvider.kt | 2 +- .../cloudstream3/mvvm/ArchComponentExt.kt | 61 ++++++++-- .../cloudstream3/ui/APIRepository.kt | 9 +- .../cloudstream3/ui/home/HomeFragment.kt | 42 +++---- .../ui/home/HomeParentItemAdapter.kt | 89 +++++++++++---- .../cloudstream3/ui/home/HomeViewModel.kt | 106 ++++++++++++++---- 89 files changed, 379 insertions(+), 199 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index 4a751932..2b393a05 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -376,6 +376,32 @@ data class ProvidersInfoJson( @JsonProperty("status") var status: Int, ) + +data class MainPageData( + val name: String, + val data: String, +) + +/** return list of MainPageData with url to name, make for more readable code */ +fun mainPageOf(vararg elements: Pair): List { + return elements.map { (url, name) -> MainPageData(name = name, data = url) } +} + +fun newHomePageResponse( + name: String, + list: List, + hasNext: Boolean? = null +): HomePageResponse { + return HomePageResponse( + listOf(HomePageList(name, list)), + hasNext = hasNext ?: list.isNotEmpty() + ) +} + +fun newHomePageResponse(list: HomePageList, hasNext: Boolean? = null): HomePageResponse { + return HomePageResponse(listOf(list), hasNext = hasNext ?: list.list.isNotEmpty()) +} + /**Every provider will **not** have try catch built in, so handle exceptions when calling these functions*/ abstract class MainAPI { companion object { @@ -431,8 +457,14 @@ abstract class MainAPI { open val vpnStatus = VPNStatus.None open val providerType = ProviderType.DirectProvider + open val mainPage = listOf(MainPageData("", "")) + @WorkerThread - open suspend fun getMainPage(): HomePageResponse? { + open suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse? { throw NotImplementedError() } @@ -632,7 +664,8 @@ fun TvType.isAnimeOp(): Boolean { data class SubtitleFile(val lang: String, val url: String) data class HomePageResponse( - val items: List + val items: List, + val hasNext: Boolean = false ) data class HomePageList( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AllAnimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AllAnimeProvider.kt index f3c91a33..c9e2e8fe 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AllAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AllAnimeProvider.kt @@ -104,7 +104,7 @@ class AllAnimeProvider : MainAPI() { @JsonProperty("__typename") val _typename: String? = null ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( // Pair( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniPlayProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniPlayProvider.kt index cb04d3d2..1ea3f151 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniPlayProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniPlayProvider.kt @@ -114,7 +114,7 @@ class AniPlayProvider : MainAPI() { @JsonProperty("videoUrl") val url: String ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val response = app.get("$mainUrl/api/home/latest-episodes?page=0").parsed>() val results = response.map{ diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniflixProvider.kt index 27ab873c..0d7f82fc 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniflixProvider.kt @@ -45,7 +45,7 @@ class AniflixProvider : MainAPI() { } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val soup = app.get(mainUrl).document val elements = listOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeIndoProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeIndoProvider.kt index 914975a2..1e01f266 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeIndoProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeIndoProvider.kt @@ -62,7 +62,7 @@ class AnimeIndoProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = request(mainUrl).document val homePageList = ArrayList() 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 58e744d9..28375616 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimePaheProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimePaheProvider.kt @@ -58,7 +58,7 @@ class AnimePaheProvider : MainAPI() { TvType.OVA ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { data class Data( @JsonProperty("id") val id: Int, @JsonProperty("anime_id") val animeId: Int, diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeSailProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeSailProvider.kt index b1dc3fc3..7b29cdc8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeSailProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeSailProvider.kt @@ -47,7 +47,7 @@ class AnimeSailProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = request(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeSaturnProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeSaturnProvider.kt index 6ddc0756..793d5b7a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeSaturnProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeSaturnProvider.kt @@ -64,7 +64,7 @@ class AnimeSaturnProvider : MainAPI() { } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val list = ArrayList() document.select("div.container:has(span.badge-saturn)").forEach { diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeWorldProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeWorldProvider.kt index 5b380330..81ce9e99 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeWorldProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeWorldProvider.kt @@ -130,7 +130,7 @@ class AnimeWorldProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = request(mainUrl).document val list = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimefenixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimefenixProvider.kt index ee1ac5be..438cc56a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimefenixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimefenixProvider.kt @@ -30,7 +30,7 @@ class AnimefenixProvider:MainAPI() { else DubStatus.Subbed } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("$mainUrl/", "Animes"), Pair("$mainUrl/animes?type[]=movie&order=default", "Peliculas", ), diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvIOProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvIOProvider.kt index 9a03c856..65a3a1c4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvIOProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvIOProvider.kt @@ -22,7 +22,7 @@ class AnimeflvIOProvider:MainAPI() { TvType.OVA, TvType.Anime, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/series", "Series actualizadas",), 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 561505aa..abecc08a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimeflvProvider.kt @@ -34,7 +34,7 @@ class AnimeflvnetProvider : MainAPI() { TvType.Anime, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("$mainUrl/browse?type[]=movie&order=updated", "Películas"), Pair("$mainUrl/browse?status[]=2&order=default", "Animes"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimekisaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimekisaProvider.kt index 91e1a133..11defe07 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimekisaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AnimekisaProvider.kt @@ -26,7 +26,7 @@ class AnimekisaProvider : MainAPI() { @JsonProperty("html") val html: String ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("$mainUrl/ajax/list/views?type=all", "All animes"), Pair("$mainUrl/ajax/list/views?type=day", "Trending now"), 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 d6ac927f..45a87085 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt @@ -96,7 +96,7 @@ class DubbedAnimeProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val trendingUrl = "$mainUrl/xz/trending.php?_=$unixTimeMS" val lastEpisodeUrl = "$mainUrl/xz/epgrid.php?p=1&_=$unixTimeMS" val recentlyAddedUrl = "$mainUrl/xz/gridgrabrecent.php?p=1&_=$unixTimeMS" 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 a9a786ce..e45976d2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GogoanimeProvider.kt @@ -178,7 +178,7 @@ class GogoanimeProvider : MainAPI() { TvType.OVA ) - override suspend fun getMainPage(): HomePageResponse { + 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\"", diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GomunimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GomunimeProvider.kt index a816df25..96633ced 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GomunimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/GomunimeProvider.kt @@ -46,7 +46,7 @@ class GomunimeProvider : MainAPI() { @JsonProperty("html") val html: String ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("e", "Episode Baru"), Pair("c", "Completed"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/JKAnimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/JKAnimeProvider.kt index 54f713de..425a29c2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/JKAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/JKAnimeProvider.kt @@ -32,7 +32,7 @@ class JKAnimeProvider : MainAPI() { TvType.Anime, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair( "$mainUrl/directorio/?filtro=fecha&tipo=TV&estado=1&fecha=none&temporada=none&orden=desc", diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KawaiifuProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KawaiifuProvider.kt index f1930306..812ce5c0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KawaiifuProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KawaiifuProvider.kt @@ -14,7 +14,7 @@ class KawaiifuProvider : MainAPI() { override val supportedTypes = setOf(TvType.Anime, TvType.AnimeMovie) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val resp = app.get(mainUrl).text diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KimCartoonProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KimCartoonProvider.kt index 5a537912..1c75fe39 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KimCartoonProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KimCartoonProvider.kt @@ -17,7 +17,7 @@ class KimCartoonProvider : MainAPI() { return if (url.startsWith("/")) mainUrl + url else url } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val doc = app.get(mainUrl).document.select("#container") val response = mutableListOf( HomePageList( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuramanimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuramanimeProvider.kt index a6b3fb27..cd451e03 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuramanimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuramanimeProvider.kt @@ -38,7 +38,7 @@ class KuramanimeProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuronimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuronimeProvider.kt index edb3d9f7..0338fc85 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuronimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/KuronimeProvider.kt @@ -39,7 +39,7 @@ class KuronimeProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MonoschinosProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MonoschinosProvider.kt index b10c480a..ebc10656 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MonoschinosProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MonoschinosProvider.kt @@ -34,7 +34,7 @@ class MonoschinosProvider : MainAPI() { TvType.Anime, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("$mainUrl/emision", "En emisión"), Pair( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MundoDonghuaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MundoDonghuaProvider.kt index cbdf9834..86fcfe5a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MundoDonghuaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/MundoDonghuaProvider.kt @@ -23,7 +23,7 @@ class MundoDonghuaProvider : MainAPI() { TvType.Anime, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("$mainUrl/lista-donghuas", "Donghuas"), ) diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NeonimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NeonimeProvider.kt index ed46d6b7..e5343fdf 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NeonimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NeonimeProvider.kt @@ -40,7 +40,7 @@ class NeonimeProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NineAnimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NineAnimeProvider.kt index fb22c791..c810e49c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NineAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NineAnimeProvider.kt @@ -137,44 +137,45 @@ class NineAnimeProvider : MainAPI() { private fun decode(input: String): String = java.net.URLDecoder.decode(input, "utf-8") } - override suspend fun getMainPage(): HomePageResponse { - val items = listOf( - "$mainUrl/ajax/home/widget/trending?page=1" to "Trending", - "$mainUrl/ajax/home/widget/updated-all?page=1" to "All", - "$mainUrl/ajax/home/widget/updated-sub?page=1" to "Recently Updated (SUB)", - "$mainUrl/ajax/home/widget/updated-dub?page=1" to - "Recently Updated (DUB)", - "$mainUrl/ajax/home/widget/updated-china?page=1" to - "Recently Updated (Chinese)", - "$mainUrl/ajax/home/widget/random?page=1" to "Random", - ).apmap { (url, name) -> - val home = Jsoup.parse( - app.get( - url - ).parsed().html - ).select("div.item").mapNotNull { element -> - val title = element.selectFirst(".info > .name") ?: return@mapNotNull null - val link = title.attr("href") - val poster = element.selectFirst(".poster > a > img")?.attr("src") - val meta = element.selectFirst(".poster > a > .meta > .inner > .left") - val subbedEpisodes = meta?.selectFirst(".sub")?.text()?.toIntOrNull() - val dubbedEpisodes = meta?.selectFirst(".dub")?.text()?.toIntOrNull() + override val mainPage = mainPageOf( + "$mainUrl/ajax/home/widget/trending?page=" to "Trending", + "$mainUrl/ajax/home/widget/updated-all?page=" to "All", + "$mainUrl/ajax/home/widget/updated-sub?page=" to "Recently Updated (SUB)", + "$mainUrl/ajax/home/widget/updated-dub?page=" to "Recently Updated (DUB)", + "$mainUrl/ajax/home/widget/updated-china?page=" to "Recently Updated (Chinese)", + "$mainUrl/ajax/home/widget/random?page=" to "Random", + ) - newAnimeSearchResponse(title.text() ?: return@mapNotNull null, link) { - this.posterUrl = poster - addDubStatus( - dubbedEpisodes != null, - subbedEpisodes != null, - dubbedEpisodes, - subbedEpisodes - ) - } + override suspend fun getMainPage( + page: Int, + categoryName: String, + categoryData: String + ): HomePageResponse { + val url = categoryData + page + val home = Jsoup.parse( + app.get( + url + ).parsed().html + ).select("div.item").mapNotNull { element -> + val title = element.selectFirst(".info > .name") ?: return@mapNotNull null + val link = title.attr("href") + val poster = element.selectFirst(".poster > a > img")?.attr("src") + val meta = element.selectFirst(".poster > a > .meta > .inner > .left") + val subbedEpisodes = meta?.selectFirst(".sub")?.text()?.toIntOrNull() + val dubbedEpisodes = meta?.selectFirst(".dub")?.text()?.toIntOrNull() + + newAnimeSearchResponse(title.text() ?: return@mapNotNull null, link) { + this.posterUrl = poster + addDubStatus( + dubbedEpisodes != null, + subbedEpisodes != null, + dubbedEpisodes, + subbedEpisodes + ) } - - HomePageList(name, home) } - return HomePageResponse(items) + return newHomePageResponse(categoryName, home) } data class Response( diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NontonAnimeIDProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NontonAnimeIDProvider.kt index 0f92d632..73d3a5a0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NontonAnimeIDProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/NontonAnimeIDProvider.kt @@ -40,7 +40,7 @@ class NontonAnimeIDProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OploverzProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OploverzProvider.kt index 092dc041..3a5f90fb 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OploverzProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OploverzProvider.kt @@ -40,7 +40,7 @@ class OploverzProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OtakudesuProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OtakudesuProvider.kt index 7aed6e41..ad213f22 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OtakudesuProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/OtakudesuProvider.kt @@ -38,7 +38,7 @@ class OtakudesuProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() 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 0e4489e7..4f0e9892 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TenshiProvider.kt @@ -44,7 +44,7 @@ class TenshiProvider : MainAPI() { } }*/ - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val soup = app.get(mainUrl, interceptor = ddosGuardKiller).document for (section in soup.select("#content > section")) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TocanimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TocanimeProvider.kt index 62b349fb..f5324ffe 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TocanimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/TocanimeProvider.kt @@ -39,7 +39,7 @@ class TocanimeProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() 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 0df4a8d4..51629d9b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/WcoProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/WcoProvider.kt @@ -30,7 +30,7 @@ class WcoProvider : MainAPI() { TvType.OVA ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("$mainUrl/ajax/list/recently_updated?type=tv", "Recently Updated Anime"), Pair("$mainUrl/ajax/list/recently_updated?type=movie", "Recently Updated Movies"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/ZoroProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/ZoroProvider.kt index b74b113a..be9209b8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/ZoroProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/ZoroProvider.kt @@ -77,7 +77,7 @@ class ZoroProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val html = app.get("$mainUrl/home").text val document = Jsoup.parse(html) diff --git a/app/src/main/java/com/lagradost/cloudstream3/liveproviders/EjaTv.kt b/app/src/main/java/com/lagradost/cloudstream3/liveproviders/EjaTv.kt index 9ee0af6b..84f04446 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/liveproviders/EjaTv.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/liveproviders/EjaTv.kt @@ -37,7 +37,7 @@ class EjaTv : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { // Maybe this based on app language or as setting? val language = "English" val dataMap = mapOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/metaproviders/TmdbProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/metaproviders/TmdbProvider.kt index 13cbd335..c390d313 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/metaproviders/TmdbProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/metaproviders/TmdbProvider.kt @@ -196,7 +196,7 @@ open class TmdbProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { // SAME AS DISCOVER IT SEEMS // val popularSeries = tmdb.tvService().popular(1, "en-US").execute().body()?.results?.map { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AkwamProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AkwamProvider.kt index ac820b46..afd7ed03 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AkwamProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AkwamProvider.kt @@ -34,7 +34,7 @@ class AkwamProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { // Title, Url val moviesUrl = listOf( "Movies" to "$mainUrl/movies", 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 4a90bc08..8efd3a40 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt @@ -27,7 +27,7 @@ class AllMoviesForYouProvider : MainAPI() { TvType.TvSeries ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val soup = app.get(mainUrl).document val urls = listOf( 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 719acc96..ee393f7f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AltadefinizioneProvider.kt @@ -18,7 +18,7 @@ class AltadefinizioneProvider : MainAPI() { TvType.Movie ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/azione/", "Azione"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AsiaFlixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AsiaFlixProvider.kt index e6893c85..0fbb8e94 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AsiaFlixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AsiaFlixProvider.kt @@ -110,7 +110,7 @@ class AsiaFlixProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val headers = mapOf("X-Requested-By" to "asiaflix-web") val response = app.get("$apiUrl/dashboard", headers = headers).text diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/BflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/BflixProvider.kt index 2ca2ab88..b6ca0bd3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/BflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/BflixProvider.kt @@ -23,7 +23,7 @@ open class BflixProvider : MainAPI() { //override val uniqueId: Int by lazy { "BflixProvider".hashCode() } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val soup = app.get("$mainUrl/home").document val testa = listOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CimaNowProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CimaNowProvider.kt index 3fa2cee6..34083b0f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CimaNowProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CimaNowProvider.kt @@ -41,7 +41,7 @@ class CimaNowProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val doc = app.get("$mainUrl/home", headers = mapOf("user-agent" to "MONKE")).document val pages = doc.select("section").not("section:contains(أختر وجهتك المفضلة)").not("section:contains(تم اضافته حديثاً)").apmap { diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt index 77114ba4..9eff8cce 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt @@ -17,7 +17,7 @@ class CineblogProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/genere/azione/", "Azione"), 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 fff75318..ff2ad22d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CinecalidadProvider.kt @@ -19,7 +19,7 @@ class CinecalidadProvider : MainAPI() { ) override val vpnStatus = VPNStatus.MightBeNeeded //Due to evoload sometimes not loading - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/ver-serie/", "Series"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CuevanaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CuevanaProvider.kt index 7c7aca67..f6fdba07 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CuevanaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CuevanaProvider.kt @@ -19,7 +19,7 @@ class CuevanaProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair(mainUrl, "Recientemente actualizadas"), 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 1d1c88d2..09cccea4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DoramasYTProvider.kt @@ -31,7 +31,7 @@ class DoramasYTProvider : MainAPI() { TvType.AsianDrama, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("$mainUrl/emision", "En emisión"), Pair( diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaSeeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaSeeProvider.kt index 7eef691b..57bf1225 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaSeeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaSeeProvider.kt @@ -14,7 +14,7 @@ class DramaSeeProvider : MainAPI() { override val hasDownloadSupport = true override val supportedTypes = setOf(TvType.AsianDrama) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val headers = mapOf("X-Requested-By" to mainUrl) val document = app.get(mainUrl, headers = headers).document val mainbody = document.getElementsByTag("body") diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaidProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaidProvider.kt index 662d23a5..4b2c8d77 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaidProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/DramaidProvider.kt @@ -30,7 +30,7 @@ class DramaidProvider : MainAPI() { } } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EgyBestProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EgyBestProvider.kt index cd639c0c..f9da13fe 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EgyBestProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EgyBestProvider.kt @@ -41,7 +41,7 @@ class EgyBestProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { // url, title val doc = app.get(mainUrl).document val pages = arrayListOf() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ElifilmsProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ElifilmsProvider.kt index 9e6f9bfe..db394948 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ElifilmsProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ElifilmsProvider.kt @@ -15,7 +15,7 @@ class ElifilmsProvider : MainAPI() { TvType.Movie, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val newest = app.get(mainUrl).document.selectFirst("a.fav_link.premiera")?.attr("href") val urls = listOf( 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 b46d67d4..97921755 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EntrepeliculasyseriesProvider.kt @@ -18,7 +18,7 @@ class EntrepeliculasyseriesProvider:MainAPI() { ) override val vpnStatus = VPNStatus.MightBeNeeded //Due to evoload sometimes not loading - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/series/", "Series"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EstrenosDoramasProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EstrenosDoramasProvider.kt index 5cb11248..df2fe159 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EstrenosDoramasProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/EstrenosDoramasProvider.kt @@ -28,7 +28,7 @@ class EstrenosDoramasProvider : MainAPI() { TvType.AsianDrama, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair(mainUrl, "Últimas series"), Pair("$mainUrl/category/peliculas", "Películas"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FaselHDProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FaselHDProvider.kt index 9a21a42c..5b941718 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FaselHDProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FaselHDProvider.kt @@ -35,7 +35,7 @@ class FaselHDProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { // Title, Url val moviesUrl = listOf( Pair("Movies", "$mainUrl/all-movies/page/"+(0..10).random()), 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 08bf21f8..63e55594 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmanProvider.kt @@ -18,7 +18,7 @@ class FilmanProvider : MainAPI() { TvType.TvSeries ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val lists = document.select("#item-list,#series-list") val categories = ArrayList() 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 cda70a31..bce4e955 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmpertuttiProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FilmpertuttiProvider.kt @@ -23,7 +23,7 @@ class FilmpertuttiProvider : MainAPI() { TvType.TvSeries ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/category/serie-tv/", "Serie Tv"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FrenchStreamProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FrenchStreamProvider.kt index 6eac9a62..f3b447b4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FrenchStreamProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/FrenchStreamProvider.kt @@ -232,7 +232,7 @@ class FrenchStreamProvider : MainAPI() { } - override suspend fun getMainPage(): HomePageResponse? { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse? { val document = app.get(mainUrl).document val docs = document.select("div.sect") val returnList = docs.mapNotNull { 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 cd08293e..fd002a5c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMProvider.kt @@ -69,7 +69,7 @@ class HDMProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { 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/HDMovie5.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt index 6de7363d..3c7a6b66 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt @@ -19,7 +19,7 @@ class HDMovie5 : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val doc = app.get(mainUrl).document.select("div.content") val list = mapOf( "Featured Movies" to "featured", diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDrezkaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDrezkaProvider.kt index 291383c2..96bcc6f3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDrezkaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDrezkaProvider.kt @@ -28,7 +28,7 @@ class HDrezkaProvider : MainAPI() { TvType.AsianDrama ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/IHaveNoTvProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/IHaveNoTvProvider.kt index 2be28b3d..0749c52e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/IHaveNoTvProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/IHaveNoTvProvider.kt @@ -14,7 +14,7 @@ class IHaveNoTvProvider : MainAPI() { override val supportedTypes = setOf(TvType.Documentary) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { // Uhh, I am too lazy to scrape the "latest documentaries" and "recommended documentaries", // so I am just scraping 3 random categories val allCategories = listOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/IdlixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/IdlixProvider.kt index 4b1912b5..10e6a7e1 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/IdlixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/IdlixProvider.kt @@ -22,7 +22,7 @@ class IdlixProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/KdramaHoodProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/KdramaHoodProvider.kt index a87c34ec..a35c0e36 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/KdramaHoodProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/KdramaHoodProvider.kt @@ -26,7 +26,7 @@ class KdramaHoodProvider : MainAPI() { @JsonProperty("file") val file: String ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val doc = app.get("$mainUrl/home2").document val home = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LayarKacaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LayarKacaProvider.kt index 8b96f88c..98091c75 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LayarKacaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/LayarKacaProvider.kt @@ -21,7 +21,7 @@ class LayarKacaProvider : MainAPI() { TvType.AsianDrama ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MultiplexProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MultiplexProvider.kt index fe013f5e..5962a56f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MultiplexProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MultiplexProvider.kt @@ -22,7 +22,7 @@ class MultiplexProvider : MainAPI() { TvType.AsianDrama ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MyCimaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MyCimaProvider.kt index b74a281c..9027d996 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MyCimaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MyCimaProvider.kt @@ -44,7 +44,7 @@ class MyCimaProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { // Title, Url val moviesUrl = listOf( "Movies" to "$mainUrl/movies/page/" + (0..25).random(), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/NginxProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/NginxProvider.kt index 4711d9cb..6b1c150f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/NginxProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/NginxProvider.kt @@ -212,7 +212,7 @@ class NginxProvider : MainAPI() { } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val authHeader = getAuthHeader() // call again because it isn't reloaded if in main class and storedCredentials loads after 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 588efea3..1cb5e0d0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PeliSmartProvider.kt @@ -17,7 +17,7 @@ class PeliSmartProvider: MainAPI() { ) override val vpnStatus = VPNStatus.MightBeNeeded //Due to evoload sometimes not loading - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/peliculas/", "Peliculas"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisflixProvider.kt index a22a1ca8..6f4dbccb 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisflixProvider.kt @@ -18,7 +18,7 @@ class PelisflixProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/ver-peliculas-online-gratis-fullhdc3/", "Películas"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusHDProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusHDProvider.kt index d45587f8..9cabffd5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusHDProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusHDProvider.kt @@ -16,7 +16,7 @@ class PelisplusHDProvider:MainAPI() { TvType.Movie, TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val document = app.get(mainUrl).document val map = mapOf( diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusProviderTemplate.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusProviderTemplate.kt index 41c51afd..74ce0ce4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusProviderTemplate.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PelisplusProviderTemplate.kt @@ -142,7 +142,7 @@ open class PelisplusProviderTemplate : MainAPI() { // This loads the homepage, which is basically a collection of search results with labels. // Optional function, but make sure to enable hasMainPage if you program this. - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = homePageUrlList val homePageList = ArrayList() // .pmap {} is used to fetch the different pages in parallel diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PhimmoichillProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PhimmoichillProvider.kt index 38862076..56d4103e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PhimmoichillProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PhimmoichillProvider.kt @@ -23,7 +23,7 @@ class PhimmoichillProvider : MainAPI() { TvType.AsianDrama ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt index e14c01d0..8f79979e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyHDXyzProvider.kt @@ -15,7 +15,7 @@ class PinoyHDXyzProvider : MainAPI() { override val hasMainPage = true override val hasQuickSearch = false - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val all = ArrayList() val document = app.get(mainUrl, referer = mainUrl).document val mainbody = document.getElementsByTag("body") diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt index ebc73b6f..fbb62f1d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviePediaProvider.kt @@ -16,7 +16,7 @@ class PinoyMoviePediaProvider : MainAPI() { override val hasMainPage = true override val hasQuickSearch = false - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val all = ArrayList() val document = app.get(mainUrl).document val mainbody = document.getElementsByTag("body") diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt index 6b68e5c1..3fd22867 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt @@ -90,7 +90,7 @@ class PinoyMoviesEsProvider : MainAPI() { return all } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val all = ArrayList() val document = app.get(mainUrl).document val mainbody = document.getElementsByTag("body") diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/RebahinProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/RebahinProvider.kt index 0a45f118..49d88112 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/RebahinProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/RebahinProvider.kt @@ -27,7 +27,7 @@ class RebahinProvider : MainAPI() { TvType.AsianDrama ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = listOf( Pair("Featured", "xtab1"), Pair("Film Terbaru", "xtab2"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SeriesflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SeriesflixProvider.kt index 08b07b31..41eec15f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SeriesflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SeriesflixProvider.kt @@ -18,7 +18,7 @@ class SeriesflixProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/ver-series-online/", "Series"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SflixProvider.kt index 0543e42f..bd61b164 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SflixProvider.kt @@ -41,7 +41,7 @@ open class SflixProvider : MainAPI() { ) override val vpnStatus = VPNStatus.None - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val html = app.get("$mainUrl/home").text val document = Jsoup.parse(html) 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 d85547e0..38c60be8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SoaptwoDayProvider.kt @@ -19,7 +19,7 @@ class SoaptwoDayProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val urls = listOf( Pair("$mainUrl/movielist/", "Movies"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/StreamingcommunityProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/StreamingcommunityProvider.kt index 49c6389b..5f3ae345 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/StreamingcommunityProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/StreamingcommunityProvider.kt @@ -174,7 +174,7 @@ class StreamingcommunityProvider : MainAPI() { val posterMap = hashMapOf() } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val document = app.get(mainUrl).document document.select("slider-title").subList(0, 6).map { it -> 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 30b00ec0..711b6895 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TantiFilmProvider.kt @@ -18,7 +18,7 @@ class TantifilmProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + 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"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TheFlixToProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TheFlixToProvider.kt index 38f08ec9..2ab2b540 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TheFlixToProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TheFlixToProvider.kt @@ -143,7 +143,7 @@ class TheFlixToProvider : MainAPI() { } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val items = ArrayList() val doc = app.get(mainUrl).document val scriptText = doc.selectFirst("script[type=application/json]")!!.data() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/UakinoProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/UakinoProvider.kt index eb48b8d8..967feb71 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/UakinoProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/UakinoProvider.kt @@ -23,7 +23,7 @@ class UakinoProvider : MainAPI() { TvType.Anime ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VidstreamProviderTemplate.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VidstreamProviderTemplate.kt index 513ce73d..48db5f85 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VidstreamProviderTemplate.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/VidstreamProviderTemplate.kt @@ -210,7 +210,7 @@ open class VidstreamProviderTemplate : MainAPI() { // This loads the homepage, which is basically a collection of search results with labels. // Optional function, but make sure to enable hasMainPage if you program this. - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val urls = homePageUrlList val homePageList = ArrayList() // .pmap {} is used to fetch the different pages in parallel diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/WatchAsianProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/WatchAsianProvider.kt index fbf3d9cf..d8ba061a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/WatchAsianProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/WatchAsianProvider.kt @@ -18,7 +18,7 @@ class WatchAsianProvider : MainAPI() { override val hasDownloadSupport = true override val supportedTypes = setOf(TvType.AsianDrama) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val headers = mapOf("X-Requested-By" to mainUrl) val doc = app.get(mainUrl, headers = headers).document val rowPair = mutableListOf>() diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/XcineProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/XcineProvider.kt index 82f5f186..99561b05 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/XcineProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/XcineProvider.kt @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.movieproviders import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.AppUtils.parseJson -import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.Qualities import org.jsoup.nodes.Element @@ -41,7 +40,7 @@ class XcineProvider : MainAPI() { ) } - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val sections = document.select("div.group-film") return HomePageResponse(sections.mapNotNull { section -> diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/YomoviesProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/YomoviesProvider.kt index 909f5fb7..04f1da6a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/YomoviesProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/YomoviesProvider.kt @@ -19,7 +19,7 @@ class YomoviesProvider : MainAPI() { TvType.TvSeries, ) - override suspend fun getMainPage(): HomePageResponse { + override suspend fun getMainPage(page: Int, categoryName: String, categoryData: String): HomePageResponse { val document = app.get(mainUrl).document val homePageList = ArrayList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt b/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt index 28007b1c..2a8c49f7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/mvvm/ArchComponentExt.kt @@ -4,6 +4,7 @@ import android.util.Log import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LiveData import com.bumptech.glide.load.HttpException +import com.lagradost.cloudstream3.BuildConfig import com.lagradost.cloudstream3.ErrorLoadingException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -11,6 +12,34 @@ import java.net.SocketTimeoutException import java.net.UnknownHostException import javax.net.ssl.SSLHandshakeException +const val DEBUG_EXCEPTION = "THIS IS A DEBUG EXCEPTION!" + +class DebugException(message: String) : Exception("$DEBUG_EXCEPTION\n$message") + +inline fun debugException(message: () -> String) { + if (BuildConfig.DEBUG) { + throw DebugException(message.invoke()) + } +} + +inline fun debugWarning(message: () -> String) { + if (BuildConfig.DEBUG) { + logError(DebugException(message.invoke())) + } +} + +inline fun debugAssert(assert: () -> Boolean, message: () -> String) { + if (BuildConfig.DEBUG && assert.invoke()) { + throw DebugException(message.invoke()) + } +} + +inline fun debugWarning(assert: () -> Boolean, message: () -> String) { + if (BuildConfig.DEBUG && assert.invoke()) { + logError(DebugException(message.invoke())) + } +} + fun LifecycleOwner.observe(liveData: LiveData, action: (t: T) -> Unit) { liveData.observe(this) { it?.let { t -> action(t) } } } @@ -61,11 +90,12 @@ suspend fun suspendSafeApiCall(apiCall: suspend () -> T): T? { } fun safeFail(throwable: Throwable): Resource { - val stackTraceMsg = (throwable.localizedMessage ?: "") + "\n\n" + throwable.stackTrace.joinToString( - separator = "\n" - ) { - "${it.fileName} ${it.lineNumber}" - } + val stackTraceMsg = + (throwable.localizedMessage ?: "") + "\n\n" + throwable.stackTrace.joinToString( + separator = "\n" + ) { + "${it.fileName} ${it.lineNumber}" + } return Resource.Failure(false, null, null, stackTraceMsg) } @@ -92,16 +122,31 @@ suspend fun safeApiCall( safeFail(throwable) } is SocketTimeoutException -> { - Resource.Failure(true, null, null, "Connection Timeout\nPlease try again later.") + Resource.Failure( + true, + null, + null, + "Connection Timeout\nPlease try again later." + ) } is HttpException -> { - Resource.Failure(false, throwable.statusCode, null, throwable.message ?: "HttpException") + Resource.Failure( + false, + throwable.statusCode, + null, + throwable.message ?: "HttpException" + ) } is UnknownHostException -> { Resource.Failure(true, null, null, "Cannot connect to server, try again later.") } is ErrorLoadingException -> { - Resource.Failure(true, null, null, throwable.message ?: "Error loading, try again later.") + Resource.Failure( + true, + null, + null, + throwable.message ?: "Error loading, try again later." + ) } is NotImplementedError -> { Resource.Failure(false, null, null, "This operation is not implemented.") diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt index f6cc0201..2daf51c1 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt @@ -29,6 +29,7 @@ class APIRepository(val api: MainAPI) { val hasMainPage = api.hasMainPage val name = api.name val mainUrl = api.mainUrl + val mainPage = api.mainPage val hasQuickSearch = api.hasQuickSearch suspend fun load(url: String): Resource { @@ -59,9 +60,13 @@ class APIRepository(val api: MainAPI) { } } - suspend fun getMainPage(): Resource { + suspend fun getMainPage(page: Int, nameIndex: Int? = null): Resource> { return safeApiCall { - api.getMainPage() ?: throw ErrorLoadingException() + nameIndex?.let { api.mainPage.getOrNull(it) }?.let { data -> + listOf(api.getMainPage(page, data.name, data.data)) + } ?: api.mainPage.apmap { data -> + api.getMainPage(page, data.name, data.data) + } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index c84679f1..f6d0babf 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -20,10 +20,8 @@ import androidx.core.widget.NestedScrollView import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.preference.PreferenceManager -import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearSnapHelper -import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.button.MaterialButton import com.lagradost.cloudstream3.* @@ -44,7 +42,6 @@ import com.lagradost.cloudstream3.ui.WatchType import com.lagradost.cloudstream3.ui.quicksearch.QuickSearchFragment import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST import com.lagradost.cloudstream3.ui.search.* -import com.lagradost.cloudstream3.ui.search.SearchFragment.Companion.filterSearchResponse import com.lagradost.cloudstream3.ui.search.SearchHelper.handleSearchClickCallback import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings @@ -349,8 +346,6 @@ class HomeFragment : Fragment() { return inflater.inflate(layout, container, false) } - private var currentHomePage: HomePageResponse? = null - private fun toggleMainVisibility(visible: Boolean) { home_main_holder?.isVisible = visible home_main_poster_recyclerview?.isVisible = visible @@ -541,18 +536,8 @@ class HomeFragment : Fragment() { val d = data.value listHomepageItems.clear() - currentHomePage = d - (home_master_recycler?.adapter as? ParentItemAdapter?)?.updateList( - d?.items?.mapNotNull { - try { - val filter = it.list.filterSearchResponse() - listHomepageItems.addAll(filter) - it.copy(list = filter) - } catch (e: Exception) { - logError(e) - null - } - } ?: listOf()) + // println("ITEMCOUNT: ${d.values.size} ${home_master_recycler?.adapter?.itemCount}") + (home_master_recycler?.adapter as? ParentItemAdapter?)?.updateList(d.values.toMutableList()) home_loading?.isVisible = false home_loading_error?.isVisible = false @@ -603,13 +588,6 @@ class HomeFragment : Fragment() { } } - val adapter: RecyclerView.Adapter = - ParentItemAdapter(mutableListOf(), { callback -> - homeHandleSearch(callback) - }, { item -> - activity?.loadHomepageList(item) - }) - val toggleList = listOf( Pair(home_type_watching_btt, WatchType.WATCHING), Pair(home_type_completed_btt, WatchType.COMPLETED), @@ -861,9 +839,19 @@ class HomeFragment : Fragment() { context?.fixPaddingStatusbarView(home_statusbar) context?.fixPaddingStatusbar(home_loading_statusbar) - - home_master_recycler.adapter = adapter - home_master_recycler.layoutManager = GridLayoutManager(context, 1) + home_master_recycler.adapter = + ParentItemAdapter(mutableListOf(), { callback -> + homeHandleSearch(callback) + }, { item -> + activity?.loadHomepageList(item) + }, { name -> + homeViewModel.expand(name) + }) + home_master_recycler.layoutManager = object : LinearLayoutManager(context) { + override fun supportsPredictiveItemAnimations(): Boolean { + return false + } + }; // GridLayoutManager(context, 1).also { it.supportsPredictiveItemAnimations() } if (context?.isTvSettings() == false) { LinearSnapHelper().attachToRecyclerView(home_main_poster_recyclerview) // snap diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt index 831ab913..15b242ed 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt @@ -13,18 +13,22 @@ import com.lagradost.cloudstream3.ui.search.SearchClickCallback import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import kotlinx.android.synthetic.main.homepage_parent.view.* + class ParentItemAdapter( - private var items: MutableList, + private var items: MutableList, private val clickCallback: (SearchClickCallback) -> Unit, private val moreInfoClickCallback: (HomePageList) -> Unit, + private val expandCallback: ((String) -> Unit)? = null, ) : RecyclerView.Adapter() { + override fun onCreateViewHolder(parent: ViewGroup, i: Int): ParentViewHolder { val layout = if (parent.context.isTvSettings()) R.layout.homepage_parent_tv else R.layout.homepage_parent return ParentViewHolder( LayoutInflater.from(parent.context).inflate(layout, parent, false), clickCallback, - moreInfoClickCallback + moreInfoClickCallback, + expandCallback ) } @@ -41,28 +45,41 @@ class ParentItemAdapter( } override fun getItemId(position: Int): Long { - return items[position].name.hashCode().toLong() + return items[position].list.name.hashCode().toLong() } + @JvmName("updateListHomePageList") fun updateList(newList: List) { - // this moves all bad results to the bottom - val endList = mutableListOf() - val newFilteredList = mutableListOf() - for (item in newList) { - if (item.list.isEmpty()) { - endList.add(item) - } else { - newFilteredList.add(item) - } - } - newFilteredList.addAll(endList) + updateList(newList.map { HomeViewModel.ExpandableHomepageList(it, 1, false) } + .toMutableList()) + } + @JvmName("updateListExpandableHomepageList") + fun updateList(newList: MutableList) { val diffResult = DiffUtil.calculateDiff( - SearchDiffCallback(this.items, newFilteredList) + SearchDiffCallback(items, newList) ) - items.clear() - items.addAll(newFilteredList) + items.addAll(newList.map { it.copy(list = it.list.copy()) }) // I have to do this otherwise it is a "copy" and dispatchUpdatesTo wont work + + /*val mAdapter = this + diffResult.dispatchUpdatesTo(object : ListUpdateCallback { + override fun onInserted(position: Int, count: Int) { + mAdapter.notifyItemRangeInserted(position, count) + } + + override fun onRemoved(position: Int, count: Int) { + mAdapter.notifyItemRangeRemoved(position, count) + } + + override fun onMoved(fromPosition: Int, toPosition: Int) { + mAdapter.notifyItemMoved(fromPosition, toPosition) + } + + override fun onChanged(position: Int, count: Int, payload: Any?) { + mAdapter.notifyItemRangeChanged(position, count, payload) + } + })*/ diffResult.dispatchUpdatesTo(this) } @@ -71,14 +88,16 @@ class ParentItemAdapter( constructor( itemView: View, private val clickCallback: (SearchClickCallback) -> Unit, - private val moreInfoClickCallback: (HomePageList) -> Unit + private val moreInfoClickCallback: (HomePageList) -> Unit, + private val expandCallback: ((String) -> Unit)? = null, ) : RecyclerView.ViewHolder(itemView) { val title: TextView = itemView.home_parent_item_title val recyclerView: RecyclerView = itemView.home_child_recyclerview private val moreInfo: FrameLayout? = itemView.home_child_more_info - fun bind(info: HomePageList) { - title.text = info.name + + fun bind(expand: HomeViewModel.ExpandableHomepageList) { + val info = expand.list recyclerView.adapter = HomeChildItemAdapter( info.list.toMutableList(), clickCallback = clickCallback, @@ -88,6 +107,23 @@ class ParentItemAdapter( isHorizontal = info.isHorizontalImages } + title.text = info.name + + recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { + var expandCount = 0 + val name = expand.list.name + + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + super.onScrollStateChanged(recyclerView, newState) + + val count = recyclerView.adapter?.itemCount ?: return + if (!recyclerView.canScrollHorizontally(1) && expand.hasNext && expandCount != count) { + expandCount = count + expandCallback?.invoke(name) + } + } + }) + //(recyclerView.adapter as HomeChildItemAdapter).notifyDataSetChanged() moreInfo?.setOnClickListener { @@ -98,17 +134,22 @@ class ParentItemAdapter( } class SearchDiffCallback( - private val oldList: List, - private val newList: List + private val oldList: List, + private val newList: List ) : DiffUtil.Callback() { override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int) = - oldList[oldItemPosition].name == newList[newItemPosition].name + oldList[oldItemPosition].list.name == newList[newItemPosition].list.name override fun getOldListSize() = oldList.size override fun getNewListSize() = newList.size - override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = oldList[oldItemPosition] == newList[newItemPosition] + //{ + // val ret = oldList[oldItemPosition].list.list.size == newList[newItemPosition].list.list.size + // println(">>>>>>>>>>>>>>>> $ret ${oldList[oldItemPosition].list.list.size} == ${newList[newItemPosition].list.list.size}") + // return ret + //} } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt index 0d729e4f..22b5e90d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt @@ -10,10 +10,12 @@ import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull import com.lagradost.cloudstream3.AcraApplication.Companion.context import com.lagradost.cloudstream3.AcraApplication.Companion.getKey import com.lagradost.cloudstream3.AcraApplication.Companion.setKey -import com.lagradost.cloudstream3.HomePageResponse +import com.lagradost.cloudstream3.HomePageList import com.lagradost.cloudstream3.MainAPI import com.lagradost.cloudstream3.SearchResponse import com.lagradost.cloudstream3.mvvm.Resource +import com.lagradost.cloudstream3.mvvm.debugAssert +import com.lagradost.cloudstream3.mvvm.debugWarning import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.ui.APIRepository import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi @@ -34,6 +36,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.* +import kotlin.collections.set class HomeViewModel : ViewModel() { private var repo: APIRepository? = null @@ -41,9 +44,6 @@ class HomeViewModel : ViewModel() { private val _apiName = MutableLiveData() val apiName: LiveData = _apiName - private val _page = MutableLiveData>() - val page: LiveData> = _page - private val _randomItems = MutableLiveData?>(null) val randomItems: LiveData?> = _randomItems @@ -51,8 +51,10 @@ class HomeViewModel : ViewModel() { return APIRepository(apis.first { it.hasMainPage }) } - private val _availableWatchStatusTypes = MutableLiveData, EnumSet>>() - val availableWatchStatusTypes: LiveData, EnumSet>> = _availableWatchStatusTypes + private val _availableWatchStatusTypes = + MutableLiveData, EnumSet>>() + val availableWatchStatusTypes: LiveData, EnumSet>> = + _availableWatchStatusTypes private val _bookmarks = MutableLiveData>>() val bookmarks: LiveData>> = _bookmarks @@ -143,6 +145,64 @@ class HomeViewModel : ViewModel() { onGoingLoad = load(api) } + data class ExpandableHomepageList( + var list: HomePageList, + var currentPage: Int, + var hasNext: Boolean, + ) + + private val expandable: MutableMap = mutableMapOf() + private val _page = + MutableLiveData>>(Resource.Loading()) + val page: LiveData>> = _page + + val lock: MutableSet = mutableSetOf() + + // this is soo over engineered, but idk how I can make it clean without making the main api harder to use :pensive: + fun expand(name: String) = viewModelScope.launch { + if (lock.contains(name)) return@launch + lock += name + + repo?.apply { + expandable[name]?.let { current -> + debugAssert({ !current.hasNext }) { + "Expand called when not needed" + } + + val nextPage = current.currentPage + 1 + val next = getMainPage(nextPage, mainPage.indexOfFirst { it.name == name }) + if (next is Resource.Success) { + next.value.filterNotNull().forEach { main -> + main.items.forEach { newList -> + val key = newList.name + expandable[key]?.apply { + hasNext = main.hasNext + currentPage = nextPage + + debugWarning({ newList.list.any { outer -> this.list.list.any { it.url == outer.url } } }) { + "Expanded contained an item that was previously already in the list\n${list.name} = ${this.list.list}\n${newList.name} = ${newList.list}" + } + + val before = list.list.size + this.list.list += newList.list + this.list.list.distinctBy { it.url } // just to be sure we are not adding the same shit for some reason + expandable[key] = this + val after = list.list.size + } ?: debugWarning { + "Expanded an item not in main load named $key, current list is ${expandable.keys}" + } + } + } + } else { + current.hasNext = false + } + } + _page.postValue(Resource.Success(expandable)) + } + + lock -= name + } + private fun load(api: MainAPI?) = viewModelScope.launch { repo = if (api != null) { APIRepository(api) @@ -156,35 +216,43 @@ class HomeViewModel : ViewModel() { if (repo?.hasMainPage == true) { _page.postValue(Resource.Loading()) - val data = repo?.getMainPage() - when (data) { + when (val data = repo?.getMainPage(1, null)) { is Resource.Success -> { try { - val home = data.value - if (home?.items?.isNullOrEmpty() == false) { + expandable.clear() + data.value.forEach { home -> + home?.items?.forEach { list -> + expandable[list.name] = + ExpandableHomepageList(list, 1, home.hasNext) + } + } + _page.postValue(Resource.Success(expandable)) + val items = data.value.mapNotNull { it?.items }.flatten() + + //val home = data.value + if (items.isNotEmpty()) { val currentList = - home.items.shuffled().filter { !it.list.isNullOrEmpty() }.flatMap { it.list } + items.shuffled().filter { it.list.isNotEmpty() } + .flatMap { it.list } .distinctBy { it.url } .toList() - if (!currentList.isNullOrEmpty()) { + if (currentList.isNotEmpty()) { val randomItems = currentList.shuffled() _randomItems.postValue(randomItems) } } - } catch (e : Exception) { + } catch (e: Exception) { _randomItems.postValue(emptyList()) logError(e) } } + is Resource.Failure -> { + _page.postValue(data!!) + } else -> Unit } - data?.let { - _page.postValue(it) - } - } else { - _page.postValue(Resource.Success(HomePageResponse(emptyList()))) } } @@ -194,7 +262,7 @@ class HomeViewModel : ViewModel() { loadAndCancel(noneApi) else if (preferredApiName == randomApi.name || api == null) { val validAPIs = context?.filterProviderByPreferredMedia() - if(validAPIs.isNullOrEmpty()) { + if (validAPIs.isNullOrEmpty()) { loadAndCancel(noneApi) } else { val apiRandom = validAPIs.random() From e7cec31b612bfb07f3db49a81046c2a9c2ff5a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samet=20Mert=20Karata=C5=9F?= <107170849+samertkaratas@users.noreply.github.com> Date: Sat, 30 Jul 2022 15:32:41 +0300 Subject: [PATCH 2/4] Update Turkish translation (#1366) --- app/src/main/res/values-tr/strings.xml | 36 ++++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 8037d404..0fd76192 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -1,17 +1,17 @@ - %d %s | %sMB - %s • %sGB - %sMB / %sMB - %dMB - %s %s - +%d - -%d - %d - %d - %.1f/10.0 - %d + %d %s | %sMB + %s • %sGB + %sMB / %sMB + %dMB + %s %s + +%d + -%d + %d + %d + %.1f/10.0 + %d %s Ep %d Cast: %s Bölüm %d şu tarihte yayınlanacak: @@ -39,6 +39,7 @@ %d dakika CloudStream + CloudStream ile oynat Ana sayfa Arama İndirilenler @@ -66,6 +67,7 @@ Yeniden izleniyor Filmi oynat + Canlı yayını oynat Torrent oynat Kaynaklar Alt yazılar @@ -268,6 +270,7 @@ Belgeseller OVA Asya dramaları + Canlı yayınlar Film @@ -278,6 +281,7 @@ Torrent Belgesel Asya draması + Canlı yayın Kaynak hatası Sunucu hatası @@ -495,5 +499,15 @@ Fragman Yayına bağlan Yönlendiren + İleri + Videoları bu dillerde izle + Geri + Kurulumu atla + + Merhaba boş parça + Cihazınıza uygun görünümü seçin + Çökme raporları + Ne izlemek istiyorsunuz? + Bitti From a6143be10eff4ff78afdc490ba092792b8b01538 Mon Sep 17 00:00:00 2001 From: xzolw <47160138+xzolw@users.noreply.github.com> Date: Sat, 30 Jul 2022 15:46:36 +0200 Subject: [PATCH 3/4] Update strings.xml (#1367) --- app/src/main/res/values-pl/strings.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index a514c96c..8fbd69d4 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -367,8 +367,8 @@ Pomocniczy Źródło - Losowy + Już wkrótce… Cam Cam @@ -391,4 +391,11 @@ Błąd Usuń informacje dla niesłyszących z napisów Usuń nadmiarowe informacje z napisów + Dalej + Wyświetlaj filmy w wybranych językach + Cofnij + Pomiń + Dostosuj wygląd aplikacji do urządzenia + Preferowany rodzaj filmów + Gotowe From d3b3091fe0e2b8b0c0720ccdf608fadd99e45409 Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Sat, 30 Jul 2022 17:30:23 +0200 Subject: [PATCH 4/4] made inf scrolling better + fixed search bug --- .../animeproviders/AniflixProvider.kt | 2 - .../ui/home/HomeChildItemAdapter.kt | 1 + .../cloudstream3/ui/home/HomeFragment.kt | 61 ++++++++++++- .../ui/home/HomeParentItemAdapter.kt | 90 ++++++++++++++++--- .../cloudstream3/ui/home/HomeViewModel.kt | 15 ++-- .../ui/quicksearch/QuickSearchFragment.kt | 3 +- .../cloudstream3/ui/search/SearchAdaptor.kt | 1 + .../cloudstream3/ui/search/SearchFragment.kt | 2 +- .../cloudstream3/ui/search/SearchViewModel.kt | 45 ++++++---- .../lagradost/cloudstream3/utils/AppUtils.kt | 6 ++ 10 files changed, 179 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniflixProvider.kt index 0d7f82fc..5500b57b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/AniflixProvider.kt @@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.animeproviders import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId -import com.lagradost.cloudstream3.utils.AppUtils.parseJson import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.getQualityFromName import java.net.URLDecoder @@ -75,7 +74,6 @@ class AniflixProvider : MainAPI() { val token = getToken() val url = "$mainUrl/_next/data/$token/search.json?keyword=$query" val response = app.get(url) - println("resp: $url ===> ${response.text}") val searchResponse = response.parsedSafe() ?: throw ErrorLoadingException("No Media") diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeChildItemAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeChildItemAdapter.kt index 7a4a43a6..7b3e430d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeChildItemAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeChildItemAdapter.kt @@ -24,6 +24,7 @@ class HomeChildItemAdapter( ) : RecyclerView.Adapter() { var isHorizontal: Boolean = false + var hasNext : Boolean = false override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { val layout = overrideLayout diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index f6d0babf..b1dde1d7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -22,6 +22,7 @@ import androidx.fragment.app.activityViewModels import androidx.preference.PreferenceManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearSnapHelper +import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.button.MaterialButton import com.lagradost.cloudstream3.* @@ -46,6 +47,8 @@ import com.lagradost.cloudstream3.ui.search.SearchHelper.handleSearchClickCallba import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult +import com.lagradost.cloudstream3.utils.AppUtils.setMaxViewPoolSize +import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.setKey import com.lagradost.cloudstream3.utils.DataStoreHelper @@ -119,11 +122,27 @@ class HomeFragment : Fragment() { val errorProfilePic = errorProfilePics.random() - fun Activity.loadHomepageList(item: HomePageList, deleteCallback: (() -> Unit)? = null) { + fun Activity.loadHomepageList( + item: HomePageList, + deleteCallback: (() -> Unit)? = null, + ) { + loadHomepageList( + expand = HomeViewModel.ExpandableHomepageList(item, 1, false), + deleteCallback = deleteCallback, + expandCallback = null + ) + } + + fun Activity.loadHomepageList( + expand: HomeViewModel.ExpandableHomepageList, + deleteCallback: (() -> Unit)? = null, + expandCallback: (suspend (String) -> HomeViewModel.ExpandableHomepageList?)? = null + ) { val context = this val bottomSheetDialogBuilder = BottomSheetDialog(context) bottomSheetDialogBuilder.setContentView(R.layout.home_episodes_expanded) val title = bottomSheetDialogBuilder.findViewById(R.id.home_expanded_text)!! + val item = expand.list title.text = item.name val recycle = bottomSheetDialogBuilder.findViewById(R.id.home_expanded_recycler)!! @@ -176,8 +195,36 @@ class HomeFragment : Fragment() { if (callback.action == SEARCH_ACTION_LOAD || callback.action == SEARCH_ACTION_PLAY_FILE) { bottomSheetDialogBuilder.dismissSafe(this) } + }.apply { + hasNext = expand.hasNext } + recycle.addOnScrollListener(object : RecyclerView.OnScrollListener() { + var expandCount = 0 + val name = expand.list.name + + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + super.onScrollStateChanged(recyclerView, newState) + + val adapter = recyclerView.adapter + if (adapter !is SearchAdapter) return + + val count = adapter.itemCount + val currentHasNext = adapter.hasNext + if (!recyclerView.canScrollVertically(1) && currentHasNext && expandCount != count) { + expandCount = count + ioSafe { + expandCallback?.invoke(name)?.let { newExpand -> + (recyclerView.adapter as? SearchAdapter?)?.apply { + hasNext = newExpand.hasNext + updateList(newExpand.list.list) + } + } + } + } + } + }) + val spanListener = { span: Int -> recycle.spanCount = span //(recycle.adapter as SearchAdapter).notifyDataSetChanged() @@ -537,7 +584,10 @@ class HomeFragment : Fragment() { listHomepageItems.clear() // println("ITEMCOUNT: ${d.values.size} ${home_master_recycler?.adapter?.itemCount}") - (home_master_recycler?.adapter as? ParentItemAdapter?)?.updateList(d.values.toMutableList()) + (home_master_recycler?.adapter as? ParentItemAdapter?)?.updateList( + d.values.toMutableList(), + home_master_recycler + ) home_loading?.isVisible = false home_loading_error?.isVisible = false @@ -843,15 +893,18 @@ class HomeFragment : Fragment() { ParentItemAdapter(mutableListOf(), { callback -> homeHandleSearch(callback) }, { item -> - activity?.loadHomepageList(item) + activity?.loadHomepageList(item, expandCallback = { + homeViewModel.expandAndReturn(it) + }) }, { name -> homeViewModel.expand(name) }) + home_master_recycler?.setMaxViewPoolSize(0, Int.MAX_VALUE) home_master_recycler.layoutManager = object : LinearLayoutManager(context) { override fun supportsPredictiveItemAnimations(): Boolean { return false } - }; // GridLayoutManager(context, 1).also { it.supportsPredictiveItemAnimations() } + } // GridLayoutManager(context, 1).also { it.supportsPredictiveItemAnimations() } if (context?.isTvSettings() == false) { LinearSnapHelper().attachToRecyclerView(home_main_poster_recyclerview) // snap diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt index 15b242ed..170bab4c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt @@ -6,10 +6,12 @@ import android.view.ViewGroup import android.widget.FrameLayout import android.widget.TextView import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListUpdateCallback import androidx.recyclerview.widget.RecyclerView import com.lagradost.cloudstream3.HomePageList import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.ui.search.SearchClickCallback +import com.lagradost.cloudstream3.ui.search.SearchFragment.Companion.filterSearchResponse import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import kotlinx.android.synthetic.main.homepage_parent.view.* @@ -17,11 +19,12 @@ import kotlinx.android.synthetic.main.homepage_parent.view.* class ParentItemAdapter( private var items: MutableList, private val clickCallback: (SearchClickCallback) -> Unit, - private val moreInfoClickCallback: (HomePageList) -> Unit, + private val moreInfoClickCallback: (HomeViewModel.ExpandableHomepageList) -> Unit, private val expandCallback: ((String) -> Unit)? = null, ) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, i: Int): ParentViewHolder { + //println("onCreateViewHolder $i") val layout = if (parent.context.isTvSettings()) R.layout.homepage_parent_tv else R.layout.homepage_parent return ParentViewHolder( @@ -33,6 +36,8 @@ class ParentItemAdapter( } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + //println("onBindViewHolder $position") + when (holder) { is ParentViewHolder -> { holder.bind(items[position]) @@ -55,14 +60,25 @@ class ParentItemAdapter( } @JvmName("updateListExpandableHomepageList") - fun updateList(newList: MutableList) { + fun updateList( + newList: MutableList, + recyclerView: RecyclerView? = null + ) { + // this + // 1. prevents deep copy that makes this.items == newList + // 2. filters out undesirable results + // 3. moves empty results to the bottom (sortedBy is a stable sort) + val new = + newList.map { it.copy(list = it.list.copy(list = it.list.list.filterSearchResponse())) } + .sortedBy { it.list.list.isEmpty() } + val diffResult = DiffUtil.calculateDiff( - SearchDiffCallback(items, newList) + SearchDiffCallback(items, new) ) items.clear() - items.addAll(newList.map { it.copy(list = it.list.copy()) }) // I have to do this otherwise it is a "copy" and dispatchUpdatesTo wont work + items.addAll(new) - /*val mAdapter = this + val mAdapter = this diffResult.dispatchUpdatesTo(object : ListUpdateCallback { override fun onInserted(position: Int, count: Int) { mAdapter.notifyItemRangeInserted(position, count) @@ -77,18 +93,44 @@ class ParentItemAdapter( } override fun onChanged(position: Int, count: Int, payload: Any?) { - mAdapter.notifyItemRangeChanged(position, count, payload) - } - })*/ + // I know kinda messy, what this does is using the update or bind instead of onCreateViewHolder -> bind + recyclerView?.apply { + // this loops every viewHolder in the recycle view and checks the position to see if it is within the update range + val missingUpdates = (position until (position + count)).toMutableSet() + for (i in 0 until mAdapter.itemCount) { + val viewHolder = getChildViewHolder(getChildAt(i)) + val absolutePosition = viewHolder.absoluteAdapterPosition + if (absolutePosition >= position && absolutePosition < position + count) { + val expand = items.getOrNull(absolutePosition) ?: continue + if (viewHolder is ParentViewHolder) { + missingUpdates -= absolutePosition + if (viewHolder.title.text == expand.list.name) { + viewHolder.update(expand) + } else { + viewHolder.bind(expand) + } + } + } + } - diffResult.dispatchUpdatesTo(this) + // just in case some item did not get updated + for (i in missingUpdates) { + mAdapter.notifyItemChanged(i, payload) + } + } ?: run { // in case we don't have a nice + mAdapter.notifyItemRangeChanged(position, count, payload) + } + } + }) + + //diffResult.dispatchUpdatesTo(this) } class ParentViewHolder constructor( itemView: View, private val clickCallback: (SearchClickCallback) -> Unit, - private val moreInfoClickCallback: (HomePageList) -> Unit, + private val moreInfoClickCallback: (HomeViewModel.ExpandableHomepageList) -> Unit, private val expandCallback: ((String) -> Unit)? = null, ) : RecyclerView.ViewHolder(itemView) { @@ -96,6 +138,23 @@ class ParentItemAdapter( val recyclerView: RecyclerView = itemView.home_child_recyclerview private val moreInfo: FrameLayout? = itemView.home_child_more_info + fun update(expand: HomeViewModel.ExpandableHomepageList) { + val info = expand.list + (recyclerView.adapter as? HomeChildItemAdapter?)?.apply { + updateList(info.list.toMutableList()) + hasNext = expand.hasNext + } ?: run { + recyclerView.adapter = HomeChildItemAdapter( + info.list.toMutableList(), + clickCallback = clickCallback, + nextFocusUp = recyclerView.nextFocusUpId, + nextFocusDown = recyclerView.nextFocusDownId, + ).apply { + isHorizontal = info.isHorizontalImages + } + } + } + fun bind(expand: HomeViewModel.ExpandableHomepageList) { val info = expand.list recyclerView.adapter = HomeChildItemAdapter( @@ -105,6 +164,7 @@ class ParentItemAdapter( nextFocusDown = recyclerView.nextFocusDownId, ).apply { isHorizontal = info.isHorizontalImages + hasNext = expand.hasNext } title.text = info.name @@ -116,8 +176,12 @@ class ParentItemAdapter( override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) - val count = recyclerView.adapter?.itemCount ?: return - if (!recyclerView.canScrollHorizontally(1) && expand.hasNext && expandCount != count) { + val adapter = recyclerView.adapter + if (adapter !is HomeChildItemAdapter) return + + val count = adapter.itemCount + val hasNext = adapter.hasNext + if (!recyclerView.canScrollHorizontally(1) && hasNext && expandCount != count) { expandCount = count expandCallback?.invoke(name) } @@ -127,7 +191,7 @@ class ParentItemAdapter( //(recyclerView.adapter as HomeChildItemAdapter).notifyDataSetChanged() moreInfo?.setOnClickListener { - moreInfoClickCallback.invoke(info) + moreInfoClickCallback.invoke(expand) } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt index 22b5e90d..14290fca 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt @@ -158,9 +158,8 @@ class HomeViewModel : ViewModel() { val lock: MutableSet = mutableSetOf() - // this is soo over engineered, but idk how I can make it clean without making the main api harder to use :pensive: - fun expand(name: String) = viewModelScope.launch { - if (lock.contains(name)) return@launch + suspend fun expandAndReturn(name: String) : ExpandableHomepageList? { + if (lock.contains(name)) return null lock += name repo?.apply { @@ -183,11 +182,8 @@ class HomeViewModel : ViewModel() { "Expanded contained an item that was previously already in the list\n${list.name} = ${this.list.list}\n${newList.name} = ${newList.list}" } - val before = list.list.size this.list.list += newList.list this.list.list.distinctBy { it.url } // just to be sure we are not adding the same shit for some reason - expandable[key] = this - val after = list.list.size } ?: debugWarning { "Expanded an item not in main load named $key, current list is ${expandable.keys}" } @@ -201,6 +197,13 @@ class HomeViewModel : ViewModel() { } lock -= name + + return expandable[name] + } + + // this is soo over engineered, but idk how I can make it clean without making the main api harder to use :pensive: + fun expand(name: String) = viewModelScope.launch { + expandAndReturn(name) } private fun load(api: MainAPI?) = viewModelScope.launch { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/quicksearch/QuickSearchFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/quicksearch/QuickSearchFragment.kt index 7fea40d0..df53f209 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/quicksearch/QuickSearchFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/quicksearch/QuickSearchFragment.kt @@ -27,7 +27,6 @@ import com.lagradost.cloudstream3.ui.home.HomeFragment.Companion.loadHomepageLis import com.lagradost.cloudstream3.ui.home.ParentItemAdapter import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchClickCallback -import com.lagradost.cloudstream3.ui.search.SearchFragment.Companion.filterSearchResponse import com.lagradost.cloudstream3.ui.search.SearchHelper import com.lagradost.cloudstream3.ui.search.SearchViewModel import com.lagradost.cloudstream3.utils.UIHelper @@ -173,7 +172,7 @@ class QuickSearchFragment : Fragment() { updateList(list.map { ongoing -> val ongoingList = HomePageList( ongoing.apiName, - if (ongoing.data is Resource.Success) ongoing.data.value.filterSearchResponse() else ArrayList() + if (ongoing.data is Resource.Success) ongoing.data.value else ArrayList() ) ongoingList }) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchAdaptor.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchAdaptor.kt index fe442e2b..c2523931 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchAdaptor.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchAdaptor.kt @@ -27,6 +27,7 @@ class SearchAdapter( private val resView: AutofitRecyclerView, private val clickCallback: (SearchClickCallback) -> Unit, ) : RecyclerView.Adapter() { + var hasNext : Boolean = false override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { val layout = if(parent.context.IsBottomLayout()) R.layout.search_result_grid_expanded else R.layout.search_result_grid diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt index fc2d1064..d05d8807 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt @@ -426,7 +426,7 @@ class SearchFragment : Fragment() { val newItems = list.map { ongoing -> val ongoingList = HomePageList( ongoing.apiName, - if (ongoing.data is Resource.Success) ongoing.data.value.filterSearchResponse() else ArrayList() + if (ongoing.data is Resource.Success) ongoing.data.value else ArrayList() ) ongoingList } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchViewModel.kt index e8e37b9d..e02d37f8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchViewModel.kt @@ -43,6 +43,7 @@ class SearchViewModel : ViewModel() { _currentSearch.postValue(emptyList()) } + private var currentSearchIndex = 0 private var onGoingSearch: Job? = null fun searchAndCancel( query: String, @@ -50,6 +51,7 @@ class SearchViewModel : ViewModel() { ignoreSettings: Boolean = false, isQuickSearch: Boolean = false, ) { + currentSearchIndex++ onGoingSearch?.cancel() onGoingSearch = search(query, providersActive, ignoreSettings, isQuickSearch) } @@ -70,6 +72,7 @@ class SearchViewModel : ViewModel() { isQuickSearch: Boolean = false, ) = viewModelScope.launch { + val currentIndex = currentSearchIndex if (query.length <= 1) { clearSearch() return@launch @@ -91,40 +94,44 @@ class SearchViewModel : ViewModel() { _searchResponse.postValue(Resource.Loading()) - val currentList = ArrayList() _currentSearch.postValue(ArrayList()) withContext(Dispatchers.IO) { // This interrupts UI otherwise + val currentList = ArrayList() + repos.filter { a -> (ignoreSettings || (providersActive.isEmpty() || providersActive.contains(a.name))) && (!isQuickSearch || a.hasQuickSearch) }.apmap { a -> // Parallel val search = if (isQuickSearch) a.quickSearch(query) else a.search(query) + if(currentSearchIndex != currentIndex) return@apmap currentList.add(OnGoingSearch(a.name, search)) _currentSearch.postValue(currentList) } - } - _currentSearch.postValue(currentList) - val list = ArrayList() - val nestedList = - currentList.map { it.data } - .filterIsInstance>>().map { it.value } + if(currentSearchIndex != currentIndex) return@withContext // this should prevent rewrite of existing data bug - // I do it this way to move the relevant search results to the top - var index = 0 - while (true) { - var added = 0 - for (sublist in nestedList) { - if (sublist.size > index) { - list.add(sublist[index]) - added++ + _currentSearch.postValue(currentList) + val list = ArrayList() + val nestedList = + currentList.map { it.data } + .filterIsInstance>>().map { it.value } + + // I do it this way to move the relevant search results to the top + var index = 0 + while (true) { + var added = 0 + for (sublist in nestedList) { + if (sublist.size > index) { + list.add(sublist[index]) + added++ + } } + if (added == 0) break + index++ } - if (added == 0) break - index++ - } - _searchResponse.postValue(Resource.Success(list)) + _searchResponse.postValue(Resource.Success(list)) + } } } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt index bdfc7b7d..5b7223d3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt @@ -26,6 +26,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.text.HtmlCompat import androidx.core.text.toSpanned +import androidx.recyclerview.widget.RecyclerView import androidx.tvprovider.media.tv.PreviewChannelHelper import androidx.tvprovider.media.tv.TvContractCompat import androidx.tvprovider.media.tv.WatchNextProgram @@ -52,6 +53,11 @@ import java.net.URL import java.net.URLDecoder object AppUtils { + fun RecyclerView.setMaxViewPoolSize(maxViewTypeId: Int, maxPoolSize: Int) { + for (i in 0..maxViewTypeId) + recycledViewPool.setMaxRecycledViews(i, maxPoolSize) + } + //fun Context.deleteFavorite(data: SearchResponse) { // if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return // normalSafeApiCall {