Skip to content

Commit 30adb1c

Browse files
fixed: Test Search & VidMoxy, RapidVid extractors (#1219)
1 parent 63e27c2 commit 30adb1c

File tree

13 files changed

+155
-150
lines changed

13 files changed

+155
-150
lines changed

app/src/main/java/com/lagradost/cloudstream3/utils/TestingUtils.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.lagradost.cloudstream3.*
44
import com.lagradost.cloudstream3.mvvm.logError
55
import kotlinx.coroutines.*
66
import org.junit.Assert
7+
import kotlin.random.Random
78

89
object TestingUtils {
910
open class TestResult(val success: Boolean) {
@@ -280,8 +281,8 @@ object TestingUtils {
280281

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

library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ContentXExtractor.kt

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,52 @@ open class ContentX : ExtractorApi() {
1212
override val requiresReferer = true
1313

1414
override suspend fun getUrl(url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit) {
15-
val ext_ref = referer ?: ""
16-
Log.d("Kekik_${this.name}", "url » ${url}")
15+
val extRef = referer ?: ""
1716

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

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

25-
if (sub_url in sub_urls) { return@forEach }
26-
sub_urls.add(sub_url)
24+
if (subUrl in subUrls) { return@forEach }
25+
subUrls.add(subUrl)
2726

2827
subtitleCallback.invoke(
2928
SubtitleFile(
30-
lang = sub_lang.replace("\\u0131", "ı").replace("\\u0130", "İ").replace("\\u00fc", "ü").replace("\\u00e7", "ç"),
31-
url = fixUrl(sub_url.replace("\\", ""))
29+
lang = subLang.replace("\\u0131", "ı").replace("\\u0130", "İ").replace("\\u00fc", "ü").replace("\\u00e7", "ç"),
30+
url = fixUrl(subUrl.replace("\\", ""))
3231
)
3332
)
3433
}
3534

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

4039
callback.invoke(
4140
ExtractorLink(
4241
source = this.name,
4342
name = this.name,
44-
url = m3u_link,
43+
url = m3uLink,
4544
referer = url,
4645
quality = Qualities.Unknown.value,
4746
isM3u8 = true
4847
)
4948
)
5049

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

5756
callback.invoke(
5857
ExtractorLink(
5958
source = "${this.name} Türkçe Dublaj",
6059
name = "${this.name} Türkçe Dublaj",
61-
url = dublaj_link,
60+
url = dublajLink,
6261
referer = url,
6362
quality = Qualities.Unknown.value,
6463
isM3u8 = true

library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,23 @@ open class HDMomPlayer : ExtractorApi() {
1616
override val requiresReferer = true
1717

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

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

30-
m3u_link = Regex("""video_location\":\"([^\"]+)""").find(encrypted)?.groupValues?.get(1)
29+
m3uLink = Regex("""video_location\":\"([^\"]+)""").find(encrypted)?.groupValues?.get(1)
3130
} else {
32-
m3u_link = Regex("""file:\"([^\"]+)""").find(i_source)?.groupValues?.get(1)
31+
m3uLink = Regex("""file:\"([^\"]+)""").find(iSource)?.groupValues?.get(1)
3332

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

3837
for (track in tracks) {
3938
if (track.file == null || track.label == null) continue
@@ -53,7 +52,7 @@ open class HDMomPlayer : ExtractorApi() {
5352
ExtractorLink(
5453
source = this.name,
5554
name = this.name,
56-
url = m3u_link ?: throw ErrorLoadingException("m3u link not found"),
55+
url = m3uLink ?: throw ErrorLoadingException("m3u link not found"),
5756
referer = url,
5857
quality = Qualities.Unknown.value,
5958
isM3u8 = true

library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,36 @@ open class HDPlayerSystem : ExtractorApi() {
1313
override val requiresReferer = true
1414

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

2524
val response = app.post(
26-
post_url,
25+
postUrl,
2726
data = mapOf(
28-
"hash" to vid_id,
29-
"r" to ext_ref
27+
"hash" to vidId,
28+
"r" to extRef
3029
),
31-
referer = ext_ref,
30+
referer = extRef,
3231
headers = mapOf(
3332
"Content-Type" to "application/x-www-form-urlencoded; charset=UTF-8",
3433
"X-Requested-With" to "XMLHttpRequest"
3534
)
3635
)
3736

38-
val video_response = response.parsedSafe<SystemResponse>() ?: throw ErrorLoadingException("failed to parse response")
39-
val m3u_link = video_response.securedLink
37+
val videoResponse = response.parsedSafe<SystemResponse>() ?: throw ErrorLoadingException("failed to parse response")
38+
val m3uLink = videoResponse.securedLink
4039

4140
callback.invoke(
4241
ExtractorLink(
4342
source = this.name,
4443
name = this.name,
45-
url = m3u_link,
46-
referer = ext_ref,
44+
url = m3uLink,
45+
referer = extRef,
4746
quality = Qualities.Unknown.value,
4847
type = INFER_TYPE
4948
)

library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,25 @@ open class MailRu : ExtractorApi() {
1313
override val requiresReferer = false
1414

1515
override suspend fun getUrl(url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit) {
16-
val ext_ref = referer ?: ""
17-
Log.d("Kekik_${this.name}", "url » ${url}")
16+
val extRef = referer ?: ""
1817

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

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

26-
for (video in video_data.videos) {
27-
Log.d("Kekik_${this.name}", "video » ${video}")
24+
for (video in videoData.videos) {
2825

29-
val video_url = if (video.url.startsWith("//")) "https:${video.url}" else video.url
26+
val videoUrl = if (video.url.startsWith("//")) "https:${video.url}" else video.url
3027

3128
callback.invoke(
3229
ExtractorLink(
3330
source = this.name,
3431
name = this.name,
35-
url = video_url,
32+
url = videoUrl,
3633
referer = url,
37-
headers = mapOf("Cookie" to "video_key=${video_key}"),
34+
headers = mapOf("Cookie" to "video_key=${videoKey}"),
3835
quality = getQualityFromName(video.key),
3936
isM3u8 = false
4037
)

library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,20 @@ open class Odnoklassniki : ExtractorApi() {
1313
override val requiresReferer = false
1414

1515
override suspend fun getUrl(url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit) {
16-
val ext_ref = referer ?: ""
17-
Log.d("Kekik_${this.name}", "url » ${url}")
16+
val extRef = referer ?: ""
1817

19-
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")
18+
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")
2019

21-
val video_req = app.get(url, headers=user_agent).text.replace("\\&quot;", "\"").replace("\\\\", "\\")
20+
val videoReq = app.get(url, headers=userAgent).text.replace("\\&quot;", "\"").replace("\\\\", "\\")
2221
.replace(Regex("\\\\u([0-9A-Fa-f]{4})")) { matchResult ->
2322
Integer.parseInt(matchResult.groupValues[1], 16).toChar().toString()
2423
}
25-
val videos_str = Regex("""\"videos\":(\[[^\]]*\])""").find(video_req)?.groupValues?.get(1) ?: throw ErrorLoadingException("Video not found")
26-
val videos = AppUtils.tryParseJson<List<OkRuVideo>>(videos_str) ?: throw ErrorLoadingException("Video not found")
24+
val videosStr = Regex("""\"videos\":(\[[^\]]*\])""").find(videoReq)?.groupValues?.get(1) ?: throw ErrorLoadingException("Video not found")
25+
val videos = AppUtils.tryParseJson<List<OkRuVideo>>(videosStr) ?: throw ErrorLoadingException("Video not found")
2726

2827
for (video in videos) {
29-
Log.d("Kekik_${this.name}", "video » ${video}")
3028

31-
val video_url = if (video.url.startsWith("//")) "https:${video.url}" else video.url
29+
val videoUrl = if (video.url.startsWith("//")) "https:${video.url}" else video.url
3230

3331
val quality = video.name.uppercase()
3432
.replace("MOBILE", "144p")
@@ -44,10 +42,10 @@ open class Odnoklassniki : ExtractorApi() {
4442
ExtractorLink(
4543
source = this.name,
4644
name = this.name,
47-
url = video_url,
45+
url = videoUrl,
4846
referer = url,
4947
quality = getQualityFromName(quality),
50-
headers = user_agent,
48+
headers = userAgent,
5149
isM3u8 = false
5250
)
5351
)

library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,47 @@ open class PeaceMakerst : ExtractorApi() {
1313
override val requiresReferer = true
1414

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

2120
val response = app.post(
22-
post_url,
21+
postUrl,
2322
data = mapOf(
2423
"hash" to url.substringAfter("video/"),
25-
"r" to ext_ref,
24+
"r" to extRef,
2625
"s" to ""
2726
),
28-
referer = ext_ref,
27+
referer = extRef,
2928
headers = mapOf(
3029
"Content-Type" to "application/x-www-form-urlencoded; charset=UTF-8",
3130
"X-Requested-With" to "XMLHttpRequest"
3231
)
3332
)
3433
if (response.text.contains("teve2.com.tr\\/embed\\/")) {
35-
val teve2_id = response.text.substringAfter("teve2.com.tr\\/embed\\/").substringBefore("\"")
36-
val teve2_response = app.get(
37-
"https://www.teve2.com.tr/action/media/${teve2_id}",
38-
referer = "https://www.teve2.com.tr/embed/${teve2_id}"
34+
val teve2Id = response.text.substringAfter("teve2.com.tr\\/embed\\/").substringBefore("\"")
35+
val teve2Response = app.get(
36+
"https://www.teve2.com.tr/action/media/${teve2Id}",
37+
referer = "https://www.teve2.com.tr/embed/${teve2Id}"
3938
).parsedSafe<Teve2ApiResponse>() ?: throw ErrorLoadingException("teve2 response is null")
4039

41-
m3u_link = teve2_response.media.link.serviceUrl + "//" + teve2_response.media.link.securePath
40+
m3uLink = teve2Response.media.link.serviceUrl + "//" + teve2Response.media.link.securePath
4241
} else {
43-
val video_response = response.parsedSafe<PeaceResponse>() ?: throw ErrorLoadingException("peace response is null")
44-
val video_sources = video_response.videoSources
45-
if (video_sources.isNotEmpty()) {
46-
m3u_link = video_sources.lastOrNull()?.file
42+
val videoResponse = response.parsedSafe<PeaceResponse>() ?: throw ErrorLoadingException("peace response is null")
43+
val videoSources = videoResponse.videoSources
44+
if (videoSources.isNotEmpty()) {
45+
m3uLink = videoSources.lastOrNull()?.file
4746
} else {
48-
m3u_link = null
47+
m3uLink = null
4948
}
5049
}
5150

5251
callback.invoke(
5352
ExtractorLink(
5453
source = this.name,
5554
name = this.name,
56-
url = m3u_link ?: throw ErrorLoadingException("m3u link not found"),
57-
referer = ext_ref,
55+
url = m3uLink ?: throw ErrorLoadingException("m3u link not found"),
56+
referer = extRef,
5857
quality = Qualities.Unknown.value,
5958
type = INFER_TYPE
6059
)

0 commit comments

Comments
 (0)