skill(share) issue: add fallback

This commit is contained in:
Cloudburst 2022-12-30 11:29:57 +01:00 committed by GitHub
parent 23f0ee0c8d
commit a4bdb2caba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 4 version = 5
cloudstream { cloudstream {

View file

@ -19,6 +19,7 @@ class SkillShareProvider : MainAPI() { // all providers must be an instance of M
private val apiUrl = "https://www.skillshare.com/api/graphql" private val apiUrl = "https://www.skillshare.com/api/graphql"
private val bypassApiUrl = "https://skillshare.techtanic.xyz/id" private val bypassApiUrl = "https://skillshare.techtanic.xyz/id"
private val bypassApiUrlFallback = "https://skillshare-api.heckernohecking.repl.co"
override val supportedTypes = setOf(TvType.Others) override val supportedTypes = setOf(TvType.Others)
override val hasChromecastSupport = true override val hasChromecastSupport = true
@ -144,6 +145,7 @@ class SkillShareProvider : MainAPI() { // all providers must be an instance of M
override suspend fun load(url: String): LoadResponse? { override suspend fun load(url: String): LoadResponse? {
val data = parseJson<Data>(url) val data = parseJson<Data>(url)
val document = app.get(bypassApiUrl + "/${data.courseId}") val document = app.get(bypassApiUrl + "/${data.courseId}")
.parsedSafe<BypassApiData>() ?: app.get(bypassApiUrlFallback + "/${data.courseId}/0")
.parsedSafe<BypassApiData>() ?: throw ErrorLoadingException("Invalid Json Response") .parsedSafe<BypassApiData>() ?: throw ErrorLoadingException("Invalid Json Response")
val title = data.title ?: "" val title = data.title ?: ""
val poster = data.largeCoverUrl val poster = data.largeCoverUrl