Skip to content

Commit

Permalink
Fix: Ensure Lyrics Are Embedded During Batch Download When Selected
Browse files Browse the repository at this point in the history
  • Loading branch information
kerollosy committed Nov 30, 2024
1 parent 2a15573 commit 06b96d0
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions app/src/main/java/pl/lambada/songsync/util/LyricsUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,44 @@ private suspend fun downloadLyricsForSong(
}
.onFailure(onFailedLyricsResponse)
.onSuccess {
formatAndSaveLyricsForSong(
song,
context,
viewModel.userSettingsController.sdCardPath,
val lrcContent = formatLyrics(
songInfo,
it,
context,
viewModel.userSettingsController.directlyModifyTimestamps
)

if(viewModel.userSettingsController.embedLyricsIntoFiles) {
embedLyricsInFile(
context,
song.filePath ?: throw NullPointerException("File path is null"),
lrcContent
)
} else {
writeLyricsToFile(song.filePath.toLrcFile(), lrcContent, context, song,viewModel.userSettingsController.sdCardPath)
}

onLyricsSaved()
}
}
}

private fun formatLyrics(
songInfo: SongInfo,
lyrics: String,
context: Context,
directOffset: Boolean
): String {
val lrcContent = generateLrcContent(
songInfo,
lyrics,
context.getString(R.string.generated_using),
directOffset = directOffset
)

return lrcContent
}

private fun formatAndSaveLyricsForSong(
song: Song,
context: Context,
Expand Down

0 comments on commit 06b96d0

Please sign in to comment.