Skip to content
Open

Test #442

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
app.get(
"https://raw.githubusercontent.com/recloudstream/.github/master/connectivitycheck",
timeout = 5
).text.trim() == "ok"
).text().trim() == "ok"
} catch (t: Throwable) {
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DdosGuardKiller(private val alwaysBypass: Boolean) : Interceptor {
ddosBypassPath = ddosBypassPath ?: Regex("'(.*?)'").find(
app.get(
"https://check.ddos-guard.net/check.js"
).text
).text()
)?.groupValues?.get(1)

val cookies =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ object RepositoryManager {
val response = app.get(convertRawGitUrl(pluginUrls))
// Normal parsed function not working?
// return response.parsedSafe()
tryParseJson<Array<SitePlugin>>(response.text)?.toList() ?: emptyList()
tryParseJson<Array<SitePlugin>>(response.text())?.toList() ?: emptyList()
} catch (t: Throwable) {
logError(t)
emptyList()
Expand Down Expand Up @@ -177,7 +177,7 @@ object RepositoryManager {
// Prevent corrupting the plugin file if the operation fails
val tempFile = File.createTempFile(file.name, ".tmp", context.cacheDir)

val body = app.get(convertRawGitUrl(pluginUrl)).okhttpResponse.body
val body = app.get(convertRawGitUrl(pluginUrl)).body()

body.byteStream().use { body ->
tempFile.outputStream().use { fileSteam ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object VotingApi {
val id = transformUrl(pluginUrl)
val url = "$API_DOMAIN/increment/$id"
Log.d(LOGKEY, "Requesting POST: $url")
return app.post(url, emptyMap<String, String>())
return app.post(url) { headers = emptyMap<String, String>() }
.parsedSafe<CountifyResult>()?.count != null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class PackageInstallerService : Service() {
ApkInstaller.InstallProgressStatus.Downloading
)

val body = app.get(url).body
val body = app.get(url).body()
val inputStream = body.byteStream()
installer = ApkInstaller(this)
val totalSize = body.contentLength()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class SubtitleResource {
url: String,
nameGenerator: (String, File) -> String? = { _, _ -> null }
) {
val source = app.get(url).okhttpResponse.body.source()
val source = app.get(url).body().source()
val zip = downloadFile(source)
val realFiles = unzip(zip)
zip.deleteRecursively()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.syncproviders.providers

import com.lagradost.cloudstream3.AllLanguagesName
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.ksoupDocument
import com.lagradost.cloudstream3.subtitles.AbstractSubtitleEntities.SubtitleEntity
import com.lagradost.cloudstream3.subtitles.AbstractSubtitleEntities.SubtitleSearch
import com.lagradost.cloudstream3.syncproviders.AuthData
Expand Down Expand Up @@ -66,8 +65,8 @@ class Addic7ed : SubtitleAPI() {
)
}

val response = app.get(url = "$HOST/search.php?search=$searchQuery&Submit=Search")
val hostDocument = response.ksoupDocument
val response = app.get("$HOST/search.php?search=$searchQuery&Submit=Search")
val hostDocument = response.document()

// 1st case: found one movie or episode. Redirected to $HOST/movie/1234 or $HOST/serie/show-name/$seasonNum/$epNum/ep-name
if (response.url.contains("/movie/") || response.url.contains("/serie/"))
Expand All @@ -79,7 +78,7 @@ class Addic7ed : SubtitleAPI() {
val doc = app.get(
"$HOST/ajax_loadShow.php?show=$showId&season=$seasonNum&langs=|$langNumAddic7ed|&hd=0&hi=0",
referer = "$HOST/"
).ksoupDocument
).document()

// get direct subtitles links from list
return doc.select("#season tbody tr").mapNotNull { node ->
Expand All @@ -106,7 +105,7 @@ class Addic7ed : SubtitleAPI() {
// filter download page by language. Do not work for movies :/
if (downloadPage.contains("/serie/"))
downloadPage = downloadPage.substringBeforeLast("/") + "/$langNumAddic7ed"
val doc = app.get(url = downloadPage).ksoupDocument
val doc = app.get(url = downloadPage).document()

// get subtitles links from download page
return doc.select(".tabel95 .tabel95 tr:has(.language):contains($langName)").mapNotNull { node ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class AniListApi : SyncAPI() {
//headers = mapOf(),
data = data,//(if (vars == null) mapOf("query" to q) else mapOf("query" to q, "variables" to vars))
timeout = 5000 // REASONABLE TIMEOUT
).text.replace("\\", "")
).text().replace("\\", "")
return res.toKotlinObject()
} catch (e: Exception) {
logError(e)
Expand Down Expand Up @@ -453,7 +453,7 @@ class AniListApi : SyncAPI() {
"https://graphql.anilist.co",
data = mapOf("query" to q),
cacheTime = 0,
).text
).text()

return tryParseJson(data) ?: throw ErrorLoadingException("Error parsing $data")
}
Expand Down Expand Up @@ -521,7 +521,7 @@ class AniListApi : SyncAPI() {
)
), //(if (vars == null) mapOf("query" to q) else mapOf("query" to q, "variables" to vars))
timeout = 5 // REASONABLE TIMEOUT
).text.replace("\\/", "/")
).text().replace("\\/", "/")
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class MALApi : SyncAPI() {
url, headers = mapOf(
"Authorization" to "Bearer $auth"
)
).text
).text()
return parseJson<MalAnime>(res).let { malAnime ->
SyncAPI.SyncResult(
id = internalId.toString(),
Expand Down Expand Up @@ -539,7 +539,7 @@ class MALApi : SyncAPI() {
url, headers = mapOf(
"Authorization" to "Bearer ${token.accessToken}",
), cacheTime = 0
).text
).text()
return res.toKotlinObject()
}

Expand Down Expand Up @@ -592,7 +592,7 @@ class MALApi : SyncAPI() {
"Authorization" to "Bearer ${token.accessToken}"
),
data = data
).text
).text()
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object Torrent {
return try {
app.get(
"$TORRENT_SERVER_URL/echo",
).text.isNotEmpty()
).text().isNotEmpty()
} catch (e: ConnectException) {
// `Failed to connect to /127.0.0.1:8090` if the server is down
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ object InAppUpdater {
val url = "https://api.github.com/repos/$GITHUB_USER_NAME/$GITHUB_REPO/releases"
val headers = mapOf("Accept" to "application/vnd.github.v3+json")
val response = parseJson<List<GithubRelease>>(
app.get(url, headers = headers).text
app.get(url, headers = headers).text()
)

val versionRegex = Regex("""(.*?((\d+)\.(\d+)\.(\d+))\.apk)""")
Expand Down Expand Up @@ -151,7 +151,7 @@ object InAppUpdater {
val releaseUrl = "https://api.github.com/repos/$GITHUB_USER_NAME/$GITHUB_REPO/releases"
val headers = mapOf("Accept" to "application/vnd.github.v3+json")
val response = parseJson<List<GithubRelease>>(
app.get(releaseUrl, headers = headers).text
app.get(releaseUrl, headers = headers).text()
)

val found = response.lastOrNull { rel ->
Expand Down Expand Up @@ -196,7 +196,7 @@ object InAppUpdater {
val sink: BufferedSink = downloadedFile.sink().buffer()

updateLock.withLock {
sink.writeAll(app.get(url).body.source())
sink.writeAll(app.get(url).body().source())
sink.close()
openApk(this, Uri.fromFile(downloadedFile))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object SyncUtil {
//Gogoanime, Twistmoe and 9anime
val url =
"https://raw.githubusercontent.com/MALSync/MAL-Sync-Backup/master/data/pages/$site/$slug.json"
val response = app.get(url, cacheTime = 1, cacheUnit = TimeUnit.DAYS).text
val response = app.get(url, cacheTime = 1, cacheUnit = TimeUnit.DAYS).text()
val mapped = parseJson<MalSyncPage?>(response)

val overrideMal = mapped?.malId ?: mapped?.mal?.id ?: mapped?.anilist?.malId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ object VideoDownloadManager {
referer = referer,
verify = false
)
val requestStream = request.body.byteStream()
val requestStream = request.body().byteStream()

val buffer = ByteArray(bufferSize)
var read: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ actual class WebViewResolver actual constructor(
useOkhttp && request.method == "GET" -> app.get(
webViewUrl,
headers = request.requestHeaders
).okhttpResponse.toWebResourceResponse()
).toWebResourceResponse()

useOkhttp && request.method == "POST" -> app.post(
webViewUrl,
headers = request.requestHeaders
).okhttpResponse.toWebResourceResponse()
).toWebResourceResponse()

else -> super.shouldInterceptRequest(
view,
Expand Down Expand Up @@ -294,16 +294,16 @@ fun WebResourceRequest.toRequest(): Request? {
}
}

fun NiceResponse.toWebResourceResponse(): WebResourceResponse {
val contentTypeValue = this.header("Content-Type")
suspend fun NiceResponse.toWebResourceResponse(): WebResourceResponse {
val contentTypeValue = this.headers["Content-Type"]
// 1. contentType. 2. charset
val typeRegex = Regex("""(.*);(?:.*charset=(.*)(?:|;)|)""")
return if (contentTypeValue != null) {
val found = typeRegex.find(contentTypeValue)
val contentType = found?.groupValues?.getOrNull(1)?.ifBlank { null } ?: contentTypeValue
val charset = found?.groupValues?.getOrNull(2)?.ifBlank { null }
WebResourceResponse(contentType, charset, this.body.byteStream())
WebResourceResponse(contentType, charset, this.body().byteStream())
} else {
WebResourceResponse("application/octet-stream", null, this.body.byteStream())
WebResourceResponse("application/octet-stream", null, this.body().byteStream())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ object APIHolder {
referer = referer,
cacheTime = 0
)
.text
.text()
.substringAfter("releases/")
.substringBefore("/")
val recapToken =
app.get("https://www.google.com/recaptcha/api2/anchor?ar=1&hl=en&size=invisible&cb=cs3&k=$key&co=$domain&v=$vToken")
.ksoupDocument
.document()
.selectFirst("#recaptcha-token")?.attr("value")
if (recapToken != null) {
return app.post(
Expand All @@ -190,7 +190,7 @@ object APIHolder {
"sa" to "",
"reason" to "q"
), cacheTime = 0
).text
).text()
.substringAfter("rresp\",\"")
.substringBefore("\"")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fleeksoft.ksoup.Ksoup
import com.fleeksoft.ksoup.nodes.Document
import com.lagradost.nicehttp.NiceResponse
import com.lagradost.nicehttp.Requests
import com.lagradost.nicehttp.ResponseParser
import io.ktor.client.engine.okhttp.OkHttpEngine
Expand Down Expand Up @@ -47,10 +46,6 @@ var app = Requests(responseParser = jacksonResponseParser).apply {
val okHttpClient = (app.baseClient.engine as? OkHttpEngine)
?.config?.preconfigured ?: OkHttpClient()

/** Parses the response body as a Ksoup Document. */
val NiceResponse.ksoupDocument: Document
get() = Ksoup.parse(text)

/** Same as the default app networking helper, but this instance ignores SSL certificates.
* This should NEVER be used for sensitive networking operations such as logins. Only use this when required. */
@Prerelease
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ open class Acefile : ExtractorApi() {
callback: (ExtractorLink) -> Unit
) {
val id = "/(?:d|download|player|f|file)/(\\w+)".toRegex().find(url)?.groupValues?.get(1)
val script = getAndUnpack(app.get("$mainUrl/player/${id ?: return}").text)
val script = getAndUnpack(app.get("$mainUrl/player/${id ?: return}").text())
val service = """service\s*=\s*['"]([^'"]+)""".toRegex().find(script)?.groupValues?.get(1)
val serverUrl = """['"](\S+check&id\S+?)['"]""".toRegex().find(script)?.groupValues?.get(1)
?.replace("\"+service+\"", service ?: return)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.extractors

import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.ksoupDocument
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson

Expand All @@ -13,7 +12,7 @@ open class Blogger : ExtractorApi() {

override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink> {
val sources = mutableListOf<ExtractorLink>()
with(app.get(url).ksoupDocument) {
with(app.get(url).document()) {
this.select("script").map { script ->
if (script.data().contains("\"streams\":[")) {
val data = script.data().substringAfter("\"streams\":[")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.extractors

import com.lagradost.cloudstream3.USER_AGENT
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.ksoupDocument
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
Expand All @@ -26,7 +25,7 @@ open class Cda : ExtractorApi() {
"User-Agent" to USER_AGENT,
"Cookie" to "cda.player=html5"
)
).ksoupDocument
).document()
val dataRaw = doc.selectFirst("[player_data]")?.attr("player_data") ?: return null
val playerData = tryParseJson<PlayerData>(dataRaw) ?: return null
return listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open class CloudMailRu : ExtractorApi() {
)
val vidId = url.substringAfter("public/").toByteArray()
val vidIdEnc = base64Encode(vidId)
val videoReq = app.get(url, headers=headers).text
val videoReq = app.get(url, headers=headers).text()
val regex = Regex(pattern = "videowl_view\":\\{\"count\":\"1\",\"url\":\"([^\"]*)\"\\}", options = setOf(RegexOption.IGNORE_CASE))
val videoMatch = regex.find(videoReq)?.groupValues?.get(1).toString()
val videoUrl = "$videoMatch/0p/$vidIdEnc.m3u8?double_encode=1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open class ContentX : ExtractorApi() {
override suspend fun getUrl(url: String, referer: String?, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit) {
val extRef = referer ?: ""

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

val subUrls = mutableSetOf<String>()
Expand All @@ -32,7 +32,7 @@ open class ContentX : ExtractorApi() {
)
}

val vidSource = app.get("${mainUrl}/source2.php?v=${iExtract}", referer=extRef).text
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("\\", "")

Expand All @@ -50,7 +50,7 @@ open class ContentX : ExtractorApi() {

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 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("\\", "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class Dailymotion : ExtractorApi() {
val id = getVideoId(embedUrl) ?: return
val metaDataUrl = "$baseUrl/player/metadata/video/$id"

val response = app.get(metaDataUrl, referer = embedUrl).text
val response = app.get(metaDataUrl, referer = embedUrl).text()
val gson = Gson()
val meta = gson.fromJson(response, MetaData::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ open class DoodLaExtractor : ExtractorApi() {
val embedUrl = url.replace("/d/", "/e/")
val req = app.get(embedUrl)
val host = getBaseUrl(req.url)
val response0 = req.text
val response0 = req.text()
val md5 = host + (Regex("/pass_md5/[^']*").find(response0)?.value ?: return)
val trueUrl = app.get(md5, referer = req.url).text + createHashTable() + "?token=" + md5.substringAfterLast("/")
val quality = Regex("\\d{3,4}p")
Expand Down
Loading