11package recloudstream
22
3- import com.lagradost.cloudstream3.*
3+ import com.lagradost.cloudstream3.HomePageList
4+ import com.lagradost.cloudstream3.HomePageResponse
5+ import com.lagradost.cloudstream3.LiveSearchResponse
6+ import com.lagradost.cloudstream3.LoadResponse
7+ import com.lagradost.cloudstream3.MainAPI
8+ import com.lagradost.cloudstream3.MainPageRequest
9+ import com.lagradost.cloudstream3.SearchResponse
10+ import com.lagradost.cloudstream3.SubtitleFile
11+ import com.lagradost.cloudstream3.TvType
12+ import com.lagradost.cloudstream3.app
13+ import com.lagradost.cloudstream3.fixUrl
14+ import com.lagradost.cloudstream3.mainPageOf
15+ import com.lagradost.cloudstream3.newHomePageResponse
16+ import com.lagradost.cloudstream3.newLiveSearchResponse
17+ import com.lagradost.cloudstream3.newLiveStreamLoadResponse
418import com.lagradost.cloudstream3.utils.ExtractorApi
519import com.lagradost.cloudstream3.utils.ExtractorLink
620import com.lagradost.cloudstream3.utils.getQualityFromName
@@ -26,20 +40,21 @@ class TwitchProvider : MainAPI() {
2640
2741 override suspend fun getMainPage (page : Int , request : MainPageRequest ): HomePageResponse {
2842 return when (request.name) {
29- gamesName -> HomePageResponse (parseGames(), hasNext = false ) // Get top games
43+ gamesName -> newHomePageResponse (parseGames(), hasNext = false ) // Get top games
3044 else -> {
3145 val doc = app.get(request.data, params = mapOf (" page" to page.toString())).document
3246 val channels = doc.select(" table#channels tr" ).map { element ->
3347 element.toLiveSearchResponse()
3448 }
35- HomePageResponse (
49+ newHomePageResponse (
3650 listOf (
3751 HomePageList (
3852 request.name,
3953 channels,
4054 isHorizontalImages = isHorizontal
4155 )
42- ), hasNext = true
56+ ),
57+ hasNext = true
4358 )
4459 }
4560 }
@@ -50,7 +65,12 @@ class TwitchProvider : MainAPI() {
5065 val linkName = anchor.attr(" href" ).substringAfterLast(" /" )
5166 val name = anchor.firstOrNull { it.text().isNotBlank() }?.text()
5267 val image = this .select(" img" ).attr(" src" )
53- return LiveSearchResponse (name ? : " " , linkName, this @TwitchProvider.name, TvType .Live , image)
68+ return newLiveSearchResponse(
69+ name ? : " " ,
70+ linkName,
71+ TvType .Live ,
72+ fix = false
73+ ) { posterUrl = image }
5474 }
5575
5676 private suspend fun parseGames (): List <HomePageList > {
@@ -85,7 +105,7 @@ class TwitchProvider : MainAPI() {
85105 val poster = doc.select(" div.embed-responsive > img" ).attr(" src" ).ifEmpty { image }
86106 val description = doc.select(" div[style='word-wrap:break-word;font-size:12px;']" ).text()
87107 val language = doc.select(" a.label.label-soft" ).text().ifEmpty { null }
88- val isLive = ! doc.select(" div.live-indicator-container" ).isEmpty ()
108+ val isLive = doc.select(" div.live-indicator-container" ).isNotEmpty ()
89109
90110 val tags = listOfNotNull(
91111 isLive.let { if (it) " Live" else " Offline" },
@@ -95,9 +115,14 @@ class TwitchProvider : MainAPI() {
95115
96116 val twitchUrl = " https://twitch.tv/$realUrl "
97117
98- return LiveStreamLoadResponse (
99- name, twitchUrl, this .name, twitchUrl, plot = description, posterUrl = image, backgroundPosterUrl = poster, tags = tags
100- )
118+ return newLiveStreamLoadResponse(
119+ name, twitchUrl, twitchUrl
120+ ) {
121+ plot = description
122+ posterUrl = image
123+ backgroundPosterUrl = poster
124+ this @newLiveStreamLoadResponse.tags = tags
125+ }
101126 }
102127
103128 override suspend fun search (query : String ): List <SearchResponse >? {
@@ -145,4 +170,4 @@ class TwitchProvider : MainAPI() {
145170 }
146171 }
147172 }
148- }
173+ }
0 commit comments