Skip to content

Commit 0a03630

Browse files
authored
Add crossplatform support and replace deprecations (#25)
1 parent e245d9f commit 0a03630

File tree

11 files changed

+90
-45
lines changed

11 files changed

+90
-45
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ jobs:
3030
path: "builds"
3131

3232
- name: Clean old builds
33-
run: rm $GITHUB_WORKSPACE/builds/*.cs3 || true
33+
run: |
34+
rm $GITHUB_WORKSPACE/builds/*.cs3 || true
35+
rm $GITHUB_WORKSPACE/builds/*.jar || true
3436
3537
- name: Setup JDK 17
3638
uses: actions/setup-java@v1
@@ -45,7 +47,9 @@ jobs:
4547
cd $GITHUB_WORKSPACE/src
4648
chmod +x gradlew
4749
./gradlew make makePluginsJson
50+
./gradlew ensureJarCompatibility
4851
cp **/build/*.cs3 $GITHUB_WORKSPACE/builds
52+
cp **/build/*.jar $GITHUB_WORKSPACE/builds
4953
cp build/plugins.json $GITHUB_WORKSPACE/builds
5054
5155
- name: Push builds

DailymotionProvider/build.gradle.kts

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

44
cloudstream {
55
// All of these properties are optional, you can safely remove any of them.
@@ -18,4 +18,6 @@ cloudstream {
1818

1919
tvTypes = listOf("Others")
2020
iconUrl = "https://www.google.com/s2/favicons?domain=www.dailymotion.com&sz=%size%"
21+
22+
isCrossPlatform = true
2123
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package recloudstream
22

3-
import android.content.Context
3+
import com.lagradost.cloudstream3.plugins.BasePlugin
44
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
5-
import com.lagradost.cloudstream3.plugins.Plugin
65

76
@CloudstreamPlugin
8-
class DailymotionPlugin: Plugin() {
9-
override fun load(context: Context) {
7+
class DailymotionPlugin: BasePlugin() {
8+
override fun load() {
109
// All providers should be added in this manner. Please don't edit the providers list directly.
1110
registerMainAPI(DailymotionProvider())
1211
}

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package recloudstream
22

3+
import com.fasterxml.jackson.annotation.JsonProperty
34
import com.lagradost.cloudstream3.HomePageList
45
import com.lagradost.cloudstream3.HomePageResponse
56
import com.lagradost.cloudstream3.LoadResponse
@@ -20,22 +21,20 @@ import com.lagradost.cloudstream3.utils.loadExtractor
2021
class DailymotionProvider : MainAPI() {
2122

2223
data class VideoSearchResponse(
23-
val list: List<VideoItem>
24+
@JsonProperty("list") val list: List<VideoItem>
2425
)
2526

2627
data class VideoItem(
27-
val id: String,
28-
val title: String,
29-
@Suppress("PropertyName")
30-
val thumbnail_360_url: String
28+
@JsonProperty("id") val id: String,
29+
@JsonProperty("title") val title: String,
30+
@JsonProperty("thumbnail_360_url") val thumbnail360Url: String
3131
)
3232

3333
data class VideoDetailResponse(
34-
val id: String,
35-
val title: String,
36-
val description: String,
37-
@Suppress("PropertyName")
38-
val thumbnail_720_url: String
34+
@JsonProperty("id") val id: String,
35+
@JsonProperty("title") val title: String,
36+
@JsonProperty("description") val description: String,
37+
@JsonProperty("thumbnail_720_url") val thumbnail720Url: String
3938
)
4039

4140
override var mainUrl = "https://api.dailymotion.com"
@@ -81,7 +80,7 @@ class DailymotionProvider : MainAPI() {
8180
"https://www.dailymotion.com/video/${this.id}",
8281
TvType.Movie
8382
) {
84-
this.posterUrl = thumbnail_360_url
83+
this.posterUrl = thumbnail360Url
8584
}
8685
}
8786

@@ -93,7 +92,7 @@ class DailymotionProvider : MainAPI() {
9392
this.id
9493
) {
9594
plot = description
96-
posterUrl = thumbnail_720_url
95+
posterUrl = thumbnail720Url
9796
}
9897
}
9998

InvidiousProvider/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// use an integer for version numbers
2-
version = 7
2+
version = 8
33

44
cloudstream {
55
// All of these properties are optional, you can safely remove any of them.
@@ -18,4 +18,6 @@ cloudstream {
1818

1919
tvTypes = listOf("Others")
2020
iconUrl = "https://www.google.com/s2/favicons?domain=invidious.io&sz=%size%"
21+
22+
isCrossPlatform = true
2123
}

InvidiousProvider/src/main/kotlin/recloudstream/InvidiousPlugin.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package recloudstream
22

3+
import com.lagradost.cloudstream3.plugins.BasePlugin
34
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
4-
import com.lagradost.cloudstream3.plugins.Plugin
5-
import android.content.Context
65

76
@CloudstreamPlugin
8-
class InvidiousPlugin: Plugin() {
9-
override fun load(context: Context) {
7+
class InvidiousPlugin: BasePlugin() {
8+
override fun load() {
109
// All providers should be added in this manner. Please don't edit the providers list directly.
1110
registerMainAPI(InvidiousProvider())
1211
}

InvidiousProvider/src/main/kotlin/recloudstream/InvidiousProvider.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
package recloudstream
22

3-
import com.lagradost.cloudstream3.*
3+
import com.lagradost.cloudstream3.Actor
4+
import com.lagradost.cloudstream3.ActorData
5+
import com.lagradost.cloudstream3.HomePageList
6+
import com.lagradost.cloudstream3.HomePageResponse
7+
import com.lagradost.cloudstream3.LoadResponse
8+
import com.lagradost.cloudstream3.MainAPI
9+
import com.lagradost.cloudstream3.MainPageRequest
10+
import com.lagradost.cloudstream3.SearchResponse
11+
import com.lagradost.cloudstream3.SubtitleFile
12+
import com.lagradost.cloudstream3.TvType
13+
import com.lagradost.cloudstream3.app
14+
import com.lagradost.cloudstream3.newHomePageResponse
15+
import com.lagradost.cloudstream3.newMovieLoadResponse
16+
import com.lagradost.cloudstream3.newMovieSearchResponse
417
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
518
import com.lagradost.cloudstream3.utils.ExtractorLink
619
import com.lagradost.cloudstream3.utils.Qualities
@@ -85,14 +98,14 @@ class InvidiousProvider : MainAPI() { // all providers must be an instance of Ma
8598
title,
8699
"${provider.mainUrl}/watch?v=$videoId",
87100
TvType.Movie,
88-
"$videoId"
101+
videoId
89102
) {
90103
plot = description
91104
posterUrl = "${provider.mainUrl}/vi/$videoId/hqdefault.jpg"
92105
recommendations = recommendedVideos.map { it.toSearchResponse(provider) }
93106
actors = listOf(
94107
ActorData(
95-
Actor(author, authorThumbnails.get(authorThumbnails.size - 1)?.url ?: ""),
108+
Actor(author, authorThumbnails.getOrNull(authorThumbnails.size - 1)?.url ?: ""),
96109
roleString = "Author"
97110
)
98111
)
@@ -130,4 +143,4 @@ class InvidiousProvider : MainAPI() { // all providers must be an instance of Ma
130143
)
131144
return true
132145
}
133-
}
146+
}

TwitchProvider/build.gradle.kts

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

44
cloudstream {
55
// All of these properties are optional, you can safely remove any of them.
@@ -18,4 +18,6 @@ cloudstream {
1818

1919
tvTypes = listOf("Live")
2020
iconUrl = "https://www.google.com/s2/favicons?domain=twitch.tv&sz=%size%"
21+
22+
isCrossPlatform = true
2123
}

TwitchProvider/src/main/kotlin/recloudstream/TwitchPlugin.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package recloudstream
22

3+
import com.lagradost.cloudstream3.plugins.BasePlugin
34
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
4-
import com.lagradost.cloudstream3.plugins.Plugin
5-
import android.content.Context
65

76
@CloudstreamPlugin
8-
class TwitchPlugin: Plugin() {
9-
override fun load(context: Context) {
7+
class TwitchPlugin: BasePlugin() {
8+
override fun load() {
109
// All providers should be added in this manner. Please don't edit the providers list directly.
1110
registerMainAPI(TwitchProvider())
1211
registerExtractorAPI(TwitchProvider.TwitchExtractor())

TwitchProvider/src/main/kotlin/recloudstream/TwitchProvider.kt

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
package 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
418
import com.lagradost.cloudstream3.utils.ExtractorApi
519
import com.lagradost.cloudstream3.utils.ExtractorLink
620
import 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

Comments
 (0)