Skip to content

Commit

Permalink
Fix PlayerView don't show
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrave-dev committed May 18, 2024
1 parent 95e6fff commit 2d9d344
Show file tree
Hide file tree
Showing 5 changed files with 1,026 additions and 826 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1657,14 +1657,30 @@ class MainRepository
}

suspend fun getLyricsData(
qartist: String,
qtrack: String,
sartist: String,
strack: String,
durationInt: Int? = null,
): Flow<Pair<String, Resource<Lyrics>>> =
flow {
runCatching {
// val q = query.replace(Regex("\\([^)]*?(feat.|ft.|cùng với|con)[^)]*?\\)"), "")
// .replace(" ", " ")
val qartist =
sartist.replace(
Regex("\\((feat\\.|ft.|cùng với|con|mukana|com|avec|合作音乐人: ) "),
" ",
).replace(
Regex("( và | & | и | e | und |, |和| dan)"),
" ",
).replace(" ", " ").replace(Regex("([()])"), "").replace(".", " ")
val qtrack =
strack.replace(
Regex("\\((feat\\.|ft.|cùng với|con|mukana|com|avec|合作音乐人: ) "),
" ",
).replace(
Regex("( và | & | и | e | und |, |和| dan)"),
" ",
).replace(" ", " ").replace(Regex("([()])"), "").replace(".", " ")
val query = "$qtrack $qartist"
val q =
query.replace(
Expand Down Expand Up @@ -1817,12 +1833,12 @@ class MainRepository
)
.onSuccess {
val trackX = it.message.body.track
if (trackX != null) {
if (trackX != null && abs(trackX.track_length - (durationInt ?: 0)) <= 10) {
YouTube.getMusixmatchLyricsByQ(trackX, musixMatchUserToken!!).onSuccess {
if (it != null) {
emit(
Pair(
id,
trackX.track_id.toString(),
Resource.Success<Lyrics>(it.toLyrics()),
),
)
Expand Down Expand Up @@ -2078,6 +2094,7 @@ class MainRepository
dataStoreManager.translationLanguage.first(),
)
.onSuccess { lyrics ->
Log.w("Translate Lyrics", "lyrics: $lyrics")
emit(lyrics)
}
.onFailure {
Expand Down
Loading

0 comments on commit 2d9d344

Please sign in to comment.