[Refactor] Minor adjustments to Source selection names (#954)

* [Refactor] Minor adjustment to name + quality display on Sources

* Minor refactor on some extractors to prevent duplicate qualities displaying on Source name
This commit is contained in:
Jace 2022-04-15 21:06:43 +08:00 committed by GitHub
parent a4735c41ba
commit d969fe42da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 38 additions and 26 deletions

View file

@ -23,13 +23,12 @@ open class PlayerVoxzer : ExtractorApi() {
), true ), true
) )
.map { stream -> .map { stream ->
val qualityString = if ((stream.quality ?: 0) == 0) "" else "${stream.quality}p"
sources.add( ExtractorLink( sources.add( ExtractorLink(
name, name,
"$name $qualityString", name = name,
stream.streamUrl, stream.streamUrl,
url, url,
getQualityFromName(stream.quality.toString()), getQualityFromName(stream.quality?.toString()),
true true
)) ))
} }

View file

@ -111,13 +111,12 @@ open class StreamSB : ExtractorApi() {
) )
.map { stream -> .map { stream ->
// val cleanstreamurl = stream.streamUrl.replace(Regex("https://.*/hls/"), "$urlmain/hls/") // val cleanstreamurl = stream.streamUrl.replace(Regex("https://.*/hls/"), "$urlmain/hls/")
val qualityString = if ((stream.quality ?: 0) == 0) "" else "${stream.quality}p"
ExtractorLink( ExtractorLink(
name, name,
"$name $qualityString", name = name,
stream.streamUrl, stream.streamUrl,
url, url,
getQualityFromName(stream.quality.toString()), getQualityFromName(stream.quality?.toString()),
true true
) )
} }

View file

@ -48,7 +48,7 @@ class UpstreamExtractor: ExtractorApi() {
source = this.name, source = this.name,
url = linkUrl, url = linkUrl,
quality = Qualities.Unknown.value, quality = Qualities.Unknown.value,
referer = referer!!, referer = referer ?: linkUrl,
isM3u8 = true isM3u8 = true
) )
) )

View file

@ -61,7 +61,7 @@ class Vidstream(val mainUrl: String) {
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
this.name, this.name,
if (qual == "null") this.name else "${this.name} - " + qual + "p", name = this.name,
href, href,
page.url, page.url,
getQualityFromName(qual), getQualityFromName(qual),

View file

@ -35,7 +35,7 @@ open class VoeExtractor : ExtractorApi() {
if (!linkUrl.isNullOrEmpty()) { if (!linkUrl.isNullOrEmpty()) {
extractedLinksList.add( extractedLinksList.add(
ExtractorLink( ExtractorLink(
name = "Voe $linkLabel", name = this.name,
source = this.name, source = this.name,
url = linkUrl, url = linkUrl,
quality = getQualityFromName(linkLabel), quality = getQualityFromName(linkLabel),

View file

@ -26,13 +26,12 @@ open class WatchSB : ExtractorApi() {
), true ), true
) )
.map { stream -> .map { stream ->
val qualityString = if ((stream.quality ?: 0) == 0) "" else "${stream.quality}p"
ExtractorLink( ExtractorLink(
name, name,
"$name $qualityString", name = name,
stream.streamUrl, stream.streamUrl,
url, url,
getQualityFromName(stream.quality.toString()), getQualityFromName(stream.quality?.toString()),
true true
) )
} }

View file

@ -99,7 +99,7 @@ open class WcoStream : ExtractorApi() {
sources.add( sources.add(
ExtractorLink( ExtractorLink(
"VidStream", "VidStream",
"VidStream $quality", "VidStream",
serverurl, serverurl,
url, url,
getQualityFromName(quality), getQualityFromName(quality),
@ -117,15 +117,13 @@ open class WcoStream : ExtractorApi() {
hlsHelper.m3u8Generation(M3u8Helper.M3u8Stream(it.file.replace("#.mp4",""), null, hlsHelper.m3u8Generation(M3u8Helper.M3u8Stream(it.file.replace("#.mp4",""), null,
headers = mapOf("Referer" to url)), true) headers = mapOf("Referer" to url)), true)
.forEach { stream -> .forEach { stream ->
val qualityString =
if ((stream.quality ?: 0) == 0) "" else "${stream.quality}p"
sources.add( sources.add(
ExtractorLink( ExtractorLink(
name, name,
"$name $qualityString", name = name,
stream.streamUrl, stream.streamUrl,
url, url,
getQualityFromName(stream.quality.toString()), getQualityFromName(stream.quality?.toString()),
true, true,
) )
) )
@ -134,7 +132,7 @@ open class WcoStream : ExtractorApi() {
sources.add( sources.add(
ExtractorLink( ExtractorLink(
name, name,
name + if (it.label != null) " - ${it.label}" else "", name = name,
it.file, it.file,
"", "",
Qualities.P720.value, Qualities.P720.value,

View file

@ -48,7 +48,7 @@ open class XStreamCdn : ExtractorApi() {
extractedLinksList.add( extractedLinksList.add(
ExtractorLink( ExtractorLink(
name, name,
"$name ${data.label}", name = name,
data.file, data.file,
url, url,
getQualityFromName(data.label), getQualityFromName(data.label),

View file

@ -44,13 +44,12 @@ open class ZplayerV2 : ExtractorApi() {
), true ), true
) )
.map { stream -> .map { stream ->
val qualityString = if ((stream.quality ?: 0) == 0) "" else "${stream.quality}p"
sources.add( ExtractorLink( sources.add( ExtractorLink(
name, source = name,
"$name $qualityString", name = name,
stream.streamUrl, stream.streamUrl,
url, url,
getQualityFromName(stream.quality.toString()), getQualityFromName(stream.quality?.toString()),
true true
)) ))
} }

View file

@ -265,7 +265,8 @@ class GeneratorPlayer : FullScreenPlayer() {
ArrayAdapter<String>(ctx, R.layout.sort_bottom_single_choice) ArrayAdapter<String>(ctx, R.layout.sort_bottom_single_choice)
sourcesArrayAdapter.addAll(sortedUrls.map { sourcesArrayAdapter.addAll(sortedUrls.map {
it.first?.name ?: it.second?.name ?: "NULL" val name = it.first?.name ?: it.second?.name ?: "NULL"
"$name ${Qualities.getStringByInt(it.first?.quality)}"
}) })
providerList.choiceMode = AbsListView.CHOICE_MODE_SINGLE providerList.choiceMode = AbsListView.CHOICE_MODE_SINGLE

View file

@ -51,10 +51,27 @@ enum class Qualities(var value: Int) {
P720(1), // 720p P720(1), // 720p
P1080(2), // 1080p P1080(2), // 1080p
P1440(3), // 1440p P1440(3), // 1440p
P2160(4) // 4k or 2160p P2160(4); // 4k or 2160p
companion object {
fun getStringByInt(qual: Int?) : String {
return when (qual) {
P360.value -> "360p"
P480.value -> "480p"
P720.value -> "720p"
P1080.value -> "1080p"
P1440.value -> "1440p"
P2160.value -> "2160p/4k"
else -> ""
}
}
}
} }
fun getQualityFromName(qualityName: String): Int { fun getQualityFromName(qualityName: String?): Int {
if (qualityName == null) {
return Qualities.Unknown.value
}
return when (qualityName.replace("p", "").replace("P", "").trim()) { return when (qualityName.replace("p", "").replace("P", "").trim()) {
"360" -> Qualities.P360 "360" -> Qualities.P360
"480" -> Qualities.P480 "480" -> Qualities.P480