Skip to content

Commit

Permalink
Superstream: small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
olivia committed Jan 25, 2024
1 parent 8a31e3a commit 9248417
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Superstream/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.konan.properties.Properties

// use an integer for version numbers
version = 2
version = 3

android {
defaultConfig {
Expand Down
70 changes: 29 additions & 41 deletions Superstream/src/main/kotlin/com/hexated/Extractors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,55 +68,43 @@ 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"
}
callback.invoke(
ExtractorLink(
"External $path",
"External $path [Server ${index + 1}]",
it.first?.replace("\\/", "/") ?: return@apmapIndexed,
"$thirdAPI/",
getIndexQuality(it.second),
type = INFER_TYPE,
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",
"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,
)
)
)
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Superstream/src/main/kotlin/com/hexated/Superstream.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 9248417

Please sign in to comment.