From 9554a8fdcb6fa0f15b506fdb538c433e7c599535 Mon Sep 17 00:00:00 2001 From: Shabinder Singh Date: Wed, 13 Oct 2021 01:00:03 +0530 Subject: [PATCH] SoundCloud Fixes --- .../src/main/java/com/shabinder/spotiflyer/MainActivity.kt | 1 + .../resolvemodel/SoundCloudResolveResponseBase.kt | 3 ++- .../kotlin/com/shabinder/common/di/ApplicationInit.kt | 2 -- .../FetchPlatformQueryResult.kt | 2 -- .../sound_cloud/SoundCloudProvider.kt | 6 ++++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/shabinder/spotiflyer/MainActivity.kt b/android/src/main/java/com/shabinder/spotiflyer/MainActivity.kt index 951e4a20..3d63b8a8 100644 --- a/android/src/main/java/com/shabinder/spotiflyer/MainActivity.kt +++ b/android/src/main/java/com/shabinder/spotiflyer/MainActivity.kt @@ -250,6 +250,7 @@ class MainActivity : ComponentActivity() { if (long) android.widget.Toast.LENGTH_LONG else android.widget.Toast.LENGTH_SHORT ).show() } + Log.i("Toasting",string) } @Suppress("DEPRECATION") diff --git a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/soundcloud/resolvemodel/SoundCloudResolveResponseBase.kt b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/soundcloud/resolvemodel/SoundCloudResolveResponseBase.kt index ddc9c128..78593b2d 100644 --- a/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/soundcloud/resolvemodel/SoundCloudResolveResponseBase.kt +++ b/common/data-models/src/commonMain/kotlin/com/shabinder/common/models/soundcloud/resolvemodel/SoundCloudResolveResponseBase.kt @@ -4,6 +4,7 @@ import com.shabinder.common.models.AudioFormat import com.shabinder.common.models.soundcloud.Media import com.shabinder.common.models.soundcloud.PublisherMetadata import com.shabinder.common.models.soundcloud.User +import com.shabinder.common.models.soundcloud.Visuals import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonClassDiscriminator @@ -149,7 +150,7 @@ sealed class SoundCloudResolveResponseBase { val user: User = User(), @SerialName("user_id") val userId: Int = 0, - val visuals: String = "", + val visuals: Visuals? = null, @SerialName("waveform_url") val waveformUrl: String = "" ) : SoundCloudResolveResponseBase() { diff --git a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/ApplicationInit.kt b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/ApplicationInit.kt index cb2ad2a5..a1ff3fed 100644 --- a/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/ApplicationInit.kt +++ b/common/dependency-injection/src/commonMain/kotlin/com/shabinder/common/di/ApplicationInit.kt @@ -1,7 +1,5 @@ package com.shabinder.common.di -import com.shabinder.common.core_components.analytics.AnalyticsEvent -import com.shabinder.common.core_components.analytics.AnalyticsManager import com.shabinder.common.models.dispatcherIO import com.shabinder.common.providers.spotify.SpotifyProvider import kotlinx.coroutines.DelicateCoroutinesApi diff --git a/common/providers/src/commonMain/kotlin/com.shabinder.common.providers/FetchPlatformQueryResult.kt b/common/providers/src/commonMain/kotlin/com.shabinder.common.providers/FetchPlatformQueryResult.kt index ef00442e..5cbc1de8 100644 --- a/common/providers/src/commonMain/kotlin/com.shabinder.common.providers/FetchPlatformQueryResult.kt +++ b/common/providers/src/commonMain/kotlin/com.shabinder.common.providers/FetchPlatformQueryResult.kt @@ -61,8 +61,6 @@ class FetchPlatformQueryResult( private val db: DownloadRecordDatabaseQueries? get() = fileManager.db?.downloadRecordDatabaseQueries - suspend fun authenticateSpotifyClient() = spotifyProvider.authenticateSpotifyClient() - suspend fun query(link: String): SuspendableEvent { val result = when { // SPOTIFY diff --git a/common/providers/src/commonMain/kotlin/com.shabinder.common.providers/sound_cloud/SoundCloudProvider.kt b/common/providers/src/commonMain/kotlin/com.shabinder.common.providers/sound_cloud/SoundCloudProvider.kt index d74087d5..40705670 100644 --- a/common/providers/src/commonMain/kotlin/com.shabinder.common.providers/sound_cloud/SoundCloudProvider.kt +++ b/common/providers/src/commonMain/kotlin/com.shabinder.common.providers/sound_cloud/SoundCloudProvider.kt @@ -46,7 +46,8 @@ class SoundCloudProvider( folderType = "Playlists" subFolder = response.title trackList = response.tracks.toTrackDetailsList(folderType, subFolder) - coverUrl = response.artworkUrl.ifBlank { response.calculatedArtworkUrl } + coverUrl = response.artworkUrl.formatArtworkUrl() + .ifBlank { response.calculatedArtworkUrl.formatArtworkUrl() } title = response.title } } @@ -110,6 +111,7 @@ class SoundCloudProvider( } private fun String.formatArtworkUrl(): String { - return substringBeforeLast("-") + "-t500x500." + substringAfterLast(".") + return if (isBlank()) "" + else substringBeforeLast("-") + "-t500x500." + substringAfterLast(".") } } \ No newline at end of file