mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
* Extractor: added some extractors * Extractor: fix same import * Extractor: PeaceMakerst fix * Extractor: source fix
62 lines
2.5 KiB
Kotlin
62 lines
2.5 KiB
Kotlin
// ! Bu araç @keyiflerolsun tarafından | @KekikAkademi için yazılmıştır.
|
||
|
||
package com.lagradost.cloudstream3.extractors
|
||
|
||
import android.util.Log
|
||
import com.lagradost.cloudstream3.*
|
||
import com.lagradost.cloudstream3.utils.*
|
||
import com.fasterxml.jackson.annotation.JsonProperty
|
||
|
||
open class Odnoklassniki : ExtractorApi() {
|
||
override val name = "Odnoklassniki"
|
||
override val mainUrl = "https://odnoklassniki.ru"
|
||
override val requiresReferer = false
|
||
|
||
override suspend fun getUrl(url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit) {
|
||
val ext_ref = referer ?: ""
|
||
Log.d("Kekik_${this.name}", "url » ${url}")
|
||
|
||
val user_agent = mapOf("User-Agent" to "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36")
|
||
|
||
val video_req = app.get(url, headers=user_agent).text.replace("\\"", "\"").replace("\\\\", "\\")
|
||
.replace(Regex("\\\\u([0-9A-Fa-f]{4})")) { matchResult ->
|
||
Integer.parseInt(matchResult.groupValues[1], 16).toChar().toString()
|
||
}
|
||
val videos_str = Regex("""\"videos\":(\[[^\]]*\])""").find(video_req)?.groupValues?.get(1) ?: throw ErrorLoadingException("Video not found")
|
||
val videos = AppUtils.tryParseJson<List<OkRuVideo>>(videos_str) ?: throw ErrorLoadingException("Video not found")
|
||
|
||
for (video in videos) {
|
||
Log.d("Kekik_${this.name}", "video » ${video}")
|
||
|
||
val video_url = if (video.url.startsWith("//")) "https:${video.url}" else video.url
|
||
|
||
val quality = video.name.uppercase()
|
||
.replace("MOBILE", "144p")
|
||
.replace("LOWEST", "240p")
|
||
.replace("LOW", "360p")
|
||
.replace("SD", "480p")
|
||
.replace("HD", "720p")
|
||
.replace("FULL", "1080p")
|
||
.replace("QUAD", "1440p")
|
||
.replace("ULTRA", "4k")
|
||
|
||
callback.invoke(
|
||
ExtractorLink(
|
||
source = this.name,
|
||
name = this.name,
|
||
url = video_url,
|
||
referer = url,
|
||
quality = getQualityFromName(quality),
|
||
headers = user_agent,
|
||
isM3u8 = false
|
||
)
|
||
)
|
||
}
|
||
}
|
||
|
||
data class OkRuVideo(
|
||
@JsonProperty("name") val name: String,
|
||
@JsonProperty("url") val url: String,
|
||
)
|
||
}
|