Code Monkey home page Code Monkey logo

Comments (7)

Utagai avatar Utagai commented on August 11, 2024 1

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.

marioortizmanero avatar marioortizmanero commented on August 11, 2024

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.

kstep avatar kstep commented on August 11, 2024

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.

kstep avatar kstep commented on August 11, 2024

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.

kstep avatar kstep commented on August 11, 2024

If the bug is related to the authentication process, is it possible it will be fixed (or otherwise affected) by #173 ?

from rspotify.

marioortizmanero avatar marioortizmanero commented on August 11, 2024

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.

marioortizmanero avatar marioortizmanero commented on August 11, 2024

Apparently this has been fixed in master. I've added a test in #259.

from rspotify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.