mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-16 23:12:12 +00:00
fixes for introdb submit
This commit is contained in:
parent
cf22743148
commit
000f081d28
5 changed files with 72 additions and 29 deletions
|
|
@ -168,6 +168,7 @@ internal fun PlayerControlsShell(
|
||||||
onAudioClick = onAudioClick,
|
onAudioClick = onAudioClick,
|
||||||
onSourcesClick = onSourcesClick,
|
onSourcesClick = onSourcesClick,
|
||||||
onEpisodesClick = onEpisodesClick,
|
onEpisodesClick = onEpisodesClick,
|
||||||
|
onSubmitIntroClick = onSubmitIntroClick,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,9 @@ fun PlayerScreen(
|
||||||
var showSourcesPanel by remember { mutableStateOf(false) }
|
var showSourcesPanel by remember { mutableStateOf(false) }
|
||||||
var showEpisodesPanel by remember { mutableStateOf(false) }
|
var showEpisodesPanel by remember { mutableStateOf(false) }
|
||||||
var showSubmitIntroModal by remember { mutableStateOf(false) }
|
var showSubmitIntroModal by remember { mutableStateOf(false) }
|
||||||
|
var submitIntroSegmentType by rememberSaveable { mutableStateOf("intro") }
|
||||||
|
var submitIntroStartTimeStr by rememberSaveable { mutableStateOf("00:00") }
|
||||||
|
var submitIntroEndTimeStr by rememberSaveable { mutableStateOf("00:00") }
|
||||||
var episodeStreamsPanelState by remember { mutableStateOf(EpisodeStreamsPanelState()) }
|
var episodeStreamsPanelState by remember { mutableStateOf(EpisodeStreamsPanelState()) }
|
||||||
val sourceStreamsState by PlayerStreamsRepository.sourceState.collectAsStateWithLifecycle()
|
val sourceStreamsState by PlayerStreamsRepository.sourceState.collectAsStateWithLifecycle()
|
||||||
val episodeStreamsRepoState by PlayerStreamsRepository.episodeStreamsState.collectAsStateWithLifecycle()
|
val episodeStreamsRepoState by PlayerStreamsRepository.episodeStreamsState.collectAsStateWithLifecycle()
|
||||||
|
|
@ -1598,9 +1601,9 @@ fun PlayerScreen(
|
||||||
refreshTracks()
|
refreshTracks()
|
||||||
showAudioModal = true
|
showAudioModal = true
|
||||||
},
|
},
|
||||||
onSourcesClick = if (activeVideoId != null) {{ openSourcesPanel() }} else null,
|
onSourcesClick = if (activeVideoId != null) { { openSourcesPanel() } } else null,
|
||||||
onEpisodesClick = if (isSeries) {{ openEpisodesPanel() }} else null,
|
onEpisodesClick = if (isSeries) { { openEpisodesPanel() } } else null,
|
||||||
onSubmitIntroClick = if (isSeries && playerSettingsUiState.introSubmitEnabled && playerSettingsUiState.introDbApiKey.isNotBlank()) {{ showSubmitIntroModal = true }} else null,
|
onSubmitIntroClick = if (isSeries && playerSettingsUiState.introSubmitEnabled && playerSettingsUiState.introDbApiKey.isNotBlank()) { { showSubmitIntroModal = true } } else null,
|
||||||
onScrubChange = { positionMs -> scrubbingPositionMs = positionMs },
|
onScrubChange = { positionMs -> scrubbingPositionMs = positionMs },
|
||||||
onScrubFinished = { positionMs ->
|
onScrubFinished = { positionMs ->
|
||||||
scrubbingPositionMs = null
|
scrubbingPositionMs = null
|
||||||
|
|
@ -1859,7 +1862,19 @@ fun PlayerScreen(
|
||||||
season = season,
|
season = season,
|
||||||
episode = episode,
|
episode = episode,
|
||||||
currentTimeSec = (displayedPositionMs / 1000.0),
|
currentTimeSec = (displayedPositionMs / 1000.0),
|
||||||
|
segmentType = submitIntroSegmentType,
|
||||||
|
onSegmentTypeChange = { submitIntroSegmentType = it },
|
||||||
|
startTimeStr = submitIntroStartTimeStr,
|
||||||
|
onStartTimeChange = { submitIntroStartTimeStr = it },
|
||||||
|
endTimeStr = submitIntroEndTimeStr,
|
||||||
|
onEndTimeChange = { submitIntroEndTimeStr = it },
|
||||||
onDismiss = { showSubmitIntroModal = false },
|
onDismiss = { showSubmitIntroModal = false },
|
||||||
|
onSuccess = {
|
||||||
|
submitIntroStartTimeStr = "00:00"
|
||||||
|
submitIntroEndTimeStr = "00:00"
|
||||||
|
submitIntroSegmentType = "intro"
|
||||||
|
showSubmitIntroModal = false
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ object PlayerSettingsRepository {
|
||||||
private var skipIntroEnabled = true
|
private var skipIntroEnabled = true
|
||||||
private var animeSkipEnabled = false
|
private var animeSkipEnabled = false
|
||||||
private var animeSkipClientId = ""
|
private var animeSkipClientId = ""
|
||||||
|
private var introDbApiKey = ""
|
||||||
|
private var introSubmitEnabled = false
|
||||||
private var streamAutoPlayNextEpisodeEnabled = false
|
private var streamAutoPlayNextEpisodeEnabled = false
|
||||||
private var streamAutoPlayPreferBingeGroup = true
|
private var streamAutoPlayPreferBingeGroup = true
|
||||||
private var nextEpisodeThresholdMode = NextEpisodeThresholdMode.PERCENTAGE
|
private var nextEpisodeThresholdMode = NextEpisodeThresholdMode.PERCENTAGE
|
||||||
|
|
@ -113,6 +115,8 @@ object PlayerSettingsRepository {
|
||||||
skipIntroEnabled = true
|
skipIntroEnabled = true
|
||||||
animeSkipEnabled = false
|
animeSkipEnabled = false
|
||||||
animeSkipClientId = ""
|
animeSkipClientId = ""
|
||||||
|
introDbApiKey = ""
|
||||||
|
introSubmitEnabled = false
|
||||||
streamAutoPlayNextEpisodeEnabled = false
|
streamAutoPlayNextEpisodeEnabled = false
|
||||||
streamAutoPlayPreferBingeGroup = true
|
streamAutoPlayPreferBingeGroup = true
|
||||||
nextEpisodeThresholdMode = NextEpisodeThresholdMode.PERCENTAGE
|
nextEpisodeThresholdMode = NextEpisodeThresholdMode.PERCENTAGE
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,11 @@ import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.BasicTextField
|
import androidx.compose.foundation.text.BasicTextField
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.rounded.Close
|
import androidx.compose.material.icons.rounded.Close
|
||||||
import androidx.compose.material.icons.rounded.GpsFixed
|
import androidx.compose.material.icons.rounded.GpsFixed
|
||||||
|
|
@ -48,7 +50,6 @@ import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -57,23 +58,30 @@ fun SubmitIntroDialog(
|
||||||
season: Int,
|
season: Int,
|
||||||
episode: Int,
|
episode: Int,
|
||||||
currentTimeSec: Double,
|
currentTimeSec: Double,
|
||||||
|
segmentType: String,
|
||||||
|
onSegmentTypeChange: (String) -> Unit,
|
||||||
|
startTimeStr: String,
|
||||||
|
onStartTimeChange: (String) -> Unit,
|
||||||
|
endTimeStr: String,
|
||||||
|
onEndTimeChange: (String) -> Unit,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
|
onSuccess: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
val scrollState = rememberScrollState()
|
||||||
var isSubmitting by remember { mutableStateOf(false) }
|
var isSubmitting by remember { mutableStateOf(false) }
|
||||||
var segmentType by remember { mutableStateOf("intro") }
|
|
||||||
var startTimeStr by remember { mutableStateOf("00:00") }
|
|
||||||
var endTimeStr by remember { mutableStateOf(formatSecondsToMMSS(currentTimeSec)) }
|
|
||||||
|
|
||||||
BasicAlertDialog(onDismissRequest = onDismiss) {
|
BasicAlertDialog(onDismissRequest = onDismiss) {
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
modifier = Modifier.padding(horizontal = 16.dp, vertical = 24.dp),
|
||||||
shape = RoundedCornerShape(24.dp),
|
shape = RoundedCornerShape(24.dp),
|
||||||
color = MaterialTheme.colorScheme.surface,
|
color = MaterialTheme.colorScheme.surface,
|
||||||
tonalElevation = 8.dp,
|
tonalElevation = 8.dp,
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(24.dp),
|
modifier = Modifier
|
||||||
|
.padding(24.dp)
|
||||||
|
.verticalScroll(scrollState),
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
) {
|
) {
|
||||||
// Header
|
// Header
|
||||||
|
|
@ -88,7 +96,7 @@ fun SubmitIntroDialog(
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
)
|
)
|
||||||
IconButton(onClick = onDismiss, modifier = Modifier.size(24.dp)) {
|
IconButton(onClick = onDismiss) {
|
||||||
Icon(Icons.Rounded.Close, contentDescription = "Close", tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
Icon(Icons.Rounded.Close, contentDescription = "Close", tint = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -109,21 +117,21 @@ fun SubmitIntroDialog(
|
||||||
label = "Intro",
|
label = "Intro",
|
||||||
icon = Icons.Rounded.PlayCircleOutline,
|
icon = Icons.Rounded.PlayCircleOutline,
|
||||||
selected = segmentType == "intro",
|
selected = segmentType == "intro",
|
||||||
onClick = { segmentType = "intro" },
|
onClick = { onSegmentTypeChange("intro") },
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
SegmentTypeButton(
|
SegmentTypeButton(
|
||||||
label = "Recap",
|
label = "Recap",
|
||||||
icon = Icons.Rounded.Replay,
|
icon = Icons.Rounded.Replay,
|
||||||
selected = segmentType == "recap",
|
selected = segmentType == "recap",
|
||||||
onClick = { segmentType = "recap" },
|
onClick = { onSegmentTypeChange("recap") },
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
SegmentTypeButton(
|
SegmentTypeButton(
|
||||||
label = "Outro",
|
label = "Outro",
|
||||||
icon = Icons.Rounded.StopCircle,
|
icon = Icons.Rounded.StopCircle,
|
||||||
selected = segmentType == "outro",
|
selected = segmentType == "outro",
|
||||||
onClick = { segmentType = "outro" },
|
onClick = { onSegmentTypeChange("outro") },
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -133,16 +141,16 @@ fun SubmitIntroDialog(
|
||||||
TimeInputRow(
|
TimeInputRow(
|
||||||
label = "START TIME (MM:SS)",
|
label = "START TIME (MM:SS)",
|
||||||
value = startTimeStr,
|
value = startTimeStr,
|
||||||
onValueChange = { startTimeStr = it },
|
onValueChange = onStartTimeChange,
|
||||||
onCapture = { startTimeStr = formatSecondsToMMSS(currentTimeSec) }
|
onCapture = { onStartTimeChange(formatSecondsToMMSS(currentTimeSec)) }
|
||||||
)
|
)
|
||||||
|
|
||||||
// End Time
|
// End Time
|
||||||
TimeInputRow(
|
TimeInputRow(
|
||||||
label = "END TIME (MM:SS)",
|
label = "END TIME (MM:SS)",
|
||||||
value = endTimeStr,
|
value = endTimeStr,
|
||||||
onValueChange = { endTimeStr = it },
|
onValueChange = onEndTimeChange,
|
||||||
onCapture = { endTimeStr = formatSecondsToMMSS(currentTimeSec) }
|
onCapture = { onEndTimeChange(formatSecondsToMMSS(currentTimeSec)) }
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
@ -179,7 +187,7 @@ fun SubmitIntroDialog(
|
||||||
if (start != null && end != null && end > start) {
|
if (start != null && end != null && end > start) {
|
||||||
isSubmitting = true
|
isSubmitting = true
|
||||||
scope.launch {
|
scope.launch {
|
||||||
SkipIntroRepository.submitIntro(
|
val result = SkipIntroRepository.submitIntro(
|
||||||
imdbId = imdbId,
|
imdbId = imdbId,
|
||||||
season = season,
|
season = season,
|
||||||
episode = episode,
|
episode = episode,
|
||||||
|
|
@ -188,7 +196,9 @@ fun SubmitIntroDialog(
|
||||||
segmentType = segmentType,
|
segmentType = segmentType,
|
||||||
)
|
)
|
||||||
isSubmitting = false
|
isSubmitting = false
|
||||||
onDismiss()
|
if (result) {
|
||||||
|
onSuccess()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -292,7 +302,7 @@ private fun TimeInputRow(
|
||||||
textStyle = MaterialTheme.typography.bodyLarge.copy(
|
textStyle = MaterialTheme.typography.bodyLarge.copy(
|
||||||
color = MaterialTheme.colorScheme.onSurface,
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal),
|
||||||
cursorBrush = SolidColor(MaterialTheme.colorScheme.primary),
|
cursorBrush = SolidColor(MaterialTheme.colorScheme.primary),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
)
|
)
|
||||||
|
|
@ -336,13 +346,26 @@ private fun formatSecondsToMMSS(seconds: Double): String {
|
||||||
|
|
||||||
private fun parseTimeToSeconds(input: String): Double? {
|
private fun parseTimeToSeconds(input: String): Double? {
|
||||||
if (input.isBlank()) return null
|
if (input.isBlank()) return null
|
||||||
if (input.contains(':')) {
|
|
||||||
val parts = input.split(':')
|
// Check for separator (colon or dot)
|
||||||
if (parts.size != 2) return null
|
val separator = when {
|
||||||
|
input.contains(':') -> ":"
|
||||||
|
input.contains('.') -> "."
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (separator != null) {
|
||||||
|
val parts = input.split(separator)
|
||||||
|
if (parts.size == 2) {
|
||||||
val mins = parts[0].toIntOrNull() ?: return null
|
val mins = parts[0].toIntOrNull() ?: return null
|
||||||
val secs = parts[1].toIntOrNull() ?: return null
|
val secs = parts[1].toIntOrNull() ?: return null
|
||||||
if (secs < 0 || secs >= 60) return null
|
// If the user uses a dot, we assume they mean MM.SS (e.g. 1.24 = 1m 24s)
|
||||||
|
// But we only treat it as minutes if seconds are 0-59.
|
||||||
|
if (secs in 0..59) {
|
||||||
return (mins * 60 + secs).toDouble()
|
return (mins * 60 + secs).toDouble()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return input.toDoubleOrNull()
|
return input.toDoubleOrNull()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.rounded.Check
|
import androidx.compose.material.icons.rounded.Check
|
||||||
import androidx.compose.material3.BasicAlertDialog
|
import androidx.compose.material3.BasicAlertDialog
|
||||||
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
|
@ -2161,5 +2162,4 @@ private fun libassRenderTypeRes(renderType: String): StringResource = when (rend
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun libassRenderTypeLabel(renderType: String): String = stringResource(libassRenderTypeRes(renderType))
|
private fun libassRenderTypeLabel(renderType: String): String = stringResource(libassRenderTypeRes(renderType))
|
||||||
): String = stringResource(libassRenderTypeRes(renderType))
|
|
||||||
pe))
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue