Skip to content

Commit

Permalink
feat: option to disable similar content, closes #373
Browse files Browse the repository at this point in the history
  • Loading branch information
Malopieds committed Nov 2, 2024
1 parent 386deb4 commit 3d528ae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ val HideExplicitKey = booleanPreferencesKey("hideExplicit")
val ProxyEnabledKey = booleanPreferencesKey("proxyEnabled")
val ProxyUrlKey = stringPreferencesKey("proxyUrl")
val ProxyTypeKey = stringPreferencesKey("proxyType")
val SimilarContent = booleanPreferencesKey("similarContent")

val AudioQualityKey = stringPreferencesKey("audioQuality")

Expand Down
29 changes: 16 additions & 13 deletions app/src/main/java/com/malopieds/innertune/playback/MusicService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import com.malopieds.innertune.constants.PersistentQueueKey
import com.malopieds.innertune.constants.PlayerVolumeKey
import com.malopieds.innertune.constants.RepeatModeKey
import com.malopieds.innertune.constants.ShowLyricsKey
import com.malopieds.innertune.constants.SimilarContent
import com.malopieds.innertune.constants.SkipSilenceKey
import com.malopieds.innertune.db.MusicDatabase
import com.malopieds.innertune.db.entities.Event
Expand Down Expand Up @@ -532,19 +533,21 @@ class MusicService :
}

fun getAutomix(playlistId: String) {
scope.launch(SilentHandler) {
YouTube
.next(WatchEndpoint(playlistId = playlistId))
.onSuccess {
YouTube
.next(WatchEndpoint(playlistId = it.endpoint.playlistId))
.onSuccess {
automixItems.value =
it.items.map { song ->
song.toMediaItem()
}
}
}
if (dataStore[SimilarContent] == true) {
scope.launch(SilentHandler) {
YouTube
.next(WatchEndpoint(playlistId = playlistId))
.onSuccess {
YouTube
.next(WatchEndpoint(playlistId = it.endpoint.playlistId))
.onSuccess {
automixItems.value =
it.items.map { song ->
song.toMediaItem()
}
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import com.malopieds.innertune.constants.ProxyUrlKey
import com.malopieds.innertune.constants.QuickPicks
import com.malopieds.innertune.constants.QuickPicksKey
import com.malopieds.innertune.constants.SYSTEM_DEFAULT
import com.malopieds.innertune.constants.SimilarContent
import com.malopieds.innertune.constants.TopSize
import com.malopieds.innertune.ui.component.EditTextPreference
import com.malopieds.innertune.ui.component.IconButton
Expand Down Expand Up @@ -86,6 +87,7 @@ fun ContentSettings(
val (historyDuration, onHistoryDurationChange) = rememberPreference(key = HistoryDuration, defaultValue = 30f)
val (defaultChip, onDefaultChipChange) = rememberEnumPreference(key = ChipSortTypeKey, defaultValue = LibraryFilter.LIBRARY)
val (quickPicks, onQuickPicksChange) = rememberEnumPreference(key = QuickPicksKey, defaultValue = QuickPicks.QUICK_PICKS)
val (similarContentEnabled, similarContentEnabledChange) = rememberPreference(key = SimilarContent, defaultValue = true)

Column(
Modifier
Expand Down Expand Up @@ -252,6 +254,12 @@ fun ContentSettings(
value = historyDuration,
onValueChange = onHistoryDurationChange,
)

SwitchPreference(
title = { Text(stringResource(R.string.enable_similar_content)) },
checked = similarContentEnabled,
onCheckedChange = similarContentEnabledChange,
)
}

TopAppBar(
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
<string name="open_supported_links">Open supported link by default</string>
<string name="configure_supported_links">Configure supported links</string>
<string name="intent_supported_links_not_found">Couldn\'t find supported links settings, please configure them manually</string>
<string name="enable_similar_content">Enable Similar Content</string>

<string name="player_and_audio">Player and audio</string>
<string name="audio_quality">Audio quality</string>
Expand Down

0 comments on commit 3d528ae

Please sign in to comment.