cyberboysumanjay / jiosaavnapi Goto Github PK
View Code? Open in Web Editor NEWAn unofficial API for JioSaavn written in Python 3
Home Page: https://saavnapi-nine.vercel.app
License: MIT License
An unofficial API for JioSaavn written in Python 3
Home Page: https://saavnapi-nine.vercel.app
License: MIT License
Hi Team,
I have more than 20 songs in my playlist, when I am extracting the details of the songs locally I am not able to get more than 20 songs details. Is there any way to get all the songs from a playlist?
Thanks in Advance!!
Regards,
Kishor
As the title says....can we have this installed in a docker container...thanks!
not working anymore :(
Hi @cyberboysumanjay
http://xxxx/song/?query=https://www.jiosaavn.com/song/jaikal-mahakal/PDIsQyd4XVU
or use any song URL - the result is same as below for all
https://i.imgur.com/C69uA4V.png
-- updated --
Would be indeed appreciate to release an update to the code #54 #52 💯
bm
there are some errors after you update your code
1)i didn't get response on this url
http://127.0.0.1:5000/result/?query=https://www.jiosaavn.com/search/gulabo%20sitabo
as a response i get this
{
"error": "list index out of range",
"status": true
}
also some time get this error in cmd :
raise ConnectionError(e, request=request)requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.jiosaavn.com', port=443): Max retries exceeded with url: /album/meri-aashiqui/TbRMeOcOBwQ_ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x000001CC65162988>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
2)also not provide response for specific url like following
http://127.0.0.1:5000/result/?query=https://www.jiosaavn.com/album/meri-aashiqui/TbRMeOcOBwQ_
as response
{
"error": "'NoneType' object is not subscriptable",
"status": true
}
3)didn't get response for this also
http://127.0.0.1:5000/result/?query=https://www.jiosaavn.com/new-releases/hindi
as response
{
"error": "list index out of range",
"status": true
}
4)this kind of URLs take too much time to response like about 4 min
http://127.0.0.1:5000/result/?query=https://www.jiosaavn.com/featured/hindi_chartbusters/u-75xwHI4ks_
5)not get response from this also
http://127.0.0.1:5000/result/?query=https://www.jiosaavn.com/new-releases/hindi
as response
{
"error": "list index out of range",
"status": true
}
If i search a song using that api & if i get 5 results, the first encypted_media_url is ok but other encrypted_media_url are not.
giving a example:
searched for biba
result of encrypted_media_url:
[0] ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyNWCbjCNtKmlpOHj5Z9iMHUI6D1DOptP5iGTj6aGadVaA6rUzPXhg/xw7tS9a8Gtq
ok
tested from:
https://www.jiosaavn.com/api.php?__call=song.generateAuthToken&url=ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyNWCbjCNtKmlpOHj5Z9iMHUI6D1DOptP5iGTj6aGadVaA6rUzPXhg/xw7tS9a8Gtq&bitrate=128&api_version=4&_format=json&ctx=wap6dot0&_marker=0
[1] ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyrrbWdPUMf/EMIzWsgvF8LB0mjZN/D8gex9116AK/ob+lxXqCyxvoYBw7tS9a8Gtq
not ok
tested from
https://www.jiosaavn.com/api.php?__call=song.generateAuthToken&url=ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDyrrbWdPUMf/EMIzWsgvF8LB0mjZN/D8gex9116AK/ob+lxXqCyxvoYBw7tS9a8Gtq&bitrate=128&api_version=4&_format=json&ctx=wap6dot0&_marker=0
[2] & [3] & [4]
are also not ok
Plz help I am new
Playlist Link:
https://www.jiosaavn.com/s/playlist/dc743890bf724e7509bb96a668902396/Hindi_00ss/i4S6We6dWd1ieSJqt9HmOQ
StackTrace
192.168.29.235 - - [11/Oct/2021 15:57:10] "GET /playlist/?query=https://www.jiosaavn.com/s/playlist/dc743890bf724e7509bb96a668902396/Hindi_00ss/i4S6We6dWd1ieSJqt9HmOQ HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/shabinder/PycharmProjects/JioSaavnAPI/jiosaavn.py", line 78, in get_playlist_id
return res.split('"type":"playlist","id":"')[1].split('"')[0]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/shabinder/PycharmProjects/JioSaavnAPI/venv/lib/python3.8/site-packages/flask/app.py", line 2091, in __call__
return self.wsgi_app(environ, start_response)
File "/home/shabinder/PycharmProjects/JioSaavnAPI/venv/lib/python3.8/site-packages/flask/app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "/home/shabinder/PycharmProjects/JioSaavnAPI/venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/shabinder/PycharmProjects/JioSaavnAPI/venv/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/home/shabinder/PycharmProjects/JioSaavnAPI/venv/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/shabinder/PycharmProjects/JioSaavnAPI/venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/shabinder/PycharmProjects/JioSaavnAPI/venv/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/home/shabinder/PycharmProjects/JioSaavnAPI/venv/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/home/shabinder/PycharmProjects/JioSaavnAPI/app.py", line 69, in playlist
id = jiosaavn.get_playlist_id(query)
File "/home/shabinder/PycharmProjects/JioSaavnAPI/jiosaavn.py", line 80, in get_playlist_id
return res.split('"page_id","')[1].split('","')[0]
IndexError: list index out of range
sir jiosaavn-api query link to decode encrypted media url
i can see decryption (aes) function of url but not able to do same with api
When song url is opened in browser, it says access denied.
https://www.jiosaavn.com/shows/hanuman-chalisa--explanation/1/TkB2L7mGtQI_
How to fetch this ?
Would be indeed appreciate to release an update to the code
#44 #55 💯
bm
this api can support infinity scroll
I am a python beginner.
I just need some help in re-directing the json output to command line instead of webpage to use the output in some other script.
Thanks for the wonderful API!!
When using the api , the search results by default are set to 320 kbps. I edited it in jiosaavn.py to 128kbps but again its showing me 320kbps links. Do you guys have any idea about it ? and what are the supported bitrate like 64/96/256kbps ?
Hindi songs are showing perfectly, but searching an English song, showing 0 result.
Hi Sumanjay, Awesome work with the JIOSaavn API. You area brilliant programmer.
I was not aware of any such API until I found this. I tried reusing the API endpoints and they work well. Thank you. But I have ran into a weird problem recently with one of my node endpoints.
I have developed my node endpoints for fetching songs,albums, playlists, artists etc exposed at heroku server and everything works fine until I found a weird issue with the playlist endpoint which fetches playlist and its song contents by taking the playlist ID as a query parameter
This is how the endpoint looks:
https://musify-api-plus.herokuapp.com/api/5ET4NH9-4M64SNC-J3X5MGD-7MHPYZB/playlist?pid=2710678
Here pid=2710678 is a legit playlist ID having the title set to "Lets Play - The Rolling Stones" The response it gets me back is as follows:
{
"id": "2710678",
"title": "Lets Play - The Rolling Stones",
"subtitle": "159 Followers",
"header_desc": "",
"type": "playlist",
"perma_url": "https://www.jiosaavn.com/featured/lets-play---the-rolling-stones/htOJvDrP3Qw_",
"image": "https://c.saavncdn.com/editorial/RockNRollwithTheRollingStones_20200803083052.jpg",
"language": "",
"year": "",
"play_count": "",
"explicit_content": "0",
"list_count": "0",
"list_type": "",
"list": "",
"more_info": {
"uid": "phulki_user",
"is_dolby_content": false,
"subtype": [],
"last_updated": "1596468675",
"username": "",
"firstname": "JioSaavn",
"lastname": "",
"is_followed": "",
"isFY": false,
"follower_count": "159",
"fan_count": "0",
"playlist_type": "playlist",
"share": "1",
"sub_types": [],
"images": [],
"H2": null,
"subheading": null,
"video_count": "0"
}
}
You see the list object is empty but it should not be.
Same endpoint if I run for a Hindi Genre runs well, example below:
https://musify-api-plus.herokuapp.com/api/5ET4NH9-4M64SNC-J3X5MGD-7MHPYZB/playlist?pid=234432
Here pid=234432 is a legit playlist ID having the title set to "Kumar Sanu, S. P. Balasubrahmanyam, Alka Yagnik, and more" which is of hindi origin and it brings back the right result set as follows:
{
"id": "234432",
"title": "alka",
"subtitle": "Kumar Sanu, S. P. Balasubrahmanyam, Alka Yagnik, and more",
"header_desc": "62 songs with music from artists like Kumar Sanu, S. P. Balasubrahmanyam, Alka Yagnik, and more.",
"type": "playlist",
"perma_url": "https://www.jiosaavn.com/s/playlist/sriparna.here737/alka/sgrzeyzd,d8_",
"image": "https://pli.saavncdn.com/44/32/234432.jpg?bch=1416620063",
"language": "",
"year": "",
"play_count": "",
"explicit_content": "0",
"list_count": "62",
"list_type": "",
"list": [
{
"id": "nAuW4AWU",
"title": "Jaati Hoon Main",
"subtitle": "Kumar Sanu, Alka Yagnik - Karan Arjun",
"header_desc": "Track from Kumar Sanu and Alka Yagnik from album Karan Arjun.",
"type": "song",
"perma_url": "https://www.jiosaavn.com/song/jaati-hoon-main/HikeZkBxYGY",
"image": "https://c.saavncdn.com/232/Karan-Arjun-Hindi-1995-20190829081335-500x500.jpg",
"language": "hindi",
"year": "1995",
"play_count": "10949725",
"explicit_content": "0",
"list_count": "0",
"list_type": "",
"list": "",
"more_info": {
"music": "Rajesh Roshan",
"album_id": "1033999",
"album": "Karan Arjun",
"label": "Tips Music",
"origin": "none",
"is_dolby_content": false,
"320kbps": "true",
"encrypted_media_url": "ID2ieOjCrwfgWvL5sXl4B1ImC5QfbsDymUBXIUwA1ZJG8PdbGEwgwUn6SKRtJsrtEd1ACZe6+cbKXnaBIYRtuxw7tS9a8Gtq",
"encrypted_cache_url": "",
"album_url": "https://www.jiosaavn.com/album/karan-arjun/omz4exe0PC4_",
"duration": "383",
"rights": {
"code": "0",
"cacheable": "true",
"delete_cached_object": "false",
"reason": ""
},
"cache_state": "false",
"has_lyrics": "false",
"lyrics_snippet": "",
"starred": "false",
"copyright_text": "© 1995 Tips Industries Ltd.",
"artistMap": {
"primary_artists": [
{
"id": "455142",
"name": "Kumar Sanu",
"role": "primary_artists",
"image": "http://c.saavncdn.com/artists/Kumar_Sanu_150x150.jpg",
"type": "artist",
"perma_url": "https://www.jiosaavn.com/artist/kumar-sanu/fe0z9ZAFgGE_"
},
{
"id": "455120",
"name": "Alka Yagnik",
"role": "primary_artists",
"image": "http://c.saavncdn.com/artists/Alka_Yagnik_150x150.jpg",
"type": "artist",
"perma_url": "https://www.jiosaavn.com/artist/alka-yagnik/uqRkqsl4ZnQ_"
}
],
"featured_artists": [],
"artists": [
{
"id": "455518",
"name": "Rajesh Roshan",
"role": "music",
"image": "http://c.saavncdn.com/artists/Rajesh_Roshan_150x150.jpg",
"type": "artist",
"perma_url": "https://www.jiosaavn.com/artist/rajesh-roshan/0c99,qeT65U_"
},
{
"id": "455142",
"name": "Kumar Sanu",
"role": "singer",
"image": "http://c.saavncdn.com/artists/Kumar_Sanu_150x150.jpg",
"type": "artist",
"perma_url": "https://www.jiosaavn.com/artist/kumar-sanu/fe0z9ZAFgGE_"
},
{
"id": "455120",
"name": "Alka Yagnik",
"role": "singer",
"image": "http://c.saavncdn.com/artists/Alka_Yagnik_150x150.jpg",
"type": "artist",
"perma_url": "https://www.jiosaavn.com/artist/alka-yagnik/uqRkqsl4ZnQ_"
},
{
"id": "456004",
"name": "Indeevar",
"role": "lyricist",
"image": "http://c.saavncdn.com/437/Dil-Ke-Sau-Tukde-Har-Tukde-Pe-Tera-Naam-Hai-2013-150x150.jpg",
"type": "artist",
"perma_url": "https://www.jiosaavn.com/artist/indeevar/mMgW-vc9apU_"
},
{
"id": "461361",
"name": "Shah Rukh Khan",
"role": "starring",
"image": "http://c.saavncdn.com/artists/Shah_Rukh_Khan_150x150.jpg",
"type": "artist",
"perma_url": "https://www.jiosaavn.com/artist/shah-rukh-khan/tkXMVGTn-A0_"
},
{
"id": "459640",
"name": "Kajol",
"role": "starring",
"image": "http://c.saavncdn.com/artists/Kajol_150x150.jpg",
"type": "artist",
"perma_url": "https://www.jiosaavn.com/artist/kajol/NRXrg-GBqKM_"
}
]
},
"release_date": "1995-01-13",
"label_url": "/label/tips-music-albums/WyMes45YplY_",
"triller_available": false,
"decrypted_media_url": "https://aac.saavncdn.com/232/4dd9c36b4b0149490cf0e63a3f6c4f89_320.mp4"
}
You can see the list object is now filled.
At first I thought its an error with my node endpoint at heroku but NO, I did the same thing with the actual playlist URL of jiosaavn in postman and got the same inconsistency. Meaning works for hindi language but for english language it does not work fully. Strange. But weird thing again is when I run the endpoint from my localhost it gives me consistent result for both english and hindi genre playlist. This is something very strange I have come across.
Here is the playlist URL I am hitting internally
https://www.jiosaavn.com/api.php?__call=playlist.getDetails&api_version=4&_format=json&_marker=0&ctx=web6dot0&listid=
What do you think can be the issue here.
Here's the github of the api https://github.com/ayanchax/musify-api-plus
PS: The name musify is something went co-incidental with your app name, I will change that.
Pls let me know if you have seen this issue, we can connect. You can also check out my portfolio at https://swaroopchakraborty-9088c.netlify.app/
My direct number is 9831305667
Getting weird song name when it contains special characters, especially when the song is not in the English language
Steps to reproduce:
Value of the song will be
"song": "Cyberangel (���崩�3��象�)",
But it should be
"song": "Cyberangel (遊戲《崩壞3》印象曲)",
Instead of showing all details of each and every song in search results just provide the title, artist, album, etc which are being provided by search_base_url
and then let the user select from the list. After selection, you can provide other details like the download link and all provided by song_details_base_url
. This would save a lot of time and make the search option really fast.
As everyone who uses this API, first shows search results and after the user selects one from the results they show more details. Currently, unnecessary requests are made which increases the overall time.
The api and download url was working fine till yesterday but today i am getting http error 403 and could not downoad the song from generated url (example: https://aac.saavncdn.com/626/250830dc7d422f41a8934a3377b5a1e4_320.mp3). you can also try this in browser.
i think they have updated their api, it could be due to cipher encryption.
please solve this
Error looks like:
Access to aac.saavncdn.com was
don't have authorization to view this page.
HTTP ERROR 403
Hey, for my use case I need mp3s and It seems this library only give mp4/m4a files link.
I don't want to use FFmpeg locally to convert the file from m4a to mp3,
So by any chance saavn gives mp3 link too?
Thanks for sharing this wonderful API
Unfortunately, this has not been working since last couple of days
http://xxxx/song/?query=https://www.jiosaavn.com/song/jaikal-mahakal/PDIsQyd4XVU
or use any song URL - the result is same as below for all
https://i.imgur.com/DapijGR.png
Would be indeed appreciate to release an update to the code #59 #55 💯
bm
whenever I am trying to run the command 'python3 app.py' it shows the following error..
Traceback (most recent call last):
File "C:\Users\havya\OneDrive\Desktop\jiosaavan\jioSaavnAPI\app.py", line 1, in
from flask import Flask, request, redirect, jsonify, json
ModuleNotFoundError: No module named 'flask'
Even i have python flask installed
Can you please give me a sollution for this issue
Api completely fails to get any data
Dear please add Add gaana.com, hungama.com,apple music
Thank you for the awesome work. It seems the media_url is now giving 404 error. Would it be possible for you to have a look?
All APIs are working fine But the downloadUrls Are Not Working
link: "https://aac.saavncdn.com/000/OvlAyRLZEkNxzW3CFB0MKZjCgYLZ2AirQ1ng5_320.mp4"
Steps to reproduce :
ex:
"downloadUrl": [ { "quality": "12kbps", "link": "https://aac.saavncdn.com/278/BfOqweHrm2mICDgN64IbdCZZNyuXoBF8iiO_12.mp4" }, { "quality": "48kbps", "link": "https://aac.saavncdn.com/278/BfOqweHrm2mICDgN64IbdCZZNyuXoBF8iiO_48.mp4" }, { "quality": "96kbps", "link": "https://aac.saavncdn.com/278/BfOqweHrm2mICDgN64IbdCZZNyuXoBF8iiO_96.mp4" }, { "quality": "160kbps", "link": "https://aac.saavncdn.com/278/BfOqweHrm2mICDgN64IbdCZZNyuXoBF8iiO_160.mp4" }, { "quality": "320kbps", "link": "https://aac.saavncdn.com/278/BfOqweHrm2mICDgN64IbdCZZNyuXoBF8iiO_320.mp4" } ]
Please acknowledge this issue ASAP or please let me know if any workaround
Why only indian songs detail comes after giving any search query. If we try to fetch song details using ID then we can get the appropriate results. If this is any bug or simple issue then please fix it.
Hi,
The JSON parsing of response text fails for the following playlist:
https://www.jiosaavn.com/s/playlist/88063878238ad9a391a33c0e628d2b01/90s_Love/OykxHSA0YytFo9wdEAzFBA__
Usage: http://127.0.0.1:5000/playlist/?query=https://www.jiosaavn.com/s/playlist/88063878238ad9a391a33c0e628d2b01/90s_Love/OykxHSA0YytFo9wdEAzFBA__&lyrics=true
Stack trace:
Traceback (most recent call last):
File "/mnt/d/vj_work/Linux/ORIG_REPO/JioSaavnAPI/jiosaavn.py", line 70, in get_playlist
songs_json = json.loads(songs_json)
File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 20 column 12851 (char 12869)
127.0.0.1 - - [26/Mar/2022 01:02:41] "GET /playlist/?query=https://www.jiosaavn.com/s/playlist/88063878238ad9a391a33c0e628d2b01/90s_Love/OykxHSA0YytFo9wdEAzFBA__&lyrics=true HTTP/1.1" 200 -
Bug:
Looks like the following data is causing the JSON parse error.
"lyrics_snippet":"कहो ना, "प्यार है," कहो ना, "प्यार है"",
Culprit code?
jiosaavn.py:67,
songs_json = response.text.encode().decode('unicode-escape')
Since we are doing "unicode_escape" we are losing the JSON delimiter.
Fix?
Can we just load the response data as it is and decode the value while displaying?
After deploying it on vps
When i'm navigating to http://127.0.0.1:5000 , your github page is showing. Does that mean it's running??
And btw my cmd is showing this path 👇 and going to this location also opens ur github page
Thank you
i want to get the data from this link then your api is not gonna work
http://127.0.0.1:5000/result/?query=https://www.jiosaavn.com/featured/hindi_00s/tsJahdem34A_
Cloned your repo and tried to run
http://127.0.0.1:5000/song/?query=https://www.jiosaavn.com/song/tum-hi-aana-/NCw-YiNJYms&lyrics=true
Unfortunately it's returning me [] null value.
Where I can find the downloaded songs?
Sorry I am noob.
How can I increase the speed of the API? Right now it takes a lot of time to get results, even when using high speed internet with low latency.
I really liked your project. It's a shame that such a popular music streaming service doesn't have an official API.
Anyway, I think that it would be great if you could somehow add the functionality of getting user-specific information from your API.
For example, it would be great if I could get my playlists information from your API. And it would be awesome if you could somehow figure out ways to post changes to saavn through the API. For example, one could use your API to add new songs to a particular playlist. It would be very useful in a large number of projects.
Think about this suggestion :)
You are using des-ECB like below...
def decrypt_url(url):
des_cipher = des(b"38346591", ECB, b"\0\0\0\0\0\0\0\0",pad=None, padmode=PAD_PKCS5)
enc_url = base64.b64decode(url.strip())
dec_url = des_cipher.decrypt(enc_url, padmode=PAD_PKCS5).decode('utf-8')
dec_url = dec_url.replace("_96.mp4", "_320.mp4")
return dec_url
I want to know how did you fingure the type of encryption and decrypted it?
Hello, I was just testing this code before using it in on of my projects, and I saw that in the jiosaavn.py, in the function get_playlist(), when an exception occurs, you catch the exception and then call print_exc(), but print_exc() is not defined in that scope.
To test if the error occurs, I changed the code to throw an exception when called(just to test it), something like this:
def get_playlist(listId,lyrics):
try:
raise Exception # Added this line
response = requests.get(endpoints.playlist_details_base_url+listId)
if response.status_code == 200:
songs_json = response.text.encode().decode('unicode-escape')
songs_json = json.loads(songs_json)
return helper.format_playlist(songs_json,lyrics)
return None
except Exception:
print_exc()
return None
and then queried for a playlist using:
curl 127.0.0.1:5000/playlist/?query=https://www.jiosaavn.com/featured/lets-play---ed-sheeran/0lP3CKDY3cA_
As expected, an exception occurred while handling the first exception.
./JioSaavnAPI/helper.py line 61, "def decrypt_url(url)" this one part not decrypt the encrypted_media_url
Hello,
Sumanjay Da ,,
I also made a website using Your API With HTML and Javascript..
Kindly check it out..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.