Skip to content

Commit

Permalink
fixed: Test Search & VidMoxy, RapidVid extractors (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyiflerolsun authored Jul 30, 2024
1 parent 63e27c2 commit 30adb1c
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.mvvm.logError
import kotlinx.coroutines.*
import org.junit.Assert
import kotlin.random.Random

object TestingUtils {
open class TestResult(val success: Boolean) {
Expand Down Expand Up @@ -280,8 +281,8 @@ object TestingUtils {

// Test Search Results
val searchQueries =
// Use the first 3 home page results as queries since they are guaranteed to exist
(homePageList.take(3).map { it.name } +
// Use the random 3 home page results as queries since they are guaranteed to exist
(homePageList.shuffled(Random).take(3).map { it.name.split(" ").first() } +
// If home page is sparse then use generic search queries
listOf("over", "iron", "guy")).take(3)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,52 @@ open class ContentX : ExtractorApi() {
override val requiresReferer = true

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 extRef = referer ?: ""

val i_source = app.get(url, referer=ext_ref).text
val i_extract = Regex("""window\.openPlayer\('([^']+)'""").find(i_source)!!.groups[1]?.value ?: throw ErrorLoadingException("i_extract is null")
val iSource = app.get(url, referer=extRef).text
val iExtract = Regex("""window\.openPlayer\('([^']+)'""").find(iSource)!!.groups[1]?.value ?: throw ErrorLoadingException("iExtract is null")

val sub_urls = mutableSetOf<String>()
Regex("""\"file\":\"([^\"]+)\",\"label\":\"([^\"]+)\"""").findAll(i_source).forEach {
val (sub_url, sub_lang) = it.destructured
val subUrls = mutableSetOf<String>()
Regex("""\"file\":\"([^\"]+)\",\"label\":\"([^\"]+)\"""").findAll(iSource).forEach {
val (subUrl, subLang) = it.destructured

if (sub_url in sub_urls) { return@forEach }
sub_urls.add(sub_url)
if (subUrl in subUrls) { return@forEach }
subUrls.add(subUrl)

subtitleCallback.invoke(
SubtitleFile(
lang = sub_lang.replace("\\u0131", "ı").replace("\\u0130", "İ").replace("\\u00fc", "ü").replace("\\u00e7", "ç"),
url = fixUrl(sub_url.replace("\\", ""))
lang = subLang.replace("\\u0131", "ı").replace("\\u0130", "İ").replace("\\u00fc", "ü").replace("\\u00e7", "ç"),
url = fixUrl(subUrl.replace("\\", ""))
)
)
}

val vid_source = app.get("${mainUrl}/source2.php?v=${i_extract}", referer=ext_ref).text
val vid_extract = Regex("""file\":\"([^\"]+)""").find(vid_source)!!.groups[1]?.value ?: throw ErrorLoadingException("vid_extract is null")
val m3u_link = vid_extract.replace("\\", "")
val vidSource = app.get("${mainUrl}/source2.php?v=${iExtract}", referer=extRef).text
val vidExtract = Regex("""file\":\"([^\"]+)""").find(vidSource)!!.groups[1]?.value ?: throw ErrorLoadingException("vidExtract is null")
val m3uLink = vidExtract.replace("\\", "")

callback.invoke(
ExtractorLink(
source = this.name,
name = this.name,
url = m3u_link,
url = m3uLink,
referer = url,
quality = Qualities.Unknown.value,
isM3u8 = true
)
)

val i_dublaj = Regex(""",\"([^']+)\",\"Türkçe""").find(i_source)!!.groups[1]?.value
if (i_dublaj != null) {
val dublaj_source = app.get("${mainUrl}/source2.php?v=${i_dublaj}", referer=ext_ref).text
val dublaj_extract = Regex("""file\":\"([^\"]+)""").find(dublaj_source)!!.groups[1]?.value ?: throw ErrorLoadingException("dublaj_extract is null")
val dublaj_link = dublaj_extract.replace("\\", "")
val iDublaj = Regex(""",\"([^']+)\",\"Türkçe""").find(iSource)!!.groups[1]?.value
if (iDublaj != null) {
val dublajSource = app.get("${mainUrl}/source2.php?v=${iDublaj}", referer=extRef).text
val dublajExtract = Regex("""file\":\"([^\"]+)""").find(dublajSource)!!.groups[1]?.value ?: throw ErrorLoadingException("dublajExtract is null")
val dublajLink = dublajExtract.replace("\\", "")

callback.invoke(
ExtractorLink(
source = "${this.name} Türkçe Dublaj",
name = "${this.name} Türkçe Dublaj",
url = dublaj_link,
url = dublajLink,
referer = url,
quality = Qualities.Unknown.value,
isM3u8 = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,23 @@ open class HDMomPlayer : ExtractorApi() {
override val requiresReferer = true

override suspend fun getUrl(url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit) {
val m3u_link:String?
val ext_ref = referer ?: ""
val i_source = app.get(url, referer=ext_ref).text
val m3uLink:String?
val extRef = referer ?: ""
val iSource = app.get(url, referer=extRef).text

val bePlayer = Regex("""bePlayer\('([^']+)',\s*'(\{[^\}]+\})'\);""").find(i_source)?.groupValues
val bePlayer = Regex("""bePlayer\('([^']+)',\s*'(\{[^\}]+\})'\);""").find(iSource)?.groupValues
if (bePlayer != null) {
val bePlayerPass = bePlayer.get(1)
val bePlayerData = bePlayer.get(2)
val encrypted = AesHelper.cryptoAESHandler(bePlayerData, bePlayerPass.toByteArray(), false)?.replace("\\", "") ?: throw ErrorLoadingException("failed to decrypt")
Log.d("Kekik_${this.name}", "encrypted » ${encrypted}")

m3u_link = Regex("""video_location\":\"([^\"]+)""").find(encrypted)?.groupValues?.get(1)
m3uLink = Regex("""video_location\":\"([^\"]+)""").find(encrypted)?.groupValues?.get(1)
} else {
m3u_link = Regex("""file:\"([^\"]+)""").find(i_source)?.groupValues?.get(1)
m3uLink = Regex("""file:\"([^\"]+)""").find(iSource)?.groupValues?.get(1)

val track_str = Regex("""tracks:\[([^\]]+)""").find(i_source)?.groupValues?.get(1)
if (track_str != null) {
val tracks:List<Track> = jacksonObjectMapper().readValue("[${track_str}]")
val trackStr = Regex("""tracks:\[([^\]]+)""").find(iSource)?.groupValues?.get(1)
if (trackStr != null) {
val tracks:List<Track> = jacksonObjectMapper().readValue("[${trackStr}]")

for (track in tracks) {
if (track.file == null || track.label == null) continue
Expand All @@ -53,7 +52,7 @@ open class HDMomPlayer : ExtractorApi() {
ExtractorLink(
source = this.name,
name = this.name,
url = m3u_link ?: throw ErrorLoadingException("m3u link not found"),
url = m3uLink ?: throw ErrorLoadingException("m3u link not found"),
referer = url,
quality = Qualities.Unknown.value,
isM3u8 = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,36 @@ open class HDPlayerSystem : ExtractorApi() {
override val requiresReferer = true

override suspend fun getUrl(url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit) {
val ext_ref = referer ?: ""
val vid_id = if (url.contains("video/")) {
val extRef = referer ?: ""
val vidId = if (url.contains("video/")) {
url.substringAfter("video/")
} else {
url.substringAfter("?data=")
}
val post_url = "${mainUrl}/player/index.php?data=${vid_id}&do=getVideo"
Log.d("Kekik_${this.name}", "post_url » ${post_url}")
val postUrl = "${mainUrl}/player/index.php?data=${vidId}&do=getVideo"

val response = app.post(
post_url,
postUrl,
data = mapOf(
"hash" to vid_id,
"r" to ext_ref
"hash" to vidId,
"r" to extRef
),
referer = ext_ref,
referer = extRef,
headers = mapOf(
"Content-Type" to "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With" to "XMLHttpRequest"
)
)

val video_response = response.parsedSafe<SystemResponse>() ?: throw ErrorLoadingException("failed to parse response")
val m3u_link = video_response.securedLink
val videoResponse = response.parsedSafe<SystemResponse>() ?: throw ErrorLoadingException("failed to parse response")
val m3uLink = videoResponse.securedLink

callback.invoke(
ExtractorLink(
source = this.name,
name = this.name,
url = m3u_link,
referer = ext_ref,
url = m3uLink,
referer = extRef,
quality = Qualities.Unknown.value,
type = INFER_TYPE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,25 @@ open class MailRu : ExtractorApi() {
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 extRef = referer ?: ""

val vid_id = url.substringAfter("video/embed/").trim()
val video_req = app.get("${mainUrl}/+/video/meta/${vid_id}", referer=url)
val video_key = video_req.cookies["video_key"].toString()
Log.d("Kekik_${this.name}", "video_key » ${video_key}")
val vidId = url.substringAfter("video/embed/").trim()
val videoReq = app.get("${mainUrl}/+/video/meta/${vidId}", referer=url)
val videoKey = videoReq.cookies["video_key"].toString()

val video_data = AppUtils.tryParseJson<MailRuData>(video_req.text) ?: throw ErrorLoadingException("Video not found")
val videoData = AppUtils.tryParseJson<MailRuData>(videoReq.text) ?: throw ErrorLoadingException("Video not found")

for (video in video_data.videos) {
Log.d("Kekik_${this.name}", "video » ${video}")
for (video in videoData.videos) {

val video_url = if (video.url.startsWith("//")) "https:${video.url}" else video.url
val videoUrl = if (video.url.startsWith("//")) "https:${video.url}" else video.url

callback.invoke(
ExtractorLink(
source = this.name,
name = this.name,
url = video_url,
url = videoUrl,
referer = url,
headers = mapOf("Cookie" to "video_key=${video_key}"),
headers = mapOf("Cookie" to "video_key=${videoKey}"),
quality = getQualityFromName(video.key),
isM3u8 = false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@ open class Odnoklassniki : ExtractorApi() {
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 extRef = referer ?: ""

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 userAgent = 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("\\&quot;", "\"").replace("\\\\", "\\")
val videoReq = app.get(url, headers=userAgent).text.replace("\\&quot;", "\"").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")
val videosStr = Regex("""\"videos\":(\[[^\]]*\])""").find(videoReq)?.groupValues?.get(1) ?: throw ErrorLoadingException("Video not found")
val videos = AppUtils.tryParseJson<List<OkRuVideo>>(videosStr) ?: 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 videoUrl = if (video.url.startsWith("//")) "https:${video.url}" else video.url

val quality = video.name.uppercase()
.replace("MOBILE", "144p")
Expand All @@ -44,10 +42,10 @@ open class Odnoklassniki : ExtractorApi() {
ExtractorLink(
source = this.name,
name = this.name,
url = video_url,
url = videoUrl,
referer = url,
quality = getQualityFromName(quality),
headers = user_agent,
headers = userAgent,
isM3u8 = false
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,47 @@ open class PeaceMakerst : ExtractorApi() {
override val requiresReferer = true

override suspend fun getUrl(url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit) {
val m3u_link:String?
val ext_ref = referer ?: ""
val post_url = "${url}?do=getVideo"
Log.d("Kekik_${this.name}", "post_url » ${post_url}")
val m3uLink:String?
val extRef = referer ?: ""
val postUrl = "${url}?do=getVideo"

val response = app.post(
post_url,
postUrl,
data = mapOf(
"hash" to url.substringAfter("video/"),
"r" to ext_ref,
"r" to extRef,
"s" to ""
),
referer = ext_ref,
referer = extRef,
headers = mapOf(
"Content-Type" to "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With" to "XMLHttpRequest"
)
)
if (response.text.contains("teve2.com.tr\\/embed\\/")) {
val teve2_id = response.text.substringAfter("teve2.com.tr\\/embed\\/").substringBefore("\"")
val teve2_response = app.get(
"https://www.teve2.com.tr/action/media/${teve2_id}",
referer = "https://www.teve2.com.tr/embed/${teve2_id}"
val teve2Id = response.text.substringAfter("teve2.com.tr\\/embed\\/").substringBefore("\"")
val teve2Response = app.get(
"https://www.teve2.com.tr/action/media/${teve2Id}",
referer = "https://www.teve2.com.tr/embed/${teve2Id}"
).parsedSafe<Teve2ApiResponse>() ?: throw ErrorLoadingException("teve2 response is null")

m3u_link = teve2_response.media.link.serviceUrl + "//" + teve2_response.media.link.securePath
m3uLink = teve2Response.media.link.serviceUrl + "//" + teve2Response.media.link.securePath
} else {
val video_response = response.parsedSafe<PeaceResponse>() ?: throw ErrorLoadingException("peace response is null")
val video_sources = video_response.videoSources
if (video_sources.isNotEmpty()) {
m3u_link = video_sources.lastOrNull()?.file
val videoResponse = response.parsedSafe<PeaceResponse>() ?: throw ErrorLoadingException("peace response is null")
val videoSources = videoResponse.videoSources
if (videoSources.isNotEmpty()) {
m3uLink = videoSources.lastOrNull()?.file
} else {
m3u_link = null
m3uLink = null
}
}

callback.invoke(
ExtractorLink(
source = this.name,
name = this.name,
url = m3u_link ?: throw ErrorLoadingException("m3u link not found"),
referer = ext_ref,
url = m3uLink ?: throw ErrorLoadingException("m3u link not found"),
referer = extRef,
quality = Qualities.Unknown.value,
type = INFER_TYPE
)
Expand Down
Loading

0 comments on commit 30adb1c

Please sign in to comment.