From 6f3e9891c5bdaccfddd83efb19c0e929ce9d146f Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Mon, 5 Sep 2022 14:21:42 +0200 Subject: [PATCH 1/2] Disable exoplayer tunneling --- .../java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt index 677042d0..b25279b9 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt @@ -553,8 +553,8 @@ class CS3IPlayer : IPlayer { trackSelector.parameters = DefaultTrackSelector.ParametersBuilder(context) // .setRendererDisabled(C.TRACK_TYPE_VIDEO, true) .setRendererDisabled(C.TRACK_TYPE_TEXT, true) - // Experimental - .setTunnelingEnabled(true) + // Experimental, I think this causes issues with audio track init 5001 +// .setTunnelingEnabled(true) .setDisabledTextTrackSelectionFlags(C.TRACK_TYPE_TEXT) // This will not force higher quality videos to fail // but will make the m3u8 pick the correct preferred From afb35f73b389b8fa925838d5059b35e9ac9a681f Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Mon, 5 Sep 2022 20:45:56 +0200 Subject: [PATCH 2/2] Add isM3u8 to raw stream button --- .../ui/download/DownloadFragment.kt | 27 ++++- .../cloudstream3/ui/player/LinkGenerator.kt | 7 +- app/src/main/res/layout/stream_input.xml | 108 ++++++++++-------- app/src/main/res/values/strings.xml | 1 + 4 files changed, 90 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt index 3335e023..b2286c99 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt @@ -38,6 +38,9 @@ import com.lagradost.cloudstream3.utils.VideoDownloadManager import kotlinx.android.synthetic.main.fragment_downloads.* import kotlinx.android.synthetic.main.stream_input.* 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" @@ -183,10 +186,29 @@ class DownloadFragment : Fragment() { 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( 0 )?.text?.toString()?.let { copy -> - dialog.stream_url?.setText(copy) + val fixedText = copy.trim() + dialog.stream_url?.setText(fixedText) + activateSwitchOnHls(fixedText) } dialog.apply_btt?.setOnClickListener { @@ -202,7 +224,8 @@ class DownloadFragment : Fragment() { LinkGenerator( listOf(url), extract = true, - referer = referer + referer = referer, + isM3u8 = dialog.hls_switch?.isChecked ) ) ) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/LinkGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/LinkGenerator.kt index f56fcb51..2c8a5372 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/LinkGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/LinkGenerator.kt @@ -1,12 +1,15 @@ package com.lagradost.cloudstream3.ui.player import com.lagradost.cloudstream3.apmap +import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.utils.* +import java.net.URI class LinkGenerator( private val links: List, private val extract: Boolean = true, private val referer: String? = null, + private val isM3u8: Boolean? = null ) : IGenerator { override val hasCache = false @@ -57,7 +60,9 @@ class LinkGenerator( link, unshortenLinkSafe(link), // unshorten because it might be a raw link 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 ) } diff --git a/app/src/main/res/layout/stream_input.xml b/app/src/main/res/layout/stream_input.xml index ef6a35b8..20a91b4a 100644 --- a/app/src/main/res/layout/stream_input.xml +++ b/app/src/main/res/layout/stream_input.xml @@ -1,73 +1,81 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingStart="?android:attr/listPreferredItemPaddingStart" + android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"> + android:id="@+id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_rowWeight="1" + android:layout_marginTop="20dp" + android:layout_marginBottom="10dp" + android:text="@string/stream" + android:textColor="?attr/textColor" + android:textSize="20sp" + android:textStyle="bold" /> + android:id="@+id/stream_url" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="20" + android:hint="@string/network_adress_example" + android:inputType="textUri" + tools:ignore="LabelFor" /> + android:id="@+id/stream_referer" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="20" + android:hint="@string/referer" + android:inputType="textUri" + tools:ignore="LabelFor" /> + + + android:layout_width="match_parent" + android:layout_height="60dp" + android:layout_gravity="bottom" + android:gravity="bottom|end" + android:orientation="horizontal"> + android:id="@+id/apply_btt" + style="@style/WhiteButton" + android:layout_width="wrap_content" + android:layout_gravity="center_vertical|end" + android:text="@string/home_play" + android:visibility="visible"> + android:id="@+id/cancel_btt" + style="@style/BlackButton" + android:layout_width="wrap_content" + android:layout_gravity="center_vertical|end" + android:text="@string/sort_cancel" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 11c90d58..06212052 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -615,4 +615,5 @@ Safe Mode enabled An unrecoverable crash occurred and we\'ve automatically disabled all extensions, so you can find and remove the extension which is causing trouble. View crash info + HLS Playlist