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
ee8ab4a6c5
commit
cf6fec172e
@ -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())
|
||||||
audioQuality = it.second
|
}.onSuccess {
|
||||||
audioFormat = AudioFormat.MP4
|
audioQuality = it.second
|
||||||
}.first
|
audioFormat = AudioFormat.MP4
|
||||||
}.onFailure {
|
}.component1()?.first
|
||||||
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 Yt1s Failed:",
|
||||||
"Fetching From YT-Music Failed:",
|
it.stackTraceToString()
|
||||||
it.component2()?.stackTraceToString()
|
)
|
||||||
)
|
appendPadded("Extracting Manually...")
|
||||||
else audioFormat = AudioFormat.MP3
|
|
||||||
|
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