test login credentials before entering main program
closes #58 this is a bit messy, as librespot panics, when authentication fails. thus, we test the credentials in a separate thread to handle the panic. see also: https://github.com/librespot-org/librespot/issues/108
This commit is contained in:
@@ -220,6 +220,17 @@ impl Spotify {
|
||||
spotify
|
||||
}
|
||||
|
||||
pub fn test_credentials(credentials: Credentials) -> bool {
|
||||
let th = thread::spawn(|| {
|
||||
let mut core = Core::new().unwrap();
|
||||
let config = SessionConfig::default();
|
||||
let handle = core.handle();
|
||||
|
||||
core.run(Session::connect(config, credentials, None, handle)).unwrap();
|
||||
});
|
||||
th.join().is_ok()
|
||||
}
|
||||
|
||||
fn create_session(core: &mut Core, credentials: Credentials) -> Session {
|
||||
let session_config = SessionConfig::default();
|
||||
let cache = Cache::new(config::cache_path("librespot"), true);
|
||||
|
||||
Reference in New Issue
Block a user