Skip to content

Commit 55ced49

Browse files
authored
Merge pull request #929 from jforberg/playlist_tracks
Add error message for bad ID
2 parents ceebb37 + 5e8e2ba commit 55ced49

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

examples/playlist_tracks.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::env;
2+
use std::process;
23

34
use librespot::core::authentication::Credentials;
45
use librespot::core::config::SessionConfig;
@@ -18,11 +19,13 @@ async fn main() {
1819
}
1920
let credentials = Credentials::with_password(&args[1], &args[2]);
2021

21-
let uri_split = args[3].split(':');
22-
let uri_parts: Vec<&str> = uri_split.collect();
23-
println!("{}, {}, {}", uri_parts[0], uri_parts[1], uri_parts[2]);
24-
25-
let plist_uri = SpotifyId::from_base62(uri_parts[2]).unwrap();
22+
let plist_uri = SpotifyId::from_uri(&args[3]).unwrap_or_else(|_| {
23+
eprintln!(
24+
"PLAYLIST should be a playlist URI such as: \
25+
\"spotify:playlist:37i9dQZF1DXec50AjHrNTq\""
26+
);
27+
process::exit(1);
28+
});
2629

2730
let session = Session::connect(session_config, credentials, None)
2831
.await

0 commit comments

Comments
 (0)