From 99d1c2457e6fbb20c37713a20c077d27789043df Mon Sep 17 00:00:00 2001 From: CakesTwix Date: Sat, 17 Aug 2024 22:24:43 +0300 Subject: [PATCH] teleportal: Fix search --- TeleportalProvider/build.gradle.kts | 2 +- .../kotlin/com/lagradost/TeleportalProvider.kt | 11 ++++++++--- .../src/main/kotlin/com/lagradost/models/Search.kt | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 TeleportalProvider/src/main/kotlin/com/lagradost/models/Search.kt diff --git a/TeleportalProvider/build.gradle.kts b/TeleportalProvider/build.gradle.kts index 57766ec..055f1e9 100644 --- a/TeleportalProvider/build.gradle.kts +++ b/TeleportalProvider/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 2 +version = 3 dependencies{ implementation("com.google.code.gson:gson:2.9.0") diff --git a/TeleportalProvider/src/main/kotlin/com/lagradost/TeleportalProvider.kt b/TeleportalProvider/src/main/kotlin/com/lagradost/TeleportalProvider.kt index df54396..cb9767a 100644 --- a/TeleportalProvider/src/main/kotlin/com/lagradost/TeleportalProvider.kt +++ b/TeleportalProvider/src/main/kotlin/com/lagradost/TeleportalProvider.kt @@ -1,6 +1,7 @@ package com.lagradost import com.google.gson.Gson +import com.google.gson.reflect.TypeToken import com.lagradost.cloudstream3.DubStatus import com.lagradost.cloudstream3.Episode import com.lagradost.cloudstream3.HomePageResponse @@ -21,6 +22,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.models.Media import com.lagradost.models.MediaShows +import com.lagradost.models.Search import com.lagradost.models.SeasonModel import com.lagradost.models.TitleShows import com.lagradost.models.VideoPlayer @@ -42,6 +44,8 @@ class TeleportalProvider : MainAPI() { private val findUrl = "$apiUrl/ua/live-search?q=" private val playerUrl = "https://vcms-api2.starlight.digital/player-api/" + private val listSearch = object : TypeToken>() {}.type + // Sections override val mainPage = mainPageOf( "$apiUrl/ua/serials" to "Серіали", @@ -76,10 +80,11 @@ class TeleportalProvider : MainAPI() { } override suspend fun search(query: String): List { - return app.get("$findUrl$query&page=1").parsedSafe()!!.items.map{ - newAnimeSearchResponse(it.title, "$apiUrl${it.videoSlug}", TvType.TvSeries) { - this.posterUrl = "$mainUrl${it.image}" + return Gson().fromJson>(app.get("$findUrl$query").text, listSearch).map{ + newAnimeSearchResponse(it.title, "$apiUrl/ua/${it.typeSlug}/${it.channelSlug}/${it.projectSlug}", TvType.TvSeries) { + this.posterUrl = "$mainUrl/${it.image}" } + } } diff --git a/TeleportalProvider/src/main/kotlin/com/lagradost/models/Search.kt b/TeleportalProvider/src/main/kotlin/com/lagradost/models/Search.kt new file mode 100644 index 0000000..4baf71a --- /dev/null +++ b/TeleportalProvider/src/main/kotlin/com/lagradost/models/Search.kt @@ -0,0 +1,14 @@ +package com.lagradost.models + + +data class Search ( + val id : Int, + val title : String, + val age : Int, + val image : String, + val description : String, + val typeSlug : String, + val channelSlug : String, + val projectSlug : String, + val seasons : String +) \ No newline at end of file