Skip to content

Commit 6f28679

Browse files
authored
Dailymotion: add pagination support (#31)
* Dailymotion: add pagination support * Fix pagination for home page
1 parent 45e8de3 commit 6f28679

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

DailymotionProvider/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// use an integer for version numbers
2-
version = 3
1+
// Use an integer for version numbers
2+
version = 4
33

44
cloudstream {
55
// All of these properties are optional, you can safely remove any of them.

DailymotionProvider/src/main/kotlin/recloudstream/DailymotionProvider.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import com.lagradost.cloudstream3.LoadResponse
77
import com.lagradost.cloudstream3.MainAPI
88
import com.lagradost.cloudstream3.MainPageRequest
99
import com.lagradost.cloudstream3.SearchResponse
10+
import com.lagradost.cloudstream3.SearchResponseList
1011
import com.lagradost.cloudstream3.SubtitleFile
1112
import com.lagradost.cloudstream3.TvType
1213
import com.lagradost.cloudstream3.app
1314
import com.lagradost.cloudstream3.newHomePageResponse
1415
import com.lagradost.cloudstream3.newMovieLoadResponse
1516
import com.lagradost.cloudstream3.newMovieSearchResponse
17+
import com.lagradost.cloudstream3.toNewSearchResponseList
1618
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
1719
import com.lagradost.cloudstream3.utils.ExtractorLink
1820
import com.lagradost.cloudstream3.utils.StringUtils.encodeUri
@@ -46,7 +48,7 @@ class DailymotionProvider : MainAPI() {
4648
override val hasMainPage = true
4749

4850
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
49-
val response = app.get("$mainUrl/videos?fields=id,title,thumbnail_360_url&limit=26").text
51+
val response = app.get("$mainUrl/videos?fields=id,title,thumbnail_360_url&limit=26&page=$page").text
5052
val popular = tryParseJson<VideoSearchResponse>(response)?.list ?: emptyList()
5153

5254
return newHomePageResponse(
@@ -56,15 +58,16 @@ class DailymotionProvider : MainAPI() {
5658
popular.map { it.toSearchResponse(this) },
5759
true
5860
),
59-
),
60-
false
61+
)
6162
)
6263
}
6364

64-
override suspend fun search(query: String): List<SearchResponse> {
65-
val response = app.get("$mainUrl/videos?fields=id,title,thumbnail_360_url&limit=10&search=${query.encodeUri()}").text
66-
val searchResults = tryParseJson<VideoSearchResponse>(response)?.list ?: return emptyList()
67-
return searchResults.map { it.toSearchResponse(this) }
65+
override suspend fun search(query: String, page: Int): SearchResponseList? {
66+
val response = app.get("$mainUrl/videos?fields=id,title,thumbnail_360_url&limit=26&page=$page&search=${query.encodeUri()}").text
67+
val searchResults = tryParseJson<VideoSearchResponse>(response)?.list
68+
return searchResults?.map {
69+
it.toSearchResponse(this)
70+
}?.toNewSearchResponseList()
6871
}
6972

7073
override suspend fun load(url: String): LoadResponse? {

0 commit comments

Comments
 (0)