Skip to content

Commit

Permalink
fix half of providers not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Lambada10 committed Sep 25, 2024
1 parent 775a5c3 commit ae4f5c1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ class LyricsProviderService {
* @return The synced lyrics as a string.
*/
suspend fun getSyncedLyrics(
songLink: String,
songLink: String?,
version: String,
provider: Providers,
// TODO providers could be a sealed interface to include such parameters
includeTranslationNetEase: Boolean = false
): String? {
return try {
when (provider) {
Providers.SPOTIFY -> SpotifyLyricsAPI().getSyncedLyrics(songLink, version)
Providers.SPOTIFY -> SpotifyLyricsAPI().getSyncedLyrics(songLink!!, version)
Providers.LRCLIB -> LRCLibAPI().getSyncedLyrics(lrcLibID)
Providers.NETEASE -> NeteaseAPI().getSyncedLyrics(
neteaseID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class HomeViewModel(
suspend fun getSongInfo(query: SongInfo): SongInfo? =
lyricsProviderService.getSongInfo(query, provider = userSettingsController.selectedProvider)

suspend fun getSyncedLyrics(link: String, version: String): String? =
suspend fun getSyncedLyrics(link: String?, version: String): String? =
lyricsProviderService.getSyncedLyrics(link, version, provider = userSettingsController.selectedProvider)

fun selectSong(song: Song, newValue: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LyricsFetchViewModel(

var lyricsFetchState by mutableStateOf<LyricsFetchState>(LyricsFetchState.NotSubmitted)

private suspend fun getSyncedLyrics(link: String, version: String): String? =
private suspend fun getSyncedLyrics(link: String?, version: String): String? =
lyricsProviderService.getSyncedLyrics(
link,
version,
Expand Down Expand Up @@ -106,7 +106,7 @@ class LyricsFetchViewModel(

try {
val lyrics = getSyncedLyrics(
link = songLink ?: throw IllegalStateException("Attempted lyrics retrieval with empty URL"),
link = songLink,
version = context.getVersion()
) ?: throw NullPointerException("Lyrics result is null")

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/pl/lambada/songsync/util/LyricsUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private suspend fun downloadLyricsForSong(
runCatching {
viewModel
.getSyncedLyrics(
link = songInfo.songLink ?: error("attempted to get lyrics without link"),
link = songInfo.songLink,
version = context.getVersion()
)
?: throw NullPointerException("Lyrics result is null")
Expand Down

0 comments on commit ae4f5c1

Please sign in to comment.