Merge branch 'master' into voting

This commit is contained in:
Cloudburst 2022-09-05 20:52:25 +02:00 committed by GitHub
commit d4b6a17ea9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 55 deletions

View file

@ -38,6 +38,9 @@ import com.lagradost.cloudstream3.utils.VideoDownloadManager
import kotlinx.android.synthetic.main.fragment_downloads.* import kotlinx.android.synthetic.main.fragment_downloads.*
import kotlinx.android.synthetic.main.stream_input.* import kotlinx.android.synthetic.main.stream_input.*
import android.text.format.Formatter.formatShortFileSize import android.text.format.Formatter.formatShortFileSize
import androidx.core.widget.doOnTextChanged
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
import java.net.URI
const val DOWNLOAD_NAVIGATE_TO = "downloadpage" const val DOWNLOAD_NAVIGATE_TO = "downloadpage"
@ -183,10 +186,29 @@ class DownloadFragment : Fragment() {
dialog.show() dialog.show()
// If user has clicked the switch do not interfere
var preventAutoSwitching = false
dialog.hls_switch?.setOnClickListener {
preventAutoSwitching = true
}
fun activateSwitchOnHls(text: String?) {
dialog.hls_switch?.isChecked = normalSafeApiCall {
URI(text).path?.substringAfterLast(".")?.contains("m3u")
} == true
}
dialog.stream_referer?.doOnTextChanged { text, _, _, _ ->
if (!preventAutoSwitching)
activateSwitchOnHls(text?.toString())
}
(activity?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager?)?.primaryClip?.getItemAt( (activity?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager?)?.primaryClip?.getItemAt(
0 0
)?.text?.toString()?.let { copy -> )?.text?.toString()?.let { copy ->
dialog.stream_url?.setText(copy) val fixedText = copy.trim()
dialog.stream_url?.setText(fixedText)
activateSwitchOnHls(fixedText)
} }
dialog.apply_btt?.setOnClickListener { dialog.apply_btt?.setOnClickListener {
@ -202,7 +224,8 @@ class DownloadFragment : Fragment() {
LinkGenerator( LinkGenerator(
listOf(url), listOf(url),
extract = true, extract = true,
referer = referer referer = referer,
isM3u8 = dialog.hls_switch?.isChecked
) )
) )
) )

View file

@ -553,8 +553,8 @@ class CS3IPlayer : IPlayer {
trackSelector.parameters = DefaultTrackSelector.ParametersBuilder(context) trackSelector.parameters = DefaultTrackSelector.ParametersBuilder(context)
// .setRendererDisabled(C.TRACK_TYPE_VIDEO, true) // .setRendererDisabled(C.TRACK_TYPE_VIDEO, true)
.setRendererDisabled(C.TRACK_TYPE_TEXT, true) .setRendererDisabled(C.TRACK_TYPE_TEXT, true)
// Experimental // Experimental, I think this causes issues with audio track init 5001
.setTunnelingEnabled(true) // .setTunnelingEnabled(true)
.setDisabledTextTrackSelectionFlags(C.TRACK_TYPE_TEXT) .setDisabledTextTrackSelectionFlags(C.TRACK_TYPE_TEXT)
// This will not force higher quality videos to fail // This will not force higher quality videos to fail
// but will make the m3u8 pick the correct preferred // but will make the m3u8 pick the correct preferred

View file

@ -1,12 +1,15 @@
package com.lagradost.cloudstream3.ui.player package com.lagradost.cloudstream3.ui.player
import com.lagradost.cloudstream3.apmap import com.lagradost.cloudstream3.apmap
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.*
import java.net.URI
class LinkGenerator( class LinkGenerator(
private val links: List<String>, private val links: List<String>,
private val extract: Boolean = true, private val extract: Boolean = true,
private val referer: String? = null, private val referer: String? = null,
private val isM3u8: Boolean? = null
) : IGenerator { ) : IGenerator {
override val hasCache = false override val hasCache = false
@ -57,7 +60,9 @@ class LinkGenerator(
link, link,
unshortenLinkSafe(link), // unshorten because it might be a raw link unshortenLinkSafe(link), // unshorten because it might be a raw link
referer ?: "", referer ?: "",
Qualities.Unknown.value, link.contains(".m3u") // TODO USE REAL PARSER Qualities.Unknown.value, isM3u8 ?: normalSafeApiCall {
URI(link).path?.substringAfterLast(".")?.contains("m3u")
} ?: false
) to null ) to null
) )
} }

View file

@ -1,73 +1,81 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:paddingStart="?android:attr/listPreferredItemPaddingStart" android:layout_width="match_parent"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:layout_height="wrap_content"> android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<TextView <TextView
android:id="@+id/text1" android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_marginTop="20dp" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_rowWeight="1"
android:textStyle="bold" android:layout_marginTop="20dp"
android:textSize="20sp" android:layout_marginBottom="10dp"
android:textColor="?attr/textColor" android:text="@string/stream"
android:layout_width="match_parent" android:textColor="?attr/textColor"
android:layout_rowWeight="1" android:textSize="20sp"
android:text="@string/stream" android:textStyle="bold" />
android:layout_height="wrap_content" />
<EditText <EditText
android:layout_weight="20" android:id="@+id/stream_url"
android:id="@+id/stream_url" android:layout_width="match_parent"
android:inputType="textUri" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_weight="20"
android:layout_height="wrap_content" android:hint="@string/network_adress_example"
android:hint="@string/network_adress_example" android:inputType="textUri"
tools:ignore="LabelFor" /> tools:ignore="LabelFor" />
<EditText <EditText
android:layout_weight="20" android:id="@+id/stream_referer"
android:id="@+id/stream_referer" android:layout_width="match_parent"
android:inputType="textUri" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_weight="20"
android:layout_height="wrap_content" android:hint="@string/referer"
android:hint="@string/referer" android:inputType="textUri"
tools:ignore="LabelFor" /> tools:ignore="LabelFor" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/hls_switch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/hls_playlist"
android:textColor="?attr/textColor"
android:textSize="16sp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_gravity="bottom" android:layout_height="60dp"
android:gravity="bottom|end" android:layout_gravity="bottom"
android:layout_width="match_parent" android:gravity="bottom|end"
android:layout_height="60dp"> android:orientation="horizontal">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/WhiteButton" android:id="@+id/apply_btt"
android:layout_gravity="center_vertical|end" style="@style/WhiteButton"
android:visibility="visible" android:layout_width="wrap_content"
android:text="@string/home_play" android:layout_gravity="center_vertical|end"
android:id="@+id/apply_btt" android:text="@string/home_play"
android:layout_width="wrap_content"> android:visibility="visible">
<requestFocus /> <requestFocus />
</com.google.android.material.button.MaterialButton> </com.google.android.material.button.MaterialButton>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/BlackButton" android:id="@+id/cancel_btt"
android:layout_gravity="center_vertical|end" style="@style/BlackButton"
android:text="@string/sort_cancel" android:layout_width="wrap_content"
android:id="@+id/cancel_btt" android:layout_gravity="center_vertical|end"
android:layout_width="wrap_content" /> android:text="@string/sort_cancel" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -623,4 +623,6 @@
<string name="extension_size">Size</string> <string name="extension_size">Size</string>
<string name="extension_authors">Authors</string> <string name="extension_authors">Authors</string>
<string name="extension_types">Supported</string> <string name="extension_types">Supported</string>
<string name="hls_playlist">HLS Playlist</string>
</resources> </resources>