Skip to content

Commit 41b63c4

Browse files
committed
Merge branch 'master' into dev
2 parents 3506777 + 52338dc commit 41b63c4

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is the [Kotlin](https://kotlinlang.org/) implementation of the [Spotify Web
1010
If you have a question, you can:
1111

1212
1. Create an [issue](https://github.com/adamint/spotify-web-api-kotlin/issues)
13-
2. Read (but that's hard)
13+
2. Join our [Discord server](https://discord.gg/G6vqP3S)
1414
3. Contact me using **Adam#9261** on [Discord](https://discordapp.com) or by sending me an email
1515

1616
## Contents
@@ -306,4 +306,4 @@ links provided for each API below
306306
11. `removeAllClientPlaylistTracks`
307307
12. `uploadClientPlaylistCover`
308308
13. `removeTrackFromClientPlaylist`
309-
14. `removeTracksFromClientPlaylist`
309+
14. `removeTracksFromClientPlaylist`

src/commonMain/kotlin/com.adamratzman.spotify/http/Endpoints.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@ import com.adamratzman.spotify.utils.ConcurrentHashMap
1616
import com.adamratzman.spotify.utils.getCurrentTimeMs
1717
import kotlin.math.ceil
1818
import kotlinx.coroutines.TimeoutCancellationException
19+
import kotlinx.coroutines.coroutineScope
20+
import kotlinx.coroutines.launch
1921
import kotlinx.coroutines.withTimeout
2022

2123
abstract class SpotifyEndpoint(val api: SpotifyApi<*, *>) {
2224
val cache = SpotifyCache()
2325
internal val json get() = api.json
2426

27+
internal suspend fun <T> chunk(limit: Int, objects: List<T>, consumer: suspend (List<T>) -> Unit) {
28+
coroutineScope {
29+
objects.chunked(limit).forEach { chunk ->
30+
launch { consumer(chunk) }
31+
}
32+
}
33+
}
34+
2535
internal suspend fun get(url: String): String {
2636
return execute(url)
2737
}

src/commonMain/kotlin/com.adamratzman.spotify/models/Track.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ data class AudioAnalysisMeta(
226226
@SerialName("analyzer_version") val analyzerVersion: String,
227227
val platform: String,
228228
@SerialName("detailed_status") val detailedStatus: String,
229-
@SerialName("status_code") val statusCode: Int,
229+
@SerialName("status_code") val statusCode: Int? = null,
230230
val timestamp: Long,
231231
@SerialName("analysis_time") val analysisTime: Float,
232232
@SerialName("input_process") val inputProcess: String
@@ -263,16 +263,16 @@ data class AudioAnalysisMeta(
263263
*/
264264
@Serializable
265265
data class AudioSection(
266-
val start: Float,
266+
val start: Float = 0f,
267267
val duration: Float,
268268
val confidence: Float,
269269
val loudness: Float,
270-
val tempo: Float,
271-
@SerialName("tempo_confidence") val tempoConfidence: Float,
270+
val tempo: Float?=null,
271+
@SerialName("tempo_confidence") val tempoConfidence: Float?=null,
272272
val key: Int,
273-
@SerialName("key_confidence") val keyConfidence: Float,
274-
val mode: Int,
275-
@SerialName("mode_confidence") val modeConfidence: Float,
273+
@SerialName("key_confidence") val keyConfidence: Float?=null,
274+
val mode: Int?=null,
275+
@SerialName("mode_confidence") val modeConfidence: Float?=null,
276276
@SerialName("time_signature") val timeSignature: Int,
277277
@SerialName("time_signature_confidence") val timeSignatureConfidence: Float
278278
)
@@ -300,11 +300,11 @@ data class AudioSection(
300300
*/
301301
@Serializable
302302
data class AudioSegment(
303-
val start: Float,
303+
val start: Float?=null,
304304
val duration: Float,
305-
val confidence: Float,
305+
val confidence: Float?=null,
306306
@SerialName("loudness_start") val loudnessStart: Float,
307-
@SerialName("loudness_max_time") val loudnessMaxTime: Float,
307+
@SerialName("loudness_max_time") val loudnessMaxTime: Float?=null,
308308
@SerialName("loudness_max") val loudnessMax: Float,
309309
@SerialName("loudness_end") val loudnessEnd: Float? = null,
310310
val pitches: List<Float>,
@@ -318,10 +318,10 @@ data class AudioSegment(
318318
data class TrackAnalysis(
319319
@SerialName("num_samples") val numSamples: Int,
320320
val duration: Float,
321-
@SerialName("sample_md5") val sampleMd5: String,
322-
@SerialName("offset_seconds") val offsetSeconds: Int,
323-
@SerialName("window_seconds") val windowSeconds: Int,
324-
@SerialName("analysis_sample_rate") val analysisSampleRate: Int,
321+
@SerialName("sample_md5") val sampleMd5: String? = null,
322+
@SerialName("offset_seconds") val offsetSeconds: Int?=null,
323+
@SerialName("window_seconds") val windowSeconds: Int?=null,
324+
@SerialName("analysis_sample_rate") val analysisSampleRate: Float,
325325
@SerialName("analysis_channels") val analysisChannels: Int,
326326
@SerialName("end_of_fade_in") val endOfFadeIn: Float,
327327
@SerialName("start_of_fade_out") val startOfFadeOut: Float,
@@ -332,7 +332,7 @@ data class TrackAnalysis(
332332
@SerialName("time_signature_confidence") val timeSignatureConfidence: Float,
333333
val key: Int,
334334
@SerialName("key_confidence") val keyConfidence: Float,
335-
val mode: Int,
335+
val mode: Int?=null,
336336
@SerialName("mode_confidence") val modeConfidence: Float,
337337
val codestring: String,
338338
@SerialName("code_version") val codeVersion: Float,

0 commit comments

Comments
 (0)