mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
quality stuff
This commit is contained in:
parent
96c074e87b
commit
b942e066ee
3 changed files with 43 additions and 49 deletions
|
@ -36,7 +36,7 @@ android {
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
|
|
||||||
versionCode 45
|
versionCode 45
|
||||||
versionName "2.9.19"
|
versionName "2.9.20"
|
||||||
|
|
||||||
resValue "string", "app_version",
|
resValue "string", "app_version",
|
||||||
"${defaultConfig.versionName}${versionNameSuffix ?: ""}"
|
"${defaultConfig.versionName}${versionNameSuffix ?: ""}"
|
||||||
|
|
|
@ -799,7 +799,7 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
|
||||||
val builder = AlertDialog.Builder(requireContext(), R.style.AlertDialogCustom)
|
val builder = AlertDialog.Builder(requireContext(), R.style.AlertDialogCustom)
|
||||||
|
|
||||||
builder.setTitle(title)
|
builder.setTitle(title)
|
||||||
builder.setItems(links.map { it.name }.toTypedArray()) { dia, which ->
|
builder.setItems(links.map { "${it.name} ${Qualities.getStringByInt(it.quality)}" }.toTypedArray()) { dia, which ->
|
||||||
callback.invoke(links[which])
|
callback.invoke(links[which])
|
||||||
dia?.dismiss()
|
dia?.dismiss()
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,44 +45,36 @@ data class ExtractorSubtitleLink(
|
||||||
) : VideoDownloadManager.IDownloadableMinimum
|
) : VideoDownloadManager.IDownloadableMinimum
|
||||||
|
|
||||||
enum class Qualities(var value: Int) {
|
enum class Qualities(var value: Int) {
|
||||||
Unknown(0),
|
Unknown(400),
|
||||||
P360(-2), // 360p
|
P144(144), // 144p
|
||||||
P480(-1), // 480p
|
P240(240), // 240p
|
||||||
P720(1), // 720p
|
P360(360), // 360p
|
||||||
P1080(2), // 1080p
|
P480(480), // 480p
|
||||||
P1440(3), // 1440p
|
P720(720), // 720p
|
||||||
P2160(4); // 4k or 2160p
|
P1080(1080), // 1080p
|
||||||
|
P1440(1440), // 1440p
|
||||||
|
P2160(2160); // 4k or 2160p
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getStringByInt(qual: Int?): String {
|
fun getStringByInt(qual: Int?): String {
|
||||||
return when (qual) {
|
return when (qual) {
|
||||||
P360.value -> "360p"
|
Unknown.value -> ""
|
||||||
P480.value -> "480p"
|
P2160.value -> "4K"
|
||||||
P720.value -> "720p"
|
else -> "${qual}p"
|
||||||
P1080.value -> "1080p"
|
|
||||||
P1440.value -> "1440p"
|
|
||||||
P2160.value -> "2160p/4k"
|
|
||||||
else -> ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getQualityFromName(qualityName: String?): Int {
|
fun getQualityFromName(qualityName: String?): Int {
|
||||||
if (qualityName == null) {
|
if (qualityName == null)
|
||||||
return Qualities.Unknown.value
|
return Qualities.Unknown.value
|
||||||
}
|
|
||||||
return when (qualityName.replace("p", "").replace("P", "").trim()) {
|
val match = qualityName.lowercase().replace("p", "").trim()
|
||||||
"360" -> Qualities.P360
|
return when (match) {
|
||||||
"480" -> Qualities.P480
|
|
||||||
"720" -> Qualities.P720
|
|
||||||
"1080" -> Qualities.P1080
|
|
||||||
"1440" -> Qualities.P1440
|
|
||||||
"2160" -> Qualities.P2160
|
|
||||||
"4k" -> Qualities.P2160
|
"4k" -> Qualities.P2160
|
||||||
"4K" -> Qualities.P2160
|
else -> null
|
||||||
else -> Qualities.Unknown
|
}?.value ?: match.toIntOrNull() ?: Qualities.Unknown.value
|
||||||
}.value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val packedRegex = Regex("""eval\(function\(p,a,c,k,e,.*\)\)""")
|
private val packedRegex = Regex("""eval\(function\(p,a,c,k,e,.*\)\)""")
|
||||||
|
@ -98,7 +90,11 @@ fun getAndUnpack(string: String): String {
|
||||||
/**
|
/**
|
||||||
* Tries to load the appropriate extractor based on link, returns true if any extractor is loaded.
|
* Tries to load the appropriate extractor based on link, returns true if any extractor is loaded.
|
||||||
* */
|
* */
|
||||||
suspend fun loadExtractor(url: String, referer: String? = null, callback: (ExtractorLink) -> Unit) : Boolean {
|
suspend fun loadExtractor(
|
||||||
|
url: String,
|
||||||
|
referer: String? = null,
|
||||||
|
callback: (ExtractorLink) -> Unit
|
||||||
|
): Boolean {
|
||||||
for (extractor in extractorApis) {
|
for (extractor in extractorApis) {
|
||||||
if (url.startsWith(extractor.mainUrl)) {
|
if (url.startsWith(extractor.mainUrl)) {
|
||||||
extractor.getSafeUrl(url, referer)?.forEach(callback)
|
extractor.getSafeUrl(url, referer)?.forEach(callback)
|
||||||
|
@ -216,7 +212,7 @@ suspend fun getPostForm(requestUrl : String, html : String) : String? {
|
||||||
}
|
}
|
||||||
delay(5000) // ye this is needed, wont work with 0 delay
|
delay(5000) // ye this is needed, wont work with 0 delay
|
||||||
|
|
||||||
val postResponse = app.post(
|
return app.post(
|
||||||
requestUrl,
|
requestUrl,
|
||||||
headers = mapOf(
|
headers = mapOf(
|
||||||
"content-type" to "application/x-www-form-urlencoded",
|
"content-type" to "application/x-www-form-urlencoded",
|
||||||
|
@ -226,8 +222,6 @@ suspend fun getPostForm(requestUrl : String, html : String) : String? {
|
||||||
),
|
),
|
||||||
data = mapOf("op" to op, "id" to id, "mode" to mode, "hash" to hash)
|
data = mapOf("op" to op, "id" to id, "mode" to mode, "hash" to hash)
|
||||||
).text
|
).text
|
||||||
|
|
||||||
return postResponse
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ExtractorApi {
|
abstract class ExtractorApi {
|
||||||
|
|
Loading…
Reference in a new issue