Superstream: small fix

This commit is contained in:
Olivia 2024-01-25 16:57:35 +07:00
parent 8a31e3acb0
commit 9248417aeb
3 changed files with 33 additions and 43 deletions

View file

@ -1,7 +1,7 @@
import org.jetbrains.kotlin.konan.properties.Properties import org.jetbrains.kotlin.konan.properties.Properties
// use an integer for version numbers // use an integer for version numbers
version = 2 version = 3
android { android {
defaultConfig { defaultConfig {

View file

@ -68,58 +68,46 @@ object Extractors : Superstream() {
callback: (ExtractorLink) -> Unit, callback: (ExtractorLink) -> Unit,
) { ) {
val (seasonSlug, episodeSlug) = getEpisodeSlug(season, episode) val (seasonSlug, episodeSlug) = getEpisodeSlug(season, episode)
val shareKey = app.get( val shareKey = app.get("$fourthAPI/index/share_link?id=${mediaId}&type=$type")
"$fourthAPI/index/share_link?id=${mediaId}&type=$type" .parsedSafe<ExternalResponse>()?.data?.link?.substringAfterLast("/") ?: return
).parsedSafe<ExternalResponse>()?.data?.link?.substringAfterLast("/")
val headers = mapOf("Accept-Language" to "en") val headers = mapOf("Accept-Language" to "en")
val shareRes = app.get( val shareRes = app.get("$thirdAPI/file/file_share_list?share_key=$shareKey", headers = headers)
"$thirdAPI/file/file_share_list?share_key=${shareKey ?: return}", .parsedSafe<ExternalResponse>()?.data ?: return
headers = headers
).parsedSafe<ExternalResponse>()?.data
val fids = if (season == null) { val fids = if (season == null) {
shareRes?.file_list shareRes.file_list
} else { } else {
val parentId = val parentId = shareRes.file_list?.find { it.file_name.equals("season $season", true) }?.fid
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)
app.get( .parsedSafe<ExternalResponse>()?.data?.file_list?.filter {
"$thirdAPI/file/file_share_list?share_key=$shareKey&parent_id=$parentId&page=1", it.file_name?.contains("s${seasonSlug}e${episodeSlug}", true) == true
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 player = app.get("$thirdAPI/file/player?fid=${fileList.fid}&share_key=$shareKey").text
val hls = """"(https.*?m3u8.*?)"""".toRegex().find(player)?.groupValues?.get(1) val sources = "sources\\s*=\\s*(.*);".toRegex().find(player)?.groupValues?.get(1)
val mp4 = "sources\\s*=\\s*(.*);".toRegex().find(player)?.groupValues?.get(1)?.let { val qualities = "quality_list\\s*=\\s*(.*);".toRegex().find(player)?.groupValues?.get(1)
AppUtils.tryParseJson<List<ExternalSources>>(it)?.first() listOf(sources, qualities).forEach {
} AppUtils.tryParseJson<ArrayList<ExternalSources>>(it)?.forEach org@{ source ->
listOf( val format = if (source.type == "video/mp4") ExtractorLinkType.VIDEO else ExtractorLinkType.M3U8
mp4?.file to mp4?.label, val label = if (format == ExtractorLinkType.M3U8) "Hls" else "Mp4"
hls to fileList.file_name if(!(source.label == "AUTO" || format == ExtractorLinkType.VIDEO)) return@org
).map {
val path = normalSafeApiCall { URL(it.first).path }.let { p ->
if(p?.endsWith(".m3u8") == true) "HLS" else "MP4"
}
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
"External $path", "External",
"External $path [Server ${index + 1}]", "External $label [Server ${index + 1}]",
it.first?.replace("\\/", "/") ?: return@apmapIndexed, (source.m3u8_url ?: source.file)?.replace("\\/", "/") ?: return@org,
"$thirdAPI/", "",
getIndexQuality(it.second), getIndexQuality(if (format == ExtractorLinkType.M3U8) fileList.file_name else source.label),
type = INFER_TYPE, type = format,
) )
) )
} }
} }
} }
}
suspend fun invokeWatchsomuch( suspend fun invokeWatchsomuch(
imdbId: String? = null, imdbId: String? = null,

View file

@ -775,8 +775,10 @@ open class Superstream : MainAPI() {
} }
data class ExternalSources( data class ExternalSources(
@JsonProperty("m3u8_url") val m3u8_url: String? = null,
@JsonProperty("file") val file: String? = null, @JsonProperty("file") val file: String? = null,
@JsonProperty("label") val label: String? = null, @JsonProperty("label") val label: String? = null,
@JsonProperty("type") val type: String? = null,
) )
data class WatchsomuchTorrents( data class WatchsomuchTorrents(