Skip to content
Closed
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 @@ -1616,7 +1616,12 @@ class GeneratorPlayer : FullScreenPlayer() {

val links = viewModel.state.sortLinks(currentQualityProfile)

val firstAvailableLink = links.firstOrNull { it.shouldUseLink }?.link
// Auto-play regex: read user pattern (comma-separated → OR). If it matches a source name, play that; otherwise fall back to first available.
val autoPlayRegex = CloudStreamApp.getKey<String>("player_auto_play_regex")
val pattern = autoPlayRegex?.trim()?.takeIf { it.isNotEmpty() }
?.split(",")?.map { it.trim() }?.filter { it.isNotEmpty() }?.joinToString("|")
val regex = pattern?.let { runCatching { Regex(it, RegexOption.IGNORE_CASE) }.getOrNull() }
val firstAvailableLink = (regex?.let { r -> links.firstOrNull { it.shouldUseLink && r.containsMatchIn(it.link?.first?.name ?: "") } } ?: links.firstOrNull { it.shouldUseLink })?.link
if (firstAvailableLink == null) {
noLinksFound()
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.lagradost.cloudstream3.ui.settings

import androidx.appcompat.app.AlertDialog
import android.text.format.Formatter.formatShortFileSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -14,6 +15,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.CloudStreamApp
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.actions.VideoClickActionHolder
import com.lagradost.cloudstream3.ui.player.source_priority.QualityProfileDialog
Expand Down Expand Up @@ -108,6 +110,25 @@ object SettingsPlayerScreen : SearchableSettings {
}
}),

Preference.PreferenceItem.TextPreference(
title = "Auto-play source regex",
subtitle = "Auto-pick first source matching (e.g. hindi,hin,tamil,webdl,4k). Empty = normal.",
icon = painterResource(R.drawable.play_arrow_24px),
onClick = {
val ctx = context
val input = android.widget.EditText(ctx).apply {
setText(CloudStreamApp.getKey<String>("player_auto_play_regex") ?: "")
isSingleLine = true
}
AlertDialog.Builder(ctx, R.style.AlertDialogCustom).setTitle("Auto-play source regex")
.setView(input)
.setPositiveButton("Save") { _, _ ->
CloudStreamApp.setKey("player_auto_play_regex", input.text.toString().trim())
}
.setNegativeButton("Cancel", null)
.show()
}),

Preference.PreferenceItem.SwitchPreference(
preference = settings.player.pipEnabled,
title = stringResource(R.string.picture_in_picture),
Expand Down