Skip to content

Commit

Permalink
Apple can try again now
Browse files Browse the repository at this point in the history
  • Loading branch information
Lambada10 committed Nov 1, 2024
1 parent 2d7784b commit 5269e12
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class LyricsProviderService {
neteaseID = it?.neteaseID ?: 0
} ?: throw NoTrackFoundException()

Providers.APPLE -> AppleAPI().getSongInfo(query).also {
Providers.APPLE -> AppleAPI().getSongInfo(query, offset).also {
appleID = it?.appleID ?: 0
} ?: throw NoTrackFoundException()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import java.net.URLEncoder
class AppleAPI {
private val baseURL = "https://paxsenix.alwaysdata.net/"

suspend fun getSongInfo(query: SongInfo): SongInfo? {
suspend fun getSongInfo(query: SongInfo, offset: Int = 0): SongInfo? {
val search = withContext(Dispatchers.IO) {
URLEncoder.encode(
"${query.songName} ${query.artistName}",
Expand All @@ -41,7 +41,11 @@ class AppleAPI {
return null
}

val result = json[0]
val result = try {
json[offset]
} catch (e: IndexOutOfBoundsException) {
return null
}

return SongInfo(
songName = result.songName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ fun SharedTransitionScope.LyricsFetchScreen(
animatedVisibilityScope = animatedVisibilityScope,
disableMarquee = viewModel.userSettingsController.disableMarquee,
allowTryingAgain =
viewModel.userSettingsController.selectedProvider != Providers.APPLE &&
viewModel.userSettingsController.selectedProvider != Providers.MUSIXMATCH
)

Expand Down

0 comments on commit 5269e12

Please sign in to comment.