Fix VoeExtractor

This commit is contained in:
Blatzar 2022-11-12 20:07:08 +01:00
parent 1226426389
commit cf22ada266

View file

@ -13,39 +13,42 @@ open class VoeExtractor : ExtractorApi() {
override val requiresReferer = false override val requiresReferer = false
private data class ResponseLinks( 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? @JsonProperty("video_height") val label: Int?
//val type: String // Mp4 //val type: String // Mp4
) )
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink> { override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink> {
val extractedLinksList: MutableList<ExtractorLink> = mutableListOf() val html = app.get(url).text
val doc = app.get(url).text if (html.isNotBlank()) {
if (doc.isNotBlank()) { val src = html.substringAfter("const sources =").substringBefore(";")
val start = "const sources =" // Remove last comma, it is not proper json otherwise
var src = doc.substring(doc.indexOf(start))
src = src.substring(start.length, src.indexOf(";"))
.replace("0,", "0") .replace("0,", "0")
.trim() // Make json use the proper quotes
.replace("'", "\"")
//Log.i(this.name, "Result => (src) ${src}") //Log.i(this.name, "Result => (src) ${src}")
parseJson<ResponseLinks?>(src)?.let { voelink -> parseJson<ResponseLinks?>(src)?.let { voeLink ->
//Log.i(this.name, "Result => (voelink) ${voelink}") //Log.i(this.name, "Result => (voeLink) ${voeLink}")
val linkUrl = voelink.url
val linkLabel = voelink.label?.toString() ?: "" // 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()) { if (!linkUrl.isNullOrEmpty()) {
extractedLinksList.add( return listOf(
ExtractorLink( ExtractorLink(
name = this.name, name = this.name,
source = this.name, source = this.name,
url = linkUrl, url = linkUrl,
quality = getQualityFromName(linkLabel), quality = getQualityFromName(linkLabel),
referer = url, referer = url,
isM3u8 = true isM3u8 = voeLink.hls != null
) )
) )
} }
} }
} }
return extractedLinksList return emptyList()
} }
} }