Skip to content

Commit dc6b9f4

Browse files
authored
feat(extractors): add up4stream extractor (#2389)
1 parent 2795e9e commit dc6b9f4

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.lagradost.cloudstream3.extractors
2+
3+
import com.lagradost.api.Log
4+
import com.lagradost.cloudstream3.app
5+
import com.lagradost.cloudstream3.utils.ExtractorApi
6+
import com.lagradost.cloudstream3.utils.ExtractorLink
7+
import com.lagradost.cloudstream3.utils.JsUnpacker
8+
import com.lagradost.cloudstream3.utils.Qualities
9+
import com.lagradost.cloudstream3.utils.fixUrl
10+
import com.lagradost.cloudstream3.utils.newExtractorLink
11+
import kotlinx.coroutines.delay
12+
13+
class Up4FunTop : Up4Stream() {
14+
override var mainUrl: String = "https://up4fun.top"
15+
}
16+
17+
open class Up4Stream : ExtractorApi() {
18+
override var name = "Up4Stream"
19+
override var mainUrl = "https://up4stream.com"
20+
override val requiresReferer = true
21+
22+
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink>? {
23+
val movieId = url.substringAfterLast("/").substringBefore(".html")
24+
25+
// redirect from "wait 5 seconds" page to actual movie page
26+
val redirectResponse = app.get(url, cookies = mapOf("id" to movieId))
27+
val redirectForm = redirectResponse.document.selectFirst("form[method=POST]") ?: return null
28+
val redirectUrl = fixUrl(redirectForm.attr("action"))
29+
val redirectParams = redirectForm.select("input[type=hidden]").associate { input ->
30+
input.attr("name") to input.attr("value")
31+
}
32+
33+
// wait for 5 seconds, otherwise the below md5 hash is invalid
34+
delay(5000)
35+
val response = app.post(redirectUrl, data = redirectParams).document
36+
37+
// starting here, this works similar to many other extractors like StreamWish
38+
val extractedpack =
39+
response.selectFirst("script:containsData(function(p,a,c,k,e,d))")?.data()
40+
if (extractedpack == null) {
41+
Log.e("up4stream", "file not ready: delay too short")
42+
}
43+
44+
JsUnpacker(extractedpack).unpack()?.let { unPacked ->
45+
Regex("sources:\\[\\{file:\"(.*?)\"").find(unPacked)?.groupValues?.get(1)?.let { link ->
46+
return listOf(
47+
newExtractorLink(
48+
this.name,
49+
this.name,
50+
link,
51+
) {
52+
this.referer = referer.orEmpty()
53+
this.quality = Qualities.Unknown.value
54+
}
55+
)
56+
}
57+
}
58+
return null
59+
}
60+
}

library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ import com.lagradost.cloudstream3.extractors.Techinmind
230230
import com.lagradost.cloudstream3.extractors.Tomatomatela
231231
import com.lagradost.cloudstream3.extractors.TomatomatelalClub
232232
import com.lagradost.cloudstream3.extractors.Tubeless
233+
import com.lagradost.cloudstream3.extractors.Up4FunTop
234+
import com.lagradost.cloudstream3.extractors.Up4Stream
233235
import com.lagradost.cloudstream3.extractors.Upstream
234236
import com.lagradost.cloudstream3.extractors.UpstreamExtractor
235237
import com.lagradost.cloudstream3.extractors.Uqload
@@ -1223,6 +1225,8 @@ val extractorApis: MutableList<ExtractorApi> = arrayListOf(
12231225
VkExtractor(),
12241226
Bysezejataos(),
12251227
ByseSX(),
1228+
Up4Stream(),
1229+
Up4FunTop()
12261230
)
12271231

12281232

0 commit comments

Comments
 (0)