Skip to content

Commit b0936c1

Browse files
authored
Fix lyrics call in request builder (jpochyla#648)
* Fix lyrics call by setting base uri in the builder, drop auth token
1 parent 615480d commit b0936c1

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

psst-gui/src/webapi/client.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,8 @@ impl WebApi {
9393
for header in request.get_headers() {
9494
req = req.header(header.0, header.1);
9595
}
96-
self.agent
97-
.get(request.build())
98-
.header("Authorization", &format!("Bearer {}", token))
99-
.call()
96+
97+
req.call()
10098
.map_err(|err| Error::WebApiError(err.to_string()))
10199
}
102100
Method::Post => self
@@ -987,19 +985,18 @@ impl WebApi {
987985
pub provider_lyrics_id: String,
988986
}
989987

990-
let token = self.access_token()?;
991988
let request = &RequestBuilder::new(
992-
format!("https://spclient.wg.spotify.com/color-lyrics/v2/track/{track_id}/image/https%3A%2F%2Fi.scdn.co%2Fimage%2F{}", track_id.clone().split_off(3)),
989+
format!("color-lyrics/v2/track/{track_id}"),
993990
Method::Get,
994991
None,
995992
)
993+
.set_base_uri("spclient.wg.spotify.com")
996994
.query("format", "json")
997995
.query("vocalRemoval", "false")
998996
.query("market", "from_token")
999-
.header("app-platform", "WebPlayer")
1000-
.header("Authorization", format!("Bearer {token}"));
997+
.header("app-platform", "WebPlayer");
1001998

1002-
let lyrics: Cached<Root> = self.load_cached(request, "TrackLines", &track_id)?;
999+
let lyrics: Cached<Root> = self.load_cached(request, "lyrics", &track_id)?;
10031000
Ok(lyrics.data.lyrics.lines)
10041001
}
10051002
}
@@ -1109,7 +1106,7 @@ impl WebApi {
11091106
.query("fields", "260")
11101107
.header("Authorization", format!("Bearer {token}"));
11111108

1112-
let result: Cached<User> = self.load_cached(request, "User_info", "usrinfo")?;
1109+
let result: Cached<User> = self.load_cached(request, "user-info", "usrinfo")?;
11131110

11141111
Ok((result.data.region, result.data.timezone))
11151112
}

0 commit comments

Comments
 (0)