FAQ¶
Why use yutipy when there are better libraries for individual music platforms?¶
You are correct that there are other libraries with more features tailored to specific music platforms. However, these libraries often come with complexities and additional steps that may not be necessary for all users. In contrast, yutipy is designed to be simple and focuses primarily on search functionality [1].
While there are several music platforms available for searching music, and potentially more in the future, yutipy aims to provide a straightforward experience.
Why is it necessary to use the close_session() method? What happens if we don’t call it?¶
Internally, yutipy uses requests.Session() [2] to make requests to the respective music platforms’ APIs for performance improvements.
Using requests.get() [3] for each request can be relatively slow, as it opens a new connection each time. In contrast, requests.Session()
allows for reusing the same session, which is beneficial when making multiple requests to the same API.
If you initiate an object using the with keyword, calling close_session() is not required. While inside the with block,
the same session is used for making requests, and close_session() is automatically called when you exit the block.
If you forget to call close_session() after you no longer need to make requests, the session will remain open,
potentially consuming resources. However, the session will eventually close when your application ends.
Why am I receiving a SpotifyException when trying to use the Spotify class?¶
The Spotify API endpoints require authentication. You will need a Client ID and Client Secret
obtained from the Spotify for Developers website. To do this, follow these steps:
Go to your dashboard at https://developer.spotify.com/dashboard.
- Create a new app and fill in the “Redirect URIs” field with:
localhost/callback
Select “Web API” for “Which API/SDKs are you planning to use?”, check the “I understand…” box, and click “Save”.
Click on “Settings” (located in the top right corner).
- Copy the
Client IDand save it somewhere secure.
- Copy the
- Click on “View client secret” to obtain your
Client Secretand save it somewhere secure as well.
- Click on “View client secret” to obtain your
Create a
.envfile in the root directory of your project.
After completing these steps, you should be able to use the Spotify class and its methods as expected.
Why am I receiving a KKBoxException when trying to use the KKBox class?¶
It’s the same case as with Spotify. You will need a Client ID and Client Secret
obtained from the KKBOX for Developers website. Please visit https://developer.kkbox.com/ for more information.
How do I use the CLI tool to search for music?¶
You can use the CLI tool to search for music directly from the command line. For example:
yutipy-cli "Artist Name" "Song Name" --service deezer
For more details, see the Usage Examples.
How do I set up API keys for the library?¶
You can use the configuration wizard to set up API keys interactively:
yutipy-config
The wizard will guide you through obtaining and setting up API keys for supported services like Spotify and KKBOX.