Comments (7)
Interesting! I did not realize this was a show-specific bug. Thanks for looking into that.
It seems like you're already taking a look at this, but let me know if you need anything else.
This isn't a major issue with spotify-tui
, especially since we can cheekily search "99%25 invisible" and have it still work 😉.
from rspotify.
I can reproduce your issue. Here's a minimal working example I wrote with 0.10.0:
use rspotify::blocking::client::Spotify;
use rspotify::blocking::oauth2::{SpotifyClientCredentials, SpotifyOAuth};
use rspotify::blocking::util::get_token;
use rspotify::senum::SearchType;
fn main() {
let mut oauth = SpotifyOAuth::default()
.scope("user-read-currently-playing")
.build();
let token_info = get_token(&mut oauth).unwrap();
let client_credential = SpotifyClientCredentials::default()
.token_info(token_info)
.build();
let spotify = Spotify::default()
.client_credentials_manager(client_credential)
.build();
let search_term = "99% invisible";
let search_show = spotify.search(
&search_term,
SearchType::Show,
None,
0,
None,
None,
);
println!("result: {:?}", search_show);
}
result: Err(Other(400))
I tried to reproduce after the rewrite in the master branch, using ureq as the client, expecting it to be fixed:
use rspotify::client::SpotifyBuilder;
use rspotify::oauth2::{CredentialsBuilder, OAuthBuilder};
use rspotify::senum::SearchType;
fn main() {
let creds = CredentialsBuilder::from_env().build().unwrap();
let oauth = OAuthBuilder::from_env()
.scope("user-read-playback-state")
.build()
.unwrap();
let mut spotify = SpotifyBuilder::default()
.credentials(creds)
.oauth(oauth)
.build()
.unwrap();
// Obtaining the access token
spotify.request_client_token().unwrap();
let search_term = "99% invisible";
let search_show = spotify.search(
&search_term,
SearchType::Show,
None,
0,
None,
None,
);
println!("result: {:?}", search_show);
}
result: Err(StatusCode(400, "Bad Request"))
But it seems to be an issue still... Interestingly, this is what happens with reqwest:
use rspotify::client::SpotifyBuilder;
use rspotify::oauth2::{CredentialsBuilder, OAuthBuilder};
use rspotify::senum::SearchType;
#[tokio::main]
async fn main() {
let creds = CredentialsBuilder::from_env().build().unwrap();
let oauth = OAuthBuilder::from_env()
.scope("user-read-playback-state")
.build()
.unwrap();
let mut spotify = SpotifyBuilder::default()
.credentials(creds)
.oauth(oauth)
.build()
.unwrap();
// Obtaining the access token
spotify.request_client_token().await.unwrap();
let search_term = "99% invisible";
let search_show = spotify.search(
&search_term,
SearchType::Show,
None,
0,
None,
None,
).await;
println!("result: {:?}", search_show);
}
result: Err(ParseJSON(Error("invalid type: null, expected struct SimplifiedShow", line: 4, column: 20)))
It seems to be related to SearchType::Show
, since with SearchType::Artist
it does work.
from rspotify.
I tried to reproduce the bug. With SearchType::Artist
it returns an empty result (items: []
), so I guess that's why it "works ok".
For SearchType::Show
it returns an array of nulls (items: [null, null, null, ...]
), hence the invalid type: null, expected struct SimplifiedShow
error.
from rspotify.
It seems the problem is in the invalid auth token.
I tried to reproduce the bug in the developer console (https://developer.spotify.com/console/), and it works just OK, no problems!
Then I tried to make the query in my terminal with curl with an auth token from the developer console, and it worked OK as well.
But then I tried to do it with an auth token I got from the code above (from this issue), and the bug was reproduced (I got items: [null, ...]
in response)!
from rspotify.
If the bug is related to the authentication process, is it possible it will be fixed (or otherwise affected) by #173 ?
from rspotify.
I mean #173 is meant to be a rewrite, but the functionality will be the same. The plan is to copy most of the codebase, only restructuring and tidying it up a bit.
But hey who knows maybe after that it'll magically work :P
I'm waiting to see if #191 can be sorted out beforehand, as two PRs restructuring the project at the same time doesn't sound like a good idea.
from rspotify.
Apparently this has been fixed in master
. I've added a test in #259.
from rspotify.
Related Issues (20)
- `tracks_features` breaks on deserialization when a track is requested that doesn't have audio features HOT 1
- Missing market field on the album API call HOT 1
- Yank version 0.11.7 from crates.io HOT 3
- Is Add Custom Playlist Cover Image request implemented ? HOT 2
- json parse error: unknown variant `Smartwatch`
- Route `/v1/shows/{id}` requires market query parameter but `get_a_show` market parameter is `Option` HOT 2
- queryArtistOverview / artist stats (monthly listeners) HOT 2
- AuthCodeSpotify with token and refresh HOT 2
- Incorrect url in OAuthClient documentation HOT 1
- json parse error when calling `artist` method HOT 24
- json parse error when getting playlist with no image HOT 20
- SimplifiedAlbum added onto SimplifiedTrack Struct
- Release a new version HOT 2
- Getting bad request error(400)
- Not able to get playlist, when reading token from a file HOT 1
- JSON parsing error when fetching a playlist with user's own local track
- Update the examples HOT 5
- `TrackLink::id` can be `null` HOT 1
- Unavailable tracks in market are still returned by playlist_items()
- Json Parsing error internal
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspotify.