mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
Superstream: small fix
This commit is contained in:
parent
8a31e3acb0
commit
9248417aeb
3 changed files with 33 additions and 43 deletions
|
@ -1,7 +1,7 @@
|
|||
import org.jetbrains.kotlin.konan.properties.Properties
|
||||
|
||||
// use an integer for version numbers
|
||||
version = 2
|
||||
version = 3
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
|
|
|
@ -68,58 +68,46 @@ object Extractors : Superstream() {
|
|||
callback: (ExtractorLink) -> Unit,
|
||||
) {
|
||||
val (seasonSlug, episodeSlug) = getEpisodeSlug(season, episode)
|
||||
val shareKey = app.get(
|
||||
"$fourthAPI/index/share_link?id=${mediaId}&type=$type"
|
||||
).parsedSafe<ExternalResponse>()?.data?.link?.substringAfterLast("/")
|
||||
val shareKey = app.get("$fourthAPI/index/share_link?id=${mediaId}&type=$type")
|
||||
.parsedSafe<ExternalResponse>()?.data?.link?.substringAfterLast("/") ?: return
|
||||
|
||||
val headers = mapOf("Accept-Language" to "en")
|
||||
val shareRes = app.get(
|
||||
"$thirdAPI/file/file_share_list?share_key=${shareKey ?: return}",
|
||||
headers = headers
|
||||
).parsedSafe<ExternalResponse>()?.data
|
||||
val shareRes = app.get("$thirdAPI/file/file_share_list?share_key=$shareKey", headers = headers)
|
||||
.parsedSafe<ExternalResponse>()?.data ?: return
|
||||
|
||||
val fids = if (season == null) {
|
||||
shareRes?.file_list
|
||||
shareRes.file_list
|
||||
} else {
|
||||
val parentId =
|
||||
shareRes?.file_list?.find { it.file_name.equals("season $season", true) }?.fid
|
||||
app.get(
|
||||
"$thirdAPI/file/file_share_list?share_key=$shareKey&parent_id=$parentId&page=1",
|
||||
headers = headers
|
||||
).parsedSafe<ExternalResponse>()?.data?.file_list?.filter {
|
||||
it.file_name?.contains(
|
||||
"s${seasonSlug}e${episodeSlug}",
|
||||
true
|
||||
) == true
|
||||
}
|
||||
val parentId = shareRes.file_list?.find { it.file_name.equals("season $season", true) }?.fid
|
||||
app.get("$thirdAPI/file/file_share_list?share_key=$shareKey&parent_id=$parentId&page=1", headers = headers)
|
||||
.parsedSafe<ExternalResponse>()?.data?.file_list?.filter {
|
||||
it.file_name?.contains("s${seasonSlug}e${episodeSlug}", true) == true
|
||||
}
|
||||
} ?: return
|
||||
|
||||
fids?.apmapIndexed { index, fileList ->
|
||||
fids.apmapIndexed { index, fileList ->
|
||||
val player = app.get("$thirdAPI/file/player?fid=${fileList.fid}&share_key=$shareKey").text
|
||||
val hls = """"(https.*?m3u8.*?)"""".toRegex().find(player)?.groupValues?.get(1)
|
||||
val mp4 = "sources\\s*=\\s*(.*);".toRegex().find(player)?.groupValues?.get(1)?.let {
|
||||
AppUtils.tryParseJson<List<ExternalSources>>(it)?.first()
|
||||
}
|
||||
listOf(
|
||||
mp4?.file to mp4?.label,
|
||||
hls to fileList.file_name
|
||||
).map {
|
||||
val path = normalSafeApiCall { URL(it.first).path }.let { p ->
|
||||
if(p?.endsWith(".m3u8") == true) "HLS" else "MP4"
|
||||
}
|
||||
val sources = "sources\\s*=\\s*(.*);".toRegex().find(player)?.groupValues?.get(1)
|
||||
val qualities = "quality_list\\s*=\\s*(.*);".toRegex().find(player)?.groupValues?.get(1)
|
||||
listOf(sources, qualities).forEach {
|
||||
AppUtils.tryParseJson<ArrayList<ExternalSources>>(it)?.forEach org@{ source ->
|
||||
val format = if (source.type == "video/mp4") ExtractorLinkType.VIDEO else ExtractorLinkType.M3U8
|
||||
val label = if (format == ExtractorLinkType.M3U8) "Hls" else "Mp4"
|
||||
if(!(source.label == "AUTO" || format == ExtractorLinkType.VIDEO)) return@org
|
||||
callback.invoke(
|
||||
ExtractorLink(
|
||||
"External $path",
|
||||
"External $path [Server ${index + 1}]",
|
||||
it.first?.replace("\\/", "/") ?: return@apmapIndexed,
|
||||
"$thirdAPI/",
|
||||
getIndexQuality(it.second),
|
||||
type = INFER_TYPE,
|
||||
"External",
|
||||
"External $label [Server ${index + 1}]",
|
||||
(source.m3u8_url ?: source.file)?.replace("\\/", "/") ?: return@org,
|
||||
"",
|
||||
getIndexQuality(if (format == ExtractorLinkType.M3U8) fileList.file_name else source.label),
|
||||
type = format,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun invokeWatchsomuch(
|
||||
imdbId: String? = null,
|
||||
|
|
|
@ -775,8 +775,10 @@ open class Superstream : MainAPI() {
|
|||
}
|
||||
|
||||
data class ExternalSources(
|
||||
@JsonProperty("m3u8_url") val m3u8_url: String? = null,
|
||||
@JsonProperty("file") val file: String? = null,
|
||||
@JsonProperty("label") val label: String? = null,
|
||||
@JsonProperty("type") val type: String? = null,
|
||||
)
|
||||
|
||||
data class WatchsomuchTorrents(
|
||||
|
|
Loading…
Reference in a new issue