From 640637804bd6f45123e9ae9ea339ff4ab2cbf1d6 Mon Sep 17 00:00:00 2001 From: Arjix <53124886+ArjixWasTaken@users.noreply.github.com> Date: Fri, 23 Jul 2021 15:00:07 +0300 Subject: [PATCH] Create WcoStream.kt --- .../utils/extractors/WcoStream.kt | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 app/src/main/java/com/lagradost/cloudstream3/utils/extractors/WcoStream.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/extractors/WcoStream.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/extractors/WcoStream.kt new file mode 100644 index 00000000..7a5fea9a --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/extractors/WcoStream.kt @@ -0,0 +1,62 @@ +package com.lagradost.cloudstream3.utils.extractors + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.module.kotlin.readValue +import com.lagradost.cloudstream3.utils.* +import com.lagradost.cloudstream3.mapper + +class WcoStream : ExtractorApi() { + override val name: String = "WcoStream" + override val mainUrl: String = "https://vidstreame.pro" + override val requiresReferer = false + + override fun getUrl(url: String, referer: String?): List { + try { + val baseUrl = url.split("/e/")[0] + + val html = khttp.get(url, headers=mapOf("Referer" to "https://wcostream.cc/")).text + val (Id) = "/e/(.*?)?domain".toRegex().find(url)!!.destructured + val (skey) = """skey\s=\s['\"](.*?)['\"];""".toRegex().find(html)!!.destructured + + val apiLink = "$baseUrl/info/$Id?domain=wcostream.cc&skey=$skey" + val referrer = "$baseUrl/e/$Id?domain=wcostream.cc" + + val response = khttp.get(apiLink, headers=mapOf("Referer" to referrer)).text + + data class Sources ( + @JsonProperty("file") val file : String, + @JsonProperty("label") val label : String + ) + + data class Media ( + @JsonProperty("sources") val sources : List + ) + + data class WcoResponse ( + @JsonProperty("success") val success : Boolean, + @JsonProperty("media") val media : Media + ) + + val mapped = response.let { mapper.readValue(it) } + val sources = mutableListOf() + + if (mapped.success) { + mapped.media.sources.forEach { + sources.add( + ExtractorLink( + "WcoStream", + "WcoStream" + "- ${it.label}", + it.file, + "", + Qualities.HD.value, + it.file.contains(".m3u8") + ) + ) + } + } + return sources + } catch (e: Exception) { + return listOf() + } + } +}