From cf22ada266191a3421dc8a213cdcd6f9fd3833b8 Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Sat, 12 Nov 2022 20:07:08 +0100 Subject: [PATCH] Fix VoeExtractor --- .../cloudstream3/extractors/VoeExtractor.kt | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/VoeExtractor.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/VoeExtractor.kt index d2f3f832..ad3f0150 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/VoeExtractor.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/VoeExtractor.kt @@ -13,39 +13,42 @@ open class VoeExtractor : ExtractorApi() { override val requiresReferer = false private data class ResponseLinks( - @JsonProperty("hls") val url: String?, + @JsonProperty("hls") val hls: String?, + @JsonProperty("mp4") val mp4: String?, @JsonProperty("video_height") val label: Int? //val type: String // Mp4 ) override suspend fun getUrl(url: String, referer: String?): List { - val extractedLinksList: MutableList = mutableListOf() - val doc = app.get(url).text - if (doc.isNotBlank()) { - val start = "const sources =" - var src = doc.substring(doc.indexOf(start)) - src = src.substring(start.length, src.indexOf(";")) + val html = app.get(url).text + if (html.isNotBlank()) { + val src = html.substringAfter("const sources =").substringBefore(";") + // Remove last comma, it is not proper json otherwise .replace("0,", "0") - .trim() + // Make json use the proper quotes + .replace("'", "\"") + //Log.i(this.name, "Result => (src) ${src}") - parseJson(src)?.let { voelink -> - //Log.i(this.name, "Result => (voelink) ${voelink}") - val linkUrl = voelink.url - val linkLabel = voelink.label?.toString() ?: "" + parseJson(src)?.let { voeLink -> + //Log.i(this.name, "Result => (voeLink) ${voeLink}") + + // Always defaults to the hls link, but returns the mp4 if null + val linkUrl = voeLink.hls ?: voeLink.mp4 + val linkLabel = voeLink.label?.toString() ?: "" if (!linkUrl.isNullOrEmpty()) { - extractedLinksList.add( + return listOf( ExtractorLink( name = this.name, source = this.name, url = linkUrl, quality = getQualityFromName(linkLabel), referer = url, - isM3u8 = true + isM3u8 = voeLink.hls != null ) ) } } } - return extractedLinksList + return emptyList() } } \ No newline at end of file