mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-22 09:04:32 +01:00
Code Cleanup
This commit is contained in:
parent
bd690a547a
commit
33fef3dbd6
@ -28,6 +28,7 @@ import com.shabinder.common.models.TrackDetails
|
|||||||
import com.shabinder.common.models.dispatcherIO
|
import com.shabinder.common.models.dispatcherIO
|
||||||
import com.shabinder.common.models.event.coroutines.SuspendableEvent
|
import com.shabinder.common.models.event.coroutines.SuspendableEvent
|
||||||
import com.shabinder.common.models.event.coroutines.flatMapError
|
import com.shabinder.common.models.event.coroutines.flatMapError
|
||||||
|
import com.shabinder.common.models.event.coroutines.onFailure
|
||||||
import com.shabinder.common.models.event.coroutines.onSuccess
|
import com.shabinder.common.models.event.coroutines.onSuccess
|
||||||
import com.shabinder.common.models.event.coroutines.success
|
import com.shabinder.common.models.event.coroutines.success
|
||||||
import com.shabinder.common.models.spotify.Source
|
import com.shabinder.common.models.spotify.Source
|
||||||
@ -134,16 +135,14 @@ class FetchPlatformQueryResult(
|
|||||||
)
|
)
|
||||||
|
|
||||||
appendLine("Trying Local Extraction")
|
appendLine("Trying Local Extraction")
|
||||||
runCatching {
|
SuspendableEvent {
|
||||||
youtubeProvider.fetchVideoM4aLink(
|
youtubeProvider.fetchVideoM4aLink(track.videoID.requireNotNull())
|
||||||
track.videoID.requireNotNull()
|
}.onFailure { throwable ->
|
||||||
).also {
|
appendPadded("YT Manual Extraction Failed!", throwable.stackTraceToString())
|
||||||
|
}.onSuccess {
|
||||||
audioQuality = it.second
|
audioQuality = it.second
|
||||||
audioFormat = AudioFormat.MP4
|
audioFormat = AudioFormat.MP4
|
||||||
}.first
|
}.component1()?.first
|
||||||
}.onFailure {
|
|
||||||
appendPadded(it.stackTraceToString())
|
|
||||||
}.getOrNull()
|
|
||||||
} else {
|
} else {
|
||||||
audioFormat = AudioFormat.MP3
|
audioFormat = AudioFormat.MP3
|
||||||
ytMp3LinkRes.component1()
|
ytMp3LinkRes.component1()
|
||||||
@ -185,14 +184,23 @@ class FetchPlatformQueryResult(
|
|||||||
).onSuccess { audioFormat = AudioFormat.MP4 }.flatMapError { saavnError ->
|
).onSuccess { audioFormat = AudioFormat.MP4 }.flatMapError { saavnError ->
|
||||||
appendPadded("Fetching From Saavn Failed:", saavnError.stackTraceToString())
|
appendPadded("Fetching From Saavn Failed:", saavnError.stackTraceToString())
|
||||||
// Saavn Failed, Lets Try Fetching Now From Youtube Music
|
// Saavn Failed, Lets Try Fetching Now From Youtube Music
|
||||||
youtubeMusic.findMp3SongDownloadURLYT(track, preferredQuality).also {
|
youtubeMusic.findMp3SongDownloadURLYT(track, preferredQuality).onSuccess {
|
||||||
|
audioFormat = AudioFormat.MP3
|
||||||
|
}.flatMapError {
|
||||||
// Append Error To StackTrace
|
// Append Error To StackTrace
|
||||||
if (it is SuspendableEvent.Failure)
|
|
||||||
appendPadded(
|
appendPadded(
|
||||||
"Fetching From YT-Music Failed:",
|
"Fetching From Yt1s Failed:",
|
||||||
it.component2()?.stackTraceToString()
|
it.stackTraceToString()
|
||||||
)
|
)
|
||||||
else audioFormat = AudioFormat.MP3
|
appendPadded("Extracting Manually...")
|
||||||
|
|
||||||
|
SuspendableEvent {
|
||||||
|
youtubeProvider.fetchVideoM4aLink(track.videoID.requireNotNull())
|
||||||
|
}.onFailure { throwable ->
|
||||||
|
appendPadded("YT Manual Extraction Failed!", throwable.stackTraceToString())
|
||||||
|
}.onSuccess {
|
||||||
|
audioFormat = AudioFormat.MP4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user