Giter Site home page Giter Site logo

jiosaavn-python's Introduction

An unofficial Python3 wrapper for JioSaavn, a popular Indian music streaming service.. I am in no way affiliated with JioSaavn, use at your own risk.

Show some ❤️ and ⭐ the repo to support the project. It will motivate me to keep this project alive.

Telegram Channel made-with-python

Hire Me: Abhi Chaudhari!

Features

  • Get New Releases
  • Get Song Lyrics
  • Get Song Info
  • Get Song Direct Download Link
  • Get Featured Playlists
  • Get Playlist Songs
  • Get Top Charts
  • Get Top Artists
  • Get Artist's Top Songs
  • Search for Songs
  • Search for Albums
  • Search for Artists
  • Search for Playlists
  • Search for Podcasts
  • Search Top Queries

Getting it

To download jiosaavn-python, either fork this github repo or simply use Pypi via pip.

pip install jiosaavn-python

Get New Releases

You can use the following code to get new releases from JioSaavn. The below code shows the example using asyncio but you can also use the following in the async function with the await keyword. We are using limit=2 to limit the number of results returned.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_new_releases(page=1, limit=2))
print(json.dumps(data, indent=4))

Get Song Lyrics

You can use the following code to get song lyrics from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_song_lyrics("https://www.jiosaavn.com/song/srivalli/RBpGRidYdVI"))
print(json.dumps(data, indent=4))

Get Song Info

You can use the following code to get song info from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_song_details("https://www.jiosaavn.com/song/srivalli/RBpGRidYdVI"))
print(json.dumps(data, indent=4))

Get Song Direct Download Link

You can use the following code to get a song direct download from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_song_direct_link("https://www.jiosaavn.com/song/srivalli/RBpGRidYdVI"))
print(json.dumps(data, indent=4))

Get Featured Playlists

You can use the following code to get featured playlists from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword. We are using limit=2 to limit the number of results returned.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_featured_playlists(page=1, limit=2))
print(json.dumps(data, indent=4))

Get Playlist Songs

You can use the following code to get playlist songs from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword. We are using limit=2 to limit the number of results returned

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_playlist_songs("https://www.jiosaavn.com/featured/the-landers/2-aGcw5eLvQwkg5tVhI3fw__", page=1, limit=2))
print(json.dumps(data, indent=4))

Get Top Charts

You can use the following code to top charts from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_top_charts())
print(json.dumps(data, indent=4))

Get Top Artists

You can use the following code to get top artists from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_top_artists())
print(json.dumps(data, indent=4))

Get Artist's Top Songs

You can use the following code to get the artist's top songs from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword. We are using limit=2 to limit the number of results returned.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.get_artist_top_songs("https://www.jiosaavn.com/artist/allu-arjun-songs/BGi8EcKdZXk_", limit=2))
print(json.dumps(data, indent=4))

Search for Songs

You can use the following code to search songs from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.search_songs("Narayan mil jayega"))
print(json.dumps(data, indent=4))

Search for Albums

You can use the following code to search albums from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.search_albums("Narayan mil jayega"))
print(json.dumps(data, indent=4))

Search for Artists

You can use the following code to search artists from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.search_artists("Allu Arjun"))
print(json.dumps(data, indent=4))

Search for Playlists

You can use the following code to search playlists from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.search_playlists("Krishna"))
print(json.dumps(data, indent=4))

Search for Podcasts

You can use the following code to search podcasts from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.search_podcasts("Krishan"))
print(json.dumps(data, indent=4))

Search Top Queries

You can use the following code to search top queries from JioSaavn. You can pass Song ID/LINK Below code shows the example using asyncio but you can also use the following in the async function with the await keyword.

import json
import asyncio
from jiosaavn import JioSaavn

saavn = JioSaavn()
data = asyncio.run(saavn.search_topquery("the landers"))
print(json.dumps(data, indent=4))

Todo

  • Add download support for album
  • Add download support for playlist
  • Add download support for podcasts
  • Add get details feature for album
  • Add get details feature for atrist
  • Add get details feature for playlist
  • Add get details feature for podcasts

License

MIT License

Copyright (c) 2023 Abhishek Chaudhari

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

jiosaavn-python's People

Contributors

abhichaudharii avatar arsaboo avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

arsaboo

jiosaavn-python's Issues

Unable to install using pip

Thanks for your work on this library. I am trying to install it, but get the following error:

pip install jiosaavn-python
Collecting jiosaavn-python
  Using cached jiosaavn-python-0.1.tar.gz (5.9 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\arsab\AppData\Local\Temp\pip-install-5b9zc9xk\jiosaavn-python_8563bb5007ee422badf08e34f8c77af3\setup.py", line 4, in <module>
          long_description = f.read()
        File "C:\Users\arsab\anaconda3\lib\encodings\cp1252.py", line 23, in decode
          return codecs.charmap_decode(input,self.errors,decoding_table)[0]
      UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 267: character maps to <undefined>
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

My guess is we will need to modify the following to include encoding:

with open("README.md") as f:

with open("README.md", encoding="utf8") as f or include errors="ignore"

Non async function

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?

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.