1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
use std::time::{Duration, SystemTime};
use std::fmt;
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyGetToken {
pub access_token: String,
pub token_type: String,
pub expires_in: u64,
pub scope: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug)]
pub struct SpotifyToken {
pub access_token: String,
pub expires_in: Duration,
pub toi: SystemTime,
pub cid: String,
pub cs: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug)]
pub enum UriType {
Track,
Album,
Playlist,
Artist,
Other,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug)]
pub struct SpotifyURI {
pub uri: String,
pub uri_raw: String,
pub uri_type: UriType,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAlbumFull {
pub album_type: String,
pub artists: Vec<SpotifyArtistSimplified>,
pub available_markets: Vec<String>,
pub copyrights: Vec<SpotifyCopyright>,
pub external_ids: SpotifyExternalIds,
pub external_urls: SpotifyExternalUrls,
pub genres: Vec<String>,
pub href: String,
pub id: String,
pub images: Vec<SpotifyImage>,
pub label: String,
pub name: String,
pub popularity: usize,
pub release_date: String,
pub release_date_precision: String,
pub tracks: SpotifyPagingTracks,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAlbumSimplified {
pub album_type: String,
pub artists: Vec<SpotifyArtistSimplified>,
pub available_markets: Vec<String>,
pub external_urls: SpotifyExternalUrls,
pub href: String,
pub id: String,
pub images: Vec<SpotifyImage>,
pub name: String,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyArtistFull {
pub external_urls: SpotifyExternalUrls,
pub followers: SpotifyFollowers,
pub genres: Vec<String>,
pub href: String,
pub id: String,
pub images: Vec<SpotifyImage>,
pub name: String,
pub popularity: usize,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyArtistSimplified {
pub external_urls: SpotifyExternalUrls,
pub href: String,
pub id: String,
pub name: String,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAudioFeatures {
pub acousticness: f64,
pub analysis_url: String,
pub danceability: f64,
pub duration_ms: usize,
pub energy: f64,
pub id: String,
pub instrumentalness: f64,
pub key: usize,
pub liveness: f64,
pub loudness: f64,
pub mode: usize,
pub speechiness: f64,
pub tempo: f64,
pub time_signature: usize,
pub track_href: String,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
pub valence: f64,
}
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifySeveralAudioFeatures {
pub audio_features: Vec<Option<SpotifyAudioFeatures>>,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyCategory {
pub href: String,
pub icons: Vec<SpotifyImage>,
pub id: String,
pub name: String
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyCopyright {
pub text: String,
#[serde(rename = "type")]
pub type_: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyCursor {
pub after: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyError {
pub status: usize,
pub message: String,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyExternalIds {
pub isrc: Option<String>,
pub ean: Option<String>,
pub upc: Option<String>,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyExternalUrls {
pub spotify: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyFollowers {
pub href: Option<String>,
pub total: usize,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyImage {
pub height: usize,
pub url: String,
pub width: usize,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyPagingTracks {
pub href: String,
pub items: Vec<SpotifyPlaylistTrack>,
pub limit: usize,
pub next: Option<String>,
pub offset: usize,
pub previous: Option<String>,
pub total: usize,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyCursorBasedPagingTracks {
pub href: String,
pub items: Vec<SpotifyPlaylistTrack>,
pub limit: usize,
pub next: String,
pub cursors: SpotifyCursor,
pub total: usize,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyPlaylistFull {
pub collaborative: bool,
pub description: String,
pub external_urls: SpotifyExternalUrls,
pub followers: SpotifyFollowers,
pub href: String,
pub id: String,
pub images: Vec<SpotifyImage>,
pub name: String,
pub owner: SpotifyUserPublic,
pub public: Option<bool>,
pub snapshot_id: String,
pub tracks: SpotifyPagingTracks,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyPlaylistSimplified {
pub collaborative: bool,
pub external_urls: SpotifyExternalUrls,
pub href: String,
pub id: String,
pub images: Vec<SpotifyImage>,
pub name: String,
pub owner: SpotifyUserPublic,
pub public: Option<bool>,
pub snapshot_id: String,
pub tracks: SpotifyPagingTracks,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyPlaylistTrack {
pub added_at: String,
#[serde(skip_deserializing)]
pub added_by: String,
pub is_local: bool,
pub track: SpotifyTrackFull,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyRecommendations {
pub seeds: Vec<SpotifyRecommendationsSeed>,
pub tracks: Vec<SpotifyTrackSimplified>,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyRecommendationsSeed {
pub afterFilteringSize: usize,
pub afterRelinkingSize: usize,
pub href: String,
pub id: String,
pub initialPoolSize: usize,
#[serde(rename = "type")]
pub type_: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifySavedTrack {
pub added_at: String,
pub track: SpotifyTrackFull,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifySavedAlbum {
added_at: String,
album: SpotifyAlbumFull
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyRestrictions {
pub reason: String,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyTrackFull {
pub album: SpotifyAlbumSimplified,
pub artists: Vec<SpotifyArtistSimplified>,
pub available_markets: Vec<String>,
pub disc_number: usize,
pub duration_ms: usize,
pub explicit: bool,
pub external_ids: SpotifyExternalIds,
pub external_urls: SpotifyExternalUrls,
pub href: String,
pub id: String,
pub name: String,
pub popularity: usize,
pub preview_url: Option<String>,
pub track_number: usize,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyTracks {
pub tracks: Vec<Option<SpotifyTrackFull>>,
}
#[allow(dead_code)]
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyTrackSimplified {
pub artists: Vec<SpotifyArtistSimplified>,
pub available_markets: Vec<String>,
pub disc_number: usize,
pub duration_ms: usize,
pub explicit: bool,
pub external_urls: SpotifyExternalUrls,
pub href: String,
pub id: String,
pub is_playable: bool,
pub linked_from: SpotifyTrackLink,
pub name: String,
pub preview_url: Option<String>,
pub track_number: usize,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyTrackLink {
pub external_urls: SpotifyExternalUrls,
pub href: String,
pub id: String,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyUserPrivate {
pub birthdate: String,
pub country: String,
pub display_name: Option<String>,
pub email: String,
pub external_urls: SpotifyExternalUrls,
pub followers: SpotifyFollowers,
pub href: String,
pub id: String,
pub images: Vec<SpotifyImage>,
pub product: String,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyUserPublic {
pub display_name: Option<String>,
pub external_urls: SpotifyExternalUrls,
pub followers: SpotifyFollowers,
pub href: String,
pub id: String,
pub images: Vec<SpotifyImage>,
#[serde(rename = "type")]
pub type_: String,
pub uri: String,
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyPlayHistory {
pub track: SpotifyTrackSimplified,
pub played_at: String,
pub context: SpotifyContext
}
#[allow(non_snake_case)]
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyContext {
#[serde(rename = "type")]
pub type_: String,
pub href: String,
pub external_urls: SpotifyExternalUrls,
pub uri: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAudioAnalysisFeature {
pub start: f64,
pub duration: f64,
pub confidence: f64,
}
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAudioAnalysisMeta {
pub analyzer_version: String,
pub platform: String,
pub detailed_status: String,
pub status_code: usize,
pub timestamp: usize,
pub analysis_time: f64,
pub input_process: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAudioAnalysisSections {
pub start: f64,
pub duration: f64,
pub confidence: f64,
pub loudness: f64,
pub tempo_confidence: f64,
pub key: usize,
pub key_confidence: f64,
pub mode: usize,
pub mode_confidence: f64,
pub time_signature: usize,
pub time_signature_confidence: f64,
}
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAudioAnalysisSegments {
pub start: f64,
pub duration: f64,
pub confidence: f64,
pub loudness_start: f64,
pub loudness_max_time: f64,
pub loudness_max: f64,
pub loudness_end: Option<f64>,
pub pitches: Vec<f64>,
pub timbre: Vec<f64>,
}
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAudioAnalysisTrack {
pub num_samples: Option<usize>,
pub duration: f64,
pub sample_md5: Option<String>,
pub offset_seconds: usize,
pub window_seconds: usize,
pub analysis_sample_rate: usize,
pub analysis_channels: usize,
pub end_of_fade_in: f64,
pub start_of_fade_out: f64,
pub loudness: f64,
pub tempo: f64,
pub tempo_confidence: f64,
pub time_signature: usize,
pub time_signature_confidence: f64,
pub key: usize,
pub key_confidence: f64,
pub mode: usize,
pub mode_confidence: f64,
pub codestring: String,
pub code_version: f64,
pub echoprintstring: String,
pub echoprint_version: f64,
pub synchstring: String,
pub synch_version: f64,
pub rhythmstring: String,
pub rhythm_version: f64,
}
impl fmt::Display for SpotifyAudioAnalysisTrack {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "num_samples: {},
duration: {},
offset_seconds: {},
window_seconds: {},
analysis_sample_rate: {},
analysis_channels: {},
end_of_fade_in: {},
start_of_fade_out: {},
loudness: {},
tempo: {},
tempo_confidence: {},
time_signature: {},
time_signature_confidence: {},
key: {},
key_confidence: {},
mode: {},
mode_confidence: {},
code_version: {},
echoprint_version: {},
synch_version: {},
rhythm_version: {}",
self.num_samples.unwrap(),
self.duration,
self.offset_seconds,
self.window_seconds,
self.analysis_sample_rate,
self.analysis_channels,
self.end_of_fade_in,
self.start_of_fade_out,
self.loudness,
self.tempo,
self.tempo_confidence,
self.time_signature,
self.time_signature_confidence,
self.key,
self.key_confidence,
self.mode,
self.mode_confidence,
self.code_version,
self.echoprint_version,
self.synch_version,
self.rhythm_version)
}
}
#[derive(Clone, Debug, Deserialize)]
pub struct SpotifyAudioAnalysis {
pub bars: Vec<SpotifyAudioAnalysisFeature>,
pub beats: Vec<SpotifyAudioAnalysisFeature>,
pub meta: SpotifyAudioAnalysisMeta,
pub sections: Vec<SpotifyAudioAnalysisSections>,
pub segments: Vec<SpotifyAudioAnalysisSegments>,
pub tatums: Vec<SpotifyAudioAnalysisFeature>,
pub track: SpotifyAudioAnalysisTrack,
}
impl fmt::Display for SpotifyAudioAnalysis {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "meta: {:?}\ntrack: {}", self.meta, self.track)
}
}