package com.lagradost.cloudstream3.extractors import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.Qualities open class Uservideo : ExtractorApi() { override val name: String = "Uservideo" override val mainUrl: String = "https://uservideo.xyz" override val requiresReferer = false override suspend fun getUrl( url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ) { val script = app.get(url).document.selectFirst("script:containsData(hosts =)")?.data() val host = script?.substringAfter("hosts = [\"")?.substringBefore("\"];") val servers = script?.substringAfter("servers = \"")?.substringBefore("\";") val sources = app.get("$host/s/$servers").text.substringAfter("\"sources\":[").substringBefore("],").let { AppUtils.tryParseJson>("[$it]") } val quality = Regex("(\\d{3,4})[Pp]").find(url)?.groupValues?.getOrNull(1)?.toIntOrNull() sources?.map { source -> callback.invoke( ExtractorLink( name, name, source.src ?: return@map null, url, quality ?: Qualities.Unknown.value, ) ) } } data class Sources( @JsonProperty("src") val src: String? = null, @JsonProperty("type") val type: String? = null, @JsonProperty("label") val label: String? = null, ) }