Skip to content

Commit ba77c06

Browse files
committed
temp: debug prints
1 parent bc2df61 commit ba77c06

7 files changed

Lines changed: 48 additions & 4 deletions

File tree

core/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::{fmt, path::PathBuf, str::FromStr};
33
use librespot_protocol::devices::DeviceType as ProtoDeviceType;
44
use url::Url;
55

6-
pub(crate) const KEYMASTER_CLIENT_ID: &str = "65b708073fc0480ea92a077233ca87bd";
7-
pub(crate) const ANDROID_CLIENT_ID: &str = "9a8d2f0ce77a4e248bb71fefcb557637";
6+
pub const KEYMASTER_CLIENT_ID: &str = "65b708073fc0480ea92a077233ca87bd";
7+
pub const ANDROID_CLIENT_ID: &str = "9a8d2f0ce77a4e248bb71fefcb557637";
88
pub(crate) const IOS_CLIENT_ID: &str = "58bd3c95768941ea9eb4350aaa033eb3";
99

1010
// Easily adjust the current platform to mock the behavior on it. If for example

core/src/login5.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ impl From<Login5Error> for Error {
5959

6060
impl Login5Manager {
6161
async fn request(&self, message: &LoginRequest) -> Result<Bytes, Error> {
62+
info!("Getting client token");
6263
let client_token = self.session().spclient().client_token().await?;
64+
info!("Got client token: {client_token}");
6365
let body = message.write_to_bytes()?;
6466

6567
let request = Request::builder()
@@ -73,6 +75,7 @@ impl Login5Manager {
7375
}
7476

7577
async fn login5_request(&self, login: Login_method) -> Result<LoginOk, Error> {
78+
info!("Login5 Req");
7679
let client_id = match OS {
7780
"macos" | "windows" => self.session().client_id(),
7881
// StoredCredential is used to get an access_token from Session credentials.
@@ -100,20 +103,23 @@ impl Login5Manager {
100103
count += 1;
101104

102105
let message = LoginResponse::parse_from_bytes(&response)?;
106+
info!("response: {message}");
103107
if let Some(Response::Ok(ok)) = message.response {
104108
break Ok(ok);
105109
}
106110

107111
if message.has_error() {
108112
match message.error() {
109113
LoginError::TIMEOUT | LoginError::TOO_MANY_ATTEMPTS => {
114+
info!("Login5 timeouting..");
110115
sleep(LOGIN_TIMEOUT).await
111116
}
112117
others => return Err(Login5Error::FaultyRequest(others).into()),
113118
}
114119
}
115120

116121
if message.has_challenges() {
122+
info!("Login5 challenges..");
117123
// handles the challenges, and updates the login context with the response
118124
Self::handle_challenges(&mut login_request, message)?;
119125
}
@@ -142,6 +148,7 @@ impl Login5Manager {
142148
// by manipulating the user-agent and client-id it can be also used/tested on desktop
143149
return Err(Login5Error::OnlyForMobile.into());
144150
}
151+
info!("logging in using {OS}");
145152

146153
let method = Login_method::Password(Password {
147154
id: id.into(),
@@ -155,6 +162,8 @@ impl Login5Manager {
155162
token_response.access_token_expires_in,
156163
);
157164

165+
166+
info!("Request end");
158167
Ok((auth_token, token_response.stored_credential))
159168
}
160169

@@ -164,6 +173,9 @@ impl Login5Manager {
164173
/// stored credentials generated with the keymaster client-id will not work, for example, with
165174
/// the android client-id.
166175
pub async fn auth_token(&self) -> Result<Token, Error> {
176+
info!("Using auth_token!");
177+
let client_id = self.session().client_id();
178+
info!("ClientID: {client_id}");
167179
let auth_data = self.session().auth_data();
168180
if auth_data.is_empty() {
169181
return Err(Login5Error::NoStoredCredentials.into());

core/src/spclient.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,11 @@ impl SpClient {
313313
match self.client_token_request(&answer_message).await {
314314
Ok(token) => {
315315
response = token;
316+
info!("Hash cash accepted");
316317
continue;
317318
}
318319
Err(e) => {
320+
info!("Hash cash not accepted");
319321
trace!("Answer not accepted {count}/{MAX_TRIES}: {e}");
320322
}
321323
}
@@ -371,6 +373,7 @@ impl SpClient {
371373
});
372374

373375
trace!("Got client token: {granted_token:?}");
376+
info!("Got client token: {granted_token:?}");
374377

375378
Ok(access_token)
376379
}
@@ -484,14 +487,23 @@ impl SpClient {
484487
);
485488
}
486489

490+
info!("SpClient requesting {url}");
491+
487492
let mut request = Request::builder()
488493
.method(method)
489494
.uri(url)
490495
.header(CONTENT_LENGTH, body.len())
491496
.body(Bytes::copy_from_slice(body))?;
492497

493498
// Reconnection logic: keep getting (cached) tokens because they might have expired.
494-
let token = self.session().login5().auth_token().await?;
499+
info!("SpClient pre token");
500+
//let token = self.session().login5().auth_token().await?;
501+
let token_type: &str = "access";
502+
let auth_data = self.session().auth_data();
503+
let access_token = String::from_utf8(auth_data)
504+
.unwrap_or_else(|_| String::new());
505+
506+
info!("SpClient post token: {access_token}");
495507

496508
let headers_mut = request.headers_mut();
497509
if let Some(ref headers) = headers {
@@ -502,7 +514,7 @@ impl SpClient {
502514

503515
headers_mut.insert(
504516
AUTHORIZATION,
505-
HeaderValue::from_str(&format!("{} {}", token.token_type, token.access_token,))?,
517+
HeaderValue::from_str(&format!("{} {}", token_type, access_token,))?,
506518
);
507519

508520
match self.client_token().await {
@@ -514,8 +526,10 @@ impl SpClient {
514526
warn!("Unable to get client token: {e} Trying to continue without...")
515527
}
516528
}
529+
info!("SpClient post headers");
517530

518531
last_response = self.session().http_client().request_body(request).await;
532+
info!("SpClient post response");
519533

520534
if last_response.is_ok() {
521535
return last_response;
@@ -605,7 +619,9 @@ impl SpClient {
605619
..Default::default()
606620
};
607621

622+
info!("Pre extended metadata..");
608623
let mut res = self.get_extended_metadata(req).await?;
624+
info!("Post extended metadata..");
609625
let mut extended_metadata = res
610626
.extended_metadata
611627
.pop()

metadata/src/audio/item.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,29 @@ impl AudioItem {
7373
.get_user_attribute("image-url")
7474
.unwrap_or_else(|| String::from("https://i.scdn.co/image/{file_id}"));
7575

76+
info!("Getting file (A)");
77+
7678
match uri {
7779
SpotifyUri::Track { .. } => {
80+
info!("Getting file (A2)");
7881
let track = Track::get(session, &uri).await?;
82+
info!("Getting file (B)");
7983

8084
if track.duration <= 0 {
8185
return Err(Error::unavailable(MetadataError::InvalidDuration(
8286
track.duration,
8387
)));
8488
}
89+
info!("Getting file (C)");
8590

8691
if track.is_explicit && session.filter_explicit_content() {
8792
return Err(Error::unavailable(MetadataError::ExplicitContentFiltered));
8893
}
94+
info!("Getting file (D)");
8995

9096
let uri_string = uri.to_uri();
9197
let album = track.album.name;
98+
info!("Getting file (E)");
9299

93100
let album_artists = track
94101
.album
@@ -116,6 +123,8 @@ impl AudioItem {
116123
)
117124
};
118125

126+
info!("Getting file (F)");
127+
119128
let popularity = track.popularity.clamp(0, 100) as u8;
120129
let number = track.number.max(0) as u32;
121130
let disc_number = track.disc_number.max(0) as u32;

metadata/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ pub trait Metadata: Send + Sized + 'static {
4848

4949
// Request a metadata struct
5050
async fn get(session: &Session, id: &SpotifyUri) -> Result<Self, Error> {
51+
info!("Requesting (a)..");
5152
let response = Self::request(session, id).await?;
53+
info!("Requesting (b)..");
5254
let msg = Self::Message::parse_from_bytes(&response)?;
55+
info!("Requesting (c)..");
5356
trace!("Received metadata: {msg:#?}");
5457
Self::parse(&msg, id)
5558
}

metadata/src/track.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ impl Metadata for Track {
6363
return Err(Error::invalid_argument("track_uri"));
6464
};
6565

66+
let uri = track_uri.to_uri();
67+
info!("Requesting {uri} as a rack");
68+
6669
session.spclient().get_track_metadata(track_uri).await
6770
}
6871

playback/src/player.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ impl PlayerTrackLoader {
976976
track_uri: SpotifyUri,
977977
position_ms: u32,
978978
) -> Option<PlayerLoadedTrackData> {
979+
debug!("Loading remote track");
979980
let track_id: SpotifyId = match (&track_uri).try_into() {
980981
Ok(id) => id,
981982
Err(_) => {

0 commit comments

Comments
 (0)