Get Basic Track Details For Multiple Tracks From The Spotify API In Rust
//! ```cargo
//! [dependencies]
//! rspotify = { version = "0.12.0", default-features = false, features = ["client-ureq", "ureq-rustls-tls", "env-file"] }
//! ```
#![allow(non_snake_case)]
use rspotify::{model::TrackId, prelude::*, ClientCredsSpotify, Credentials};
fn main() {
let chunk_size = 2; // up to 50
let ids = vec![
"spotify:track:0UlwTmT01jdFp3BaofARtU",
"spotify:track:7MXK7DwU1DpGFTA31AZW6S",
"spotify:track:0Lz0VvjdDvO8LaUOPW94iT",
"spotify:track:3obwANwnr6iXVABsOnXLNC",
"spotify:track:5xYZXIgVAND5sWjN8G0hID",
];
let creds = Credentials::from_env().unwrap();
let spotify = ClientCredsSpotify::new(creds);
spotify.request_token().unwrap();
let track_ids = ids.iter().map(|id| TrackId::from_uri(id).unwrap()).collect::<Vec<TrackId>>();
track_ids.chunks(chunk_size).for_each(|track_set| {
let tracks = spotify.tracks(track_set.to_owned(), None);
dbg!(tracks.ok());
});
}
Output:
[_active_nvim_run:24] tracks.ok() = Some(
[
FullTrack {
album: SimplifiedAlbum {
album_group: None,
album_type: Some(
"compilation",
),
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/2CvCyf1gEVhI0mX6aFXmVI",
},
href: Some(
"https://api.spotify.com/v1/artists/2CvCyf1gEVhI0mX6aFXmVI",
),
id: Some(
ArtistId(
"2CvCyf1gEVhI0mX6aFXmVI",
),
),
name: "Paul Simon",
},
],
available_markets: [
"AR",
"AU",
"AT",
"BE",
"BO",
"BR",
"BG",
"CA",
"CL",
"CO",
"CR",
"CY",
"CZ",
"DK",
"DO",
"DE",
"EC",
"EE",
"SV",
"FI",
"FR",
"GR",
"GT",
"HN",
"HK",
"HU",
"IS",
"IE",
"IT",
"LV",
"LT",
"LU",
"MY",
"MT",
"MX",
"NL",
"NZ",
"NI",
"NO",
"PA",
"PY",
"PE",
"PH",
"PL",
"PT",
"SG",
"SK",
"ES",
"SE",
"CH",
"TW",
"TR",
"UY",
"US",
"GB",
"AD",
"LI",
"MC",
"ID",
"JP",
"TH",
"VN",
"RO",
"IL",
"ZA",
"SA",
"AE",
"BH",
"QA",
"OM",
"KW",
"EG",
"MA",
"DZ",
"TN",
"LB",
"JO",
"PS",
"IN",
"BY",
"KZ",
"MD",
"UA",
"AL",
"BA",
"HR",
"ME",
"MK",
"RS",
"SI",
"KR",
"BD",
"PK",
"LK",
"GH",
"KE",
"NG",
"TZ",
"UG",
"AG",
"AM",
"BS",
"BB",
"BZ",
"BT",
"BW",
"BF",
"CV",
"CW",
"DM",
"FJ",
"GM",
"GE",
"GD",
"GW",
"GY",
"HT",
"JM",
"KI",
"LS",
"LR",
"MW",
"MV",
"ML",
"MH",
"FM",
"NA",
"NR",
"NE",
"PW",
"PG",
"WS",
"SM",
"ST",
"SN",
"SC",
"SL",
"SB",
"KN",
"LC",
"VC",
"SR",
"TL",
"TO",
"TT",
"TV",
"VU",
"AZ",
"BN",
"BI",
"KH",
"CM",
"TD",
"KM",
"GQ",
"SZ",
"GA",
"GN",
"KG",
"LA",
"MO",
"MR",
"MN",
"NP",
"RW",
"TG",
"UZ",
"ZW",
"BJ",
"MG",
"MU",
"MZ",
"AO",
"CI",
"DJ",
"ZM",
"CD",
"CG",
"IQ",
"LY",
"TJ",
"VE",
"ET",
"XK",
],
external_urls: {
"spotify": "https://open.spotify.com/album/4kdOH3s9cRL9YykvHFpSlD",
},
href: Some(
"https://api.spotify.com/v1/albums/4kdOH3s9cRL9YykvHFpSlD",
),
id: Some(
AlbumId(
"4kdOH3s9cRL9YykvHFpSlD",
),
),
images: [
Image {
height: Some(
640,
),
url: "https://i.scdn.co/image/ab67616d0000b2737075e4870a7c2e55f28045ce",
width: Some(
640,
),
},
Image {
height: Some(
300,
),
url: "https://i.scdn.co/image/ab67616d00001e027075e4870a7c2e55f28045ce",
width: Some(
300,
),
},
Image {
height: Some(
64,
),
url: "https://i.scdn.co/image/ab67616d000048517075e4870a7c2e55f28045ce",
width: Some(
64,
),
},
],
name: "The Essential Paul Simon",
release_date: Some(
"2007",
),
release_date_precision: Some(
"year",
),
restrictions: None,
},
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/2CvCyf1gEVhI0mX6aFXmVI",
},
href: Some(
"https://api.spotify.com/v1/artists/2CvCyf1gEVhI0mX6aFXmVI",
),
id: Some(
ArtistId(
"2CvCyf1gEVhI0mX6aFXmVI",
),
),
name: "Paul Simon",
},
],
available_markets: [
"AR",
"AU",
"AT",
"BE",
"BO",
"BR",
"BG",
"CA",
"CL",
"CO",
"CR",
"CY",
"CZ",
"DK",
"DO",
"DE",
"EC",
"EE",
"SV",
"FI",
"FR",
"GR",
"GT",
"HN",
"HK",
"HU",
"IS",
"IE",
"IT",
"LV",
"LT",
"LU",
"MY",
"MT",
"MX",
"NL",
"NZ",
"NI",
"NO",
"PA",
"PY",
"PE",
"PH",
"PL",
"PT",
"SG",
"SK",
"ES",
"SE",
"CH",
"TW",
"TR",
"UY",
"US",
"GB",
"AD",
"LI",
"MC",
"ID",
"JP",
"TH",
"VN",
"RO",
"IL",
"ZA",
"SA",
"AE",
"BH",
"QA",
"OM",
"KW",
"EG",
"MA",
"DZ",
"TN",
"LB",
"JO",
"PS",
"IN",
"BY",
"KZ",
"MD",
"UA",
"AL",
"BA",
"HR",
"ME",
"MK",
"RS",
"SI",
"KR",
"BD",
"PK",
"LK",
"GH",
"KE",
"NG",
"TZ",
"UG",
"AG",
"AM",
"BS",
"BB",
"BZ",
"BT",
"BW",
"BF",
"CV",
"CW",
"DM",
"FJ",
"GM",
"GE",
"GD",
"GW",
"GY",
"HT",
"JM",
"KI",
"LS",
"LR",
"MW",
"MV",
"ML",
"MH",
"FM",
"NA",
"NR",
"NE",
"PW",
"PG",
"WS",
"SM",
"ST",
"SN",
"SC",
"SL",
"SB",
"KN",
"LC",
"VC",
"SR",
"TL",
"TO",
"TT",
"TV",
"VU",
"AZ",
"BN",
"BI",
"KH",
"CM",
"TD",
"KM",
"GQ",
"SZ",
"GA",
"GN",
"KG",
"LA",
"MO",
"MR",
"MN",
"NP",
"RW",
"TG",
"UZ",
"ZW",
"BJ",
"MG",
"MU",
"MZ",
"AO",
"CI",
"DJ",
"ZM",
"CD",
"CG",
"IQ",
"LY",
"TJ",
"VE",
"ET",
"XK",
],
disc_number: 1,
duration: Duration {
secs: 213,
nanos: 960000000,
},
explicit: false,
external_ids: {
"isrc": "USSM11002044",
},
external_urls: {
"spotify": "https://open.spotify.com/track/0UlwTmT01jdFp3BaofARtU",
},
href: Some(
"https://api.spotify.com/v1/tracks/0UlwTmT01jdFp3BaofARtU",
),
id: Some(
TrackId(
"0UlwTmT01jdFp3BaofARtU",
),
),
is_local: false,
is_playable: None,
linked_from: None,
restrictions: None,
name: "Kodachrome",
popularity: 45,
preview_url: Some(
"https://p.scdn.co/mp3-preview/62fa3913090c48b00acb7daf2816bd23a6d3150f?cid=cd3e61bde252419da1e9b1051947a9a4",
),
track_number: 5,
},
FullTrack {
album: SimplifiedAlbum {
album_group: None,
album_type: Some(
"album",
),
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/74fkl73HDlCXw0l6cemB89",
},
href: Some(
"https://api.spotify.com/v1/artists/74fkl73HDlCXw0l6cemB89",
),
id: Some(
ArtistId(
"74fkl73HDlCXw0l6cemB89",
),
),
name: "G. Love & Special Sauce",
},
],
available_markets: [
"AR",
"AU",
"AT",
"BE",
"BO",
"BR",
"BG",
"CA",
"CL",
"CO",
"CR",
"CY",
"CZ",
"DK",
"DO",
"DE",
"EC",
"EE",
"SV",
"FI",
"FR",
"GR",
"GT",
"HN",
"HK",
"HU",
"IS",
"IE",
"IT",
"LV",
"LT",
"LU",
"MY",
"MT",
"MX",
"NL",
"NZ",
"NI",
"NO",
"PA",
"PY",
"PE",
"PH",
"PL",
"PT",
"SG",
"SK",
"ES",
"SE",
"CH",
"TW",
"TR",
"UY",
"US",
"GB",
"AD",
"LI",
"MC",
"ID",
"JP",
"TH",
"VN",
"RO",
"IL",
"ZA",
"SA",
"AE",
"BH",
"QA",
"OM",
"KW",
"EG",
"MA",
"DZ",
"TN",
"LB",
"JO",
"PS",
"IN",
"BY",
"KZ",
"MD",
"UA",
"AL",
"BA",
"HR",
"ME",
"MK",
"RS",
"SI",
"KR",
"BD",
"PK",
"LK",
"GH",
"KE",
"NG",
"TZ",
"UG",
"AG",
"AM",
"BS",
"BB",
"BZ",
"BT",
"BW",
"BF",
"CV",
"CW",
"DM",
"FJ",
"GM",
"GE",
"GD",
"GW",
"GY",
"HT",
"JM",
"KI",
"LS",
"LR",
"MW",
"MV",
"ML",
"MH",
"FM",
"NA",
"NR",
"NE",
"PW",
"PG",
"WS",
"SM",
"ST",
"SN",
"SC",
"SL",
"SB",
"KN",
"LC",
"VC",
"SR",
"TL",
"TO",
"TT",
"TV",
"VU",
"AZ",
"BN",
"BI",
"KH",
"CM",
"TD",
"KM",
"GQ",
"SZ",
"GA",
"GN",
"KG",
"LA",
"MO",
"MR",
"MN",
"NP",
"RW",
"TG",
"UZ",
"ZW",
"BJ",
"MG",
"MU",
"MZ",
"AO",
"CI",
"DJ",
"ZM",
"CD",
"CG",
"IQ",
"LY",
"TJ",
"VE",
"ET",
"XK",
],
external_urls: {
"spotify": "https://open.spotify.com/album/6K6iycuUPM1HT5sxnwp6Ek",
},
href: Some(
"https://api.spotify.com/v1/albums/6K6iycuUPM1HT5sxnwp6Ek",
),
id: Some(
AlbumId(
"6K6iycuUPM1HT5sxnwp6Ek",
),
),
images: [
Image {
height: Some(
640,
),
url: "https://i.scdn.co/image/ab67616d0000b2737923b2156563568de6115187",
width: Some(
640,
),
},
Image {
height: Some(
300,
),
url: "https://i.scdn.co/image/ab67616d00001e027923b2156563568de6115187",
width: Some(
300,
),
},
Image {
height: Some(
64,
),
url: "https://i.scdn.co/image/ab67616d000048517923b2156563568de6115187",
width: Some(
64,
),
},
],
name: "G. Love And Special Sauce",
release_date: Some(
"1994-05-10",
),
release_date_precision: Some(
"day",
),
restrictions: None,
},
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/74fkl73HDlCXw0l6cemB89",
},
href: Some(
"https://api.spotify.com/v1/artists/74fkl73HDlCXw0l6cemB89",
),
id: Some(
ArtistId(
"74fkl73HDlCXw0l6cemB89",
),
),
name: "G. Love & Special Sauce",
},
],
available_markets: [
"AR",
"AU",
"AT",
"BE",
"BO",
"BR",
"BG",
"CA",
"CL",
"CO",
"CR",
"CY",
"CZ",
"DK",
"DO",
"DE",
"EC",
"EE",
"SV",
"FI",
"FR",
"GR",
"GT",
"HN",
"HK",
"HU",
"IS",
"IE",
"IT",
"LV",
"LT",
"LU",
"MY",
"MT",
"MX",
"NL",
"NZ",
"NI",
"NO",
"PA",
"PY",
"PE",
"PH",
"PL",
"PT",
"SG",
"SK",
"ES",
"SE",
"CH",
"TW",
"TR",
"UY",
"US",
"GB",
"AD",
"LI",
"MC",
"ID",
"JP",
"TH",
"VN",
"RO",
"IL",
"ZA",
"SA",
"AE",
"BH",
"QA",
"OM",
"KW",
"EG",
"MA",
"DZ",
"TN",
"LB",
"JO",
"PS",
"IN",
"BY",
"KZ",
"MD",
"UA",
"AL",
"BA",
"HR",
"ME",
"MK",
"RS",
"SI",
"KR",
"BD",
"PK",
"LK",
"GH",
"KE",
"NG",
"TZ",
"UG",
"AG",
"AM",
"BS",
"BB",
"BZ",
"BT",
"BW",
"BF",
"CV",
"CW",
"DM",
"FJ",
"GM",
"GE",
"GD",
"GW",
"GY",
"HT",
"JM",
"KI",
"LS",
"LR",
"MW",
"MV",
"ML",
"MH",
"FM",
"NA",
"NR",
"NE",
"PW",
"PG",
"WS",
"SM",
"ST",
"SN",
"SC",
"SL",
"SB",
"KN",
"LC",
"VC",
"SR",
"TL",
"TO",
"TT",
"TV",
"VU",
"AZ",
"BN",
"BI",
"KH",
"CM",
"TD",
"KM",
"GQ",
"SZ",
"GA",
"GN",
"KG",
"LA",
"MO",
"MR",
"MN",
"NP",
"RW",
"TG",
"UZ",
"ZW",
"BJ",
"MG",
"MU",
"MZ",
"AO",
"CI",
"DJ",
"ZM",
"CD",
"CG",
"IQ",
"LY",
"TJ",
"VE",
"ET",
"XK",
],
disc_number: 1,
duration: Duration {
secs: 233,
nanos: 960000000,
},
explicit: false,
external_ids: {
"isrc": "USSM19401089",
},
external_urls: {
"spotify": "https://open.spotify.com/track/7MXK7DwU1DpGFTA31AZW6S",
},
href: Some(
"https://api.spotify.com/v1/tracks/7MXK7DwU1DpGFTA31AZW6S",
),
id: Some(
TrackId(
"7MXK7DwU1DpGFTA31AZW6S",
),
),
is_local: false,
is_playable: None,
linked_from: None,
restrictions: None,
name: "Baby's Got Sauce",
popularity: 45,
preview_url: Some(
"https://p.scdn.co/mp3-preview/d36f10597468c7597959cd51b80276ab7049a1a0?cid=cd3e61bde252419da1e9b1051947a9a4",
),
track_number: 5,
},
],
)
[_active_nvim_run:24] tracks.ok() = Some(
[
FullTrack {
album: SimplifiedAlbum {
album_group: None,
album_type: Some(
"single",
),
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/6G5wDM1Vmsscql7qRtcLH0",
},
href: Some(
"https://api.spotify.com/v1/artists/6G5wDM1Vmsscql7qRtcLH0",
),
id: Some(
ArtistId(
"6G5wDM1Vmsscql7qRtcLH0",
),
),
name: "French Horn Rebellion",
},
],
available_markets: [],
external_urls: {
"spotify": "https://open.spotify.com/album/5khb5PkmHdt07NwTe609sb",
},
href: Some(
"https://api.spotify.com/v1/albums/5khb5PkmHdt07NwTe609sb",
),
id: Some(
AlbumId(
"5khb5PkmHdt07NwTe609sb",
),
),
images: [
Image {
height: Some(
640,
),
url: "https://i.scdn.co/image/ab67616d0000b273f1bb459a14e12c6f48446a80",
width: Some(
640,
),
},
Image {
height: Some(
300,
),
url: "https://i.scdn.co/image/ab67616d00001e02f1bb459a14e12c6f48446a80",
width: Some(
300,
),
},
Image {
height: Some(
64,
),
url: "https://i.scdn.co/image/ab67616d00004851f1bb459a14e12c6f48446a80",
width: Some(
64,
),
},
],
name: "Caaalifornia",
release_date: Some(
"2013-10-08",
),
release_date_precision: Some(
"day",
),
restrictions: None,
},
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/6G5wDM1Vmsscql7qRtcLH0",
},
href: Some(
"https://api.spotify.com/v1/artists/6G5wDM1Vmsscql7qRtcLH0",
),
id: Some(
ArtistId(
"6G5wDM1Vmsscql7qRtcLH0",
),
),
name: "French Horn Rebellion",
},
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/21IHyqpE95fqLW8cY5gccG",
},
href: Some(
"https://api.spotify.com/v1/artists/21IHyqpE95fqLW8cY5gccG",
),
id: Some(
ArtistId(
"21IHyqpE95fqLW8cY5gccG",
),
),
name: "Ghost Beach",
},
],
available_markets: [],
disc_number: 1,
duration: Duration {
secs: 229,
nanos: 239000000,
},
explicit: false,
external_ids: {
"isrc": "US5ZL0900096",
},
external_urls: {
"spotify": "https://open.spotify.com/track/0Lz0VvjdDvO8LaUOPW94iT",
},
href: Some(
"https://api.spotify.com/v1/tracks/0Lz0VvjdDvO8LaUOPW94iT",
),
id: Some(
TrackId(
"0Lz0VvjdDvO8LaUOPW94iT",
),
),
is_local: false,
is_playable: None,
linked_from: None,
restrictions: None,
name: "Caaalifornia",
popularity: 0,
preview_url: None,
track_number: 1,
},
FullTrack {
album: SimplifiedAlbum {
album_group: None,
album_type: Some(
"album",
),
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/1XIbUq7y7kiMUhmp5dywGx",
},
href: Some(
"https://api.spotify.com/v1/artists/1XIbUq7y7kiMUhmp5dywGx",
),
id: Some(
ArtistId(
"1XIbUq7y7kiMUhmp5dywGx",
),
),
name: "Jim Capaldi",
},
],
available_markets: [],
external_urls: {
"spotify": "https://open.spotify.com/album/1Xo0pYG5d4gH2FMh3n3coU",
},
href: Some(
"https://api.spotify.com/v1/albums/1Xo0pYG5d4gH2FMh3n3coU",
),
id: Some(
AlbumId(
"1Xo0pYG5d4gH2FMh3n3coU",
),
),
images: [
Image {
height: Some(
640,
),
url: "https://i.scdn.co/image/ab67616d0000b27369792b995c0f39b8c131e856",
width: Some(
640,
),
},
Image {
height: Some(
300,
),
url: "https://i.scdn.co/image/ab67616d00001e0269792b995c0f39b8c131e856",
width: Some(
300,
),
},
Image {
height: Some(
64,
),
url: "https://i.scdn.co/image/ab67616d0000485169792b995c0f39b8c131e856",
width: Some(
64,
),
},
],
name: "Dear Mr. Fantasy",
release_date: Some(
"2010-01-01",
),
release_date_precision: Some(
"day",
),
restrictions: None,
},
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/1CD77o9fbdyQFrHnUPUEsF",
},
href: Some(
"https://api.spotify.com/v1/artists/1CD77o9fbdyQFrHnUPUEsF",
),
id: Some(
ArtistId(
"1CD77o9fbdyQFrHnUPUEsF",
),
),
name: "Traffic",
},
],
available_markets: [],
disc_number: 1,
duration: Duration {
secs: 339,
nanos: 786000000,
},
explicit: false,
external_ids: {
"isrc": "GBAAN6800033",
},
external_urls: {
"spotify": "https://open.spotify.com/track/3obwANwnr6iXVABsOnXLNC",
},
href: Some(
"https://api.spotify.com/v1/tracks/3obwANwnr6iXVABsOnXLNC",
),
id: Some(
TrackId(
"3obwANwnr6iXVABsOnXLNC",
),
),
is_local: false,
is_playable: None,
linked_from: None,
restrictions: None,
name: "Dear Mr. Fantasy",
popularity: 0,
preview_url: None,
track_number: 5,
},
],
)
[_active_nvim_run:24] tracks.ok() = Some(
[
FullTrack {
album: SimplifiedAlbum {
album_group: None,
album_type: Some(
"album",
),
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/6VsiDFMZJlJ053P1uO4A6h",
},
href: Some(
"https://api.spotify.com/v1/artists/6VsiDFMZJlJ053P1uO4A6h",
),
id: Some(
ArtistId(
"6VsiDFMZJlJ053P1uO4A6h",
),
),
name: "Public Service Broadcasting",
},
],
available_markets: [
"AR",
"AT",
"BE",
"BO",
"BR",
"BG",
"CA",
"CL",
"CO",
"CR",
"CY",
"CZ",
"DK",
"DO",
"DE",
"EC",
"EE",
"SV",
"FI",
"FR",
"GR",
"GT",
"HN",
"HU",
"IS",
"IE",
"IT",
"LV",
"LT",
"LU",
"MT",
"MX",
"NL",
"NZ",
"NI",
"NO",
"PA",
"PY",
"PE",
"PH",
"PL",
"PT",
"SK",
"ES",
"SE",
"CH",
"TR",
"UY",
"US",
"GB",
"AD",
"LI",
"MC",
"ID",
"TH",
"VN",
"RO",
"IL",
"ZA",
"SA",
"AE",
"BH",
"QA",
"OM",
"KW",
"EG",
"MA",
"DZ",
"TN",
"LB",
"JO",
"PS",
"IN",
"BY",
"KZ",
"MD",
"UA",
"AL",
"BA",
"HR",
"MK",
"SI",
"KR",
"BD",
"PK",
"LK",
"GH",
"KE",
"NG",
"TZ",
"UG",
"AG",
"AM",
"BS",
"BB",
"BZ",
"BT",
"BW",
"BF",
"CV",
"CW",
"DM",
"GM",
"GE",
"GD",
"GW",
"GY",
"HT",
"JM",
"LS",
"LR",
"MW",
"MV",
"ML",
"NA",
"NE",
"PW",
"PG",
"SM",
"ST",
"SN",
"SC",
"SL",
"KN",
"LC",
"VC",
"SR",
"TL",
"TT",
"AZ",
"BN",
"BI",
"KH",
"CM",
"TD",
"KM",
"GQ",
"SZ",
"GA",
"GN",
"KG",
"LA",
"MO",
"MR",
"MN",
"NP",
"RW",
"TG",
"UZ",
"ZW",
"BJ",
"MG",
"MU",
"MZ",
"AO",
"CI",
"DJ",
"ZM",
"CD",
"CG",
"IQ",
"LY",
"TJ",
"VE",
"ET",
],
external_urls: {
"spotify": "https://open.spotify.com/album/65KwtzkJXw7oT819NFWmEP",
},
href: Some(
"https://api.spotify.com/v1/albums/65KwtzkJXw7oT819NFWmEP",
),
id: Some(
AlbumId(
"65KwtzkJXw7oT819NFWmEP",
),
),
images: [
Image {
height: Some(
640,
),
url: "https://i.scdn.co/image/ab67616d0000b273123ebfc7ca99a9bb6342cd36",
width: Some(
640,
),
},
Image {
height: Some(
300,
),
url: "https://i.scdn.co/image/ab67616d00001e02123ebfc7ca99a9bb6342cd36",
width: Some(
300,
),
},
Image {
height: Some(
64,
),
url: "https://i.scdn.co/image/ab67616d00004851123ebfc7ca99a9bb6342cd36",
width: Some(
64,
),
},
],
name: "The Race For Space",
release_date: Some(
"2014",
),
release_date_precision: Some(
"year",
),
restrictions: None,
},
artists: [
SimplifiedArtist {
external_urls: {
"spotify": "https://open.spotify.com/artist/6VsiDFMZJlJ053P1uO4A6h",
},
href: Some(
"https://api.spotify.com/v1/artists/6VsiDFMZJlJ053P1uO4A6h",
),
id: Some(
ArtistId(
"6VsiDFMZJlJ053P1uO4A6h",
),
),
name: "Public Service Broadcasting",
},
],
available_markets: [
"AR",
"AT",
"BE",
"BO",
"BR",
"BG",
"CA",
"CL",
"CO",
"CR",
"CY",
"CZ",
"DK",
"DO",
"DE",
"EC",
"EE",
"SV",
"FI",
"FR",
"GR",
"GT",
"HN",
"HU",
"IS",
"IE",
"IT",
"LV",
"LT",
"LU",
"MT",
"MX",
"NL",
"NZ",
"NI",
"NO",
"PA",
"PY",
"PE",
"PH",
"PL",
"PT",
"SK",
"ES",
"SE",
"CH",
"TR",
"UY",
"US",
"GB",
"AD",
"LI",
"MC",
"ID",
"TH",
"VN",
"RO",
"IL",
"ZA",
"SA",
"AE",
"BH",
"QA",
"OM",
"KW",
"EG",
"MA",
"DZ",
"TN",
"LB",
"JO",
"PS",
"IN",
"BY",
"KZ",
"MD",
"UA",
"AL",
"BA",
"HR",
"MK",
"SI",
"KR",
"BD",
"PK",
"LK",
"GH",
"KE",
"NG",
"TZ",
"UG",
"AG",
"AM",
"BS",
"BB",
"BZ",
"BT",
"BW",
"BF",
"CV",
"CW",
"DM",
"GM",
"GE",
"GD",
"GW",
"GY",
"HT",
"JM",
"LS",
"LR",
"MW",
"MV",
"ML",
"NA",
"NE",
"PW",
"PG",
"SM",
"ST",
"SN",
"SC",
"SL",
"KN",
"LC",
"VC",
"SR",
"TL",
"TT",
"AZ",
"BN",
"BI",
"KH",
"CM",
"TD",
"KM",
"GQ",
"SZ",
"GA",
"GN",
"KG",
"LA",
"MO",
"MR",
"MN",
"NP",
"RW",
"TG",
"UZ",
"ZW",
"BJ",
"MG",
"MU",
"MZ",
"AO",
"CI",
"DJ",
"ZM",
"CD",
"CG",
"IQ",
"LY",
"TJ",
"VE",
"ET",
],
disc_number: 1,
duration: Duration {
secs: 252,
nanos: 720000000,
},
explicit: false,
external_ids: {
"isrc": "GBSZF1400173",
},
external_urls: {
"spotify": "https://open.spotify.com/track/5xYZXIgVAND5sWjN8G0hID",
},
href: Some(
"https://api.spotify.com/v1/tracks/5xYZXIgVAND5sWjN8G0hID",
),
id: Some(
TrackId(
"5xYZXIgVAND5sWjN8G0hID",
),
),
is_local: false,
is_playable: None,
linked_from: None,
restrictions: None,
name: "Go!",
popularity: 49,
preview_url: Some(
"https://p.scdn.co/mp3-preview/e486847ed1fb5c7d7bcff27efdab04d65a6a3ac1?cid=cd3e61bde252419da1e9b1051947a9a4",
),
track_number: 8,
},
],
)
Notes
- You can get up to 50 tracks at a time
- This one is done syncronously since I'm working with an SQLite database for inserts and don't want to hit it async
-
The credentails come from a .env file with:
RSPOTIFY_CLIENT_ID
,RSPOTIFY_CLIENT_SECRET
for Spotify Client Credentails auth
-- end of line --