Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non async function #3

Open
arsaboo opened this issue Mar 6, 2023 · 4 comments
Open

Non async function #3

arsaboo opened this issue Mar 6, 2023 · 4 comments
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@arsaboo
Copy link
Contributor

arsaboo commented Mar 6, 2023

I am trying to retrieve songs from a playlist and here's the function that I have right now (running it in Jupyter notebook):

import json
import asyncio
from jiosaavn import JioSaavn
import nest_asyncio

saavn = JioSaavn()
nest_asyncio.apply()

# Define a function to get playlist songs by id
async def get_playlist_songs(playlist_url):
    # Use the async method from saavn
    songs = await saavn.get_playlist_songs(playlist_url)
    # Return a list of songs with details
    return songs


playlist_url = "https://www.jiosaavn.com/featured/weekly-top-songs/8MT-LQlP35c_"
data = asyncio.run(saavn.get_playlist_songs(playlist_url, page=1, limit=100))

It works but gives me a warning UserWarning: Unclosed <httpx.AsyncClient object at 0x000001DDD757F850>. See https://www.python-httpx.org/async/#opening-and-closing-clients for details.

A couple of questions for you:

  1. How would you modify the code to run without using asyncio? I tried a few combinations but I kept getting errors. Appreciate your input.
  2. Can we remove page=1, limit=100 from the get_playlist_songs function call?
@abhichaudharii
Copy link
Owner

abhichaudharii commented Mar 7, 2023

Thanks for asking and reporting the issue. You are getting that warning because I made a mistake while writing the wrapper. I will push a fix for that soon.

You cant call async functions without using asyncio. I'm planning to release synchronous and asynchronous functions. Then you won't need asyncio.

Yes, you can remove page=1, limit=100 those are optional arguments. My example shows the use of those keyword arguments because I wanted to show that you can limit the results. But you don't need to pass them always

@abhichaudharii abhichaudharii added bug Something isn't working enhancement New feature or request good first issue Good for newcomers labels Mar 7, 2023
@arsaboo
Copy link
Contributor Author

arsaboo commented Mar 8, 2023

Thanks @abhichaudharii It would be great to have this.

@arsaboo
Copy link
Contributor Author

arsaboo commented Mar 19, 2023

Any update on this and the other endpoints?

@abhichaudharii
Copy link
Owner

The new release is still in WIP and will be released in 2nd week of April month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants