diff --git a/Superstream/build.gradle.kts b/Superstream/build.gradle.kts index a51ee0af..2bf7d8a9 100644 --- a/Superstream/build.gradle.kts +++ b/Superstream/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.konan.properties.Properties // use an integer for version numbers -version = 2 +version = 3 android { defaultConfig { diff --git a/Superstream/src/main/kotlin/com/hexated/Extractors.kt b/Superstream/src/main/kotlin/com/hexated/Extractors.kt index e6fd7605..1d0fd0e3 100644 --- a/Superstream/src/main/kotlin/com/hexated/Extractors.kt +++ b/Superstream/src/main/kotlin/com/hexated/Extractors.kt @@ -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()?.data?.link?.substringAfterLast("/") + val shareKey = app.get("$fourthAPI/index/share_link?id=${mediaId}&type=$type") + .parsedSafe()?.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()?.data + val shareRes = app.get("$thirdAPI/file/file_share_list?share_key=$shareKey", headers = headers) + .parsedSafe()?.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()?.data?.file_list?.filter { - it.file_name?.contains( - "s${seasonSlug}e${episodeSlug}", - true - ) == true - } - } - - 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>(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 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()?.data?.file_list?.filter { + it.file_name?.contains("s${seasonSlug}e${episodeSlug}", true) == true } - callback.invoke( - ExtractorLink( - "External $path", - "External $path [Server ${index + 1}]", - it.first?.replace("\\/", "/") ?: return@apmapIndexed, - "$thirdAPI/", - getIndexQuality(it.second), - type = INFER_TYPE, + } ?: return + + fids.apmapIndexed { index, fileList -> + val player = app.get("$thirdAPI/file/player?fid=${fileList.fid}&share_key=$shareKey").text + 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>(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, + ) ) - ) + } } } } diff --git a/Superstream/src/main/kotlin/com/hexated/Superstream.kt b/Superstream/src/main/kotlin/com/hexated/Superstream.kt index 24acd381..bd971a67 100644 --- a/Superstream/src/main/kotlin/com/hexated/Superstream.kt +++ b/Superstream/src/main/kotlin/com/hexated/Superstream.kt @@ -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(