From d265f92a0dd654296075073153c0a377bd0e85e7 Mon Sep 17 00:00:00 2001 From: CakesTwix Date: Thu, 7 Nov 2024 07:41:49 +0200 Subject: [PATCH] uaserial: Fix search --- UASerialProvider/build.gradle.kts | 2 +- .../kotlin/com/lagradost/UASerialProvider.kt | 20 +++++++++---------- .../com/lagradost/models/SearchModel.kt | 13 ++++++++++++ 3 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 UASerialProvider/src/main/kotlin/com/lagradost/models/SearchModel.kt diff --git a/UASerialProvider/build.gradle.kts b/UASerialProvider/build.gradle.kts index 075a8b5..1cc5db4 100644 --- a/UASerialProvider/build.gradle.kts +++ b/UASerialProvider/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 9 +version = 10 dependencies { implementation("com.google.code.gson:gson:2.9.0") diff --git a/UASerialProvider/src/main/kotlin/com/lagradost/UASerialProvider.kt b/UASerialProvider/src/main/kotlin/com/lagradost/UASerialProvider.kt index dc492e1..1b5fb85 100644 --- a/UASerialProvider/src/main/kotlin/com/lagradost/UASerialProvider.kt +++ b/UASerialProvider/src/main/kotlin/com/lagradost/UASerialProvider.kt @@ -7,6 +7,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.models.GeneralInfo import com.lagradost.models.GeneralInfoMovie +import com.lagradost.models.SearchModel import org.jsoup.nodes.Element open class UASerialProvider(url: String, name: String) : MainAPI() { @@ -53,17 +54,16 @@ open class UASerialProvider(url: String, name: String) : MainAPI() { } override suspend fun search(query: String): List { - val document = app.post( - url = mainUrl, - data = mapOf( - "do" to "search", - "subaction" to "search", - "story" to query.replace(" ", "+") - ) - ).document + val searchResult = app.get( + url = "$mainUrl/search-ajax?query=$query", + ).text - return document.select("article.short").map { - it.toSearchResponse() + val searchJson = Gson().fromJson(searchResult, SearchModel::class.java) + + return searchJson.movies.map { + newMovieSearchResponse(it.name, it.link, TvType.Movie) { + this.posterUrl = "$mainUrl${it.poster}" + } } } diff --git a/UASerialProvider/src/main/kotlin/com/lagradost/models/SearchModel.kt b/UASerialProvider/src/main/kotlin/com/lagradost/models/SearchModel.kt new file mode 100644 index 0000000..6bfef87 --- /dev/null +++ b/UASerialProvider/src/main/kotlin/com/lagradost/models/SearchModel.kt @@ -0,0 +1,13 @@ +package com.lagradost.models + +import com.google.gson.annotations.SerializedName + +data class SearchModel ( + @SerializedName("movies") val movies : List, +) + +data class Movies ( + @SerializedName("link") val link : String, + @SerializedName("name") val name : String, + @SerializedName("poster") val poster : String +) \ No newline at end of file