forked from recloudstream/cloudstream
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBuzzServer.kt
More file actions
47 lines (43 loc) · 1.65 KB
/
Copy pathBuzzServer.kt
File metadata and controls
47 lines (43 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.lagradost.cloudstream3.extractors
import com.lagradost.api.Log
import com.lagradost.cloudstream3.Prerelease
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.getQualityFromName
import com.lagradost.cloudstream3.utils.newExtractorLink
@Prerelease
class BuzzServer : ExtractorApi() {
override val name = "BuzzServer"
override val mainUrl = "https://buzzheavier.com"
override val requiresReferer = true
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
try {
val qualityText = app.get(url).documentLarge.selectFirst("div.max-w-2xl > span")?.text()
val quality = getQualityFromName(qualityText)
val response = app.get("$url/download", referer = url, allowRedirects = false)
val redirectUrl = response.headers["hx-redirect"] ?: ""
if (redirectUrl.isNotEmpty()) {
callback.invoke(
newExtractorLink(
"BuzzServer",
"BuzzServer",
redirectUrl,
) {
this.quality = quality
}
)
} else {
Log.w("BuzzServer", "No redirect URL found in headers.")
}
} catch (e: Exception) {
Log.e("BuzzServer", "Exception occurred: ${e.message}")
}
}
}