musicapy.saavn_api package
Submodules
musicapy.saavn_api.api module
- class musicapy.saavn_api.api.SaavnAPI
Bases:
SearchService
,SongService
,AlbumService
,Utils
SaavnAPI
class inherits all the services of the JioSaavn API used to search, get details and lyrics of songs and album
musicapy.saavn_api.config module
musicapy.saavn_api.endpoint module
- musicapy.saavn_api.endpoint.get_data(api_type: str = '', params: Optional[dict] = None, use_v4: bool = True) dict
Sends HTTP GET request to the Saavn API server and returns data in python dict format
- Parameters
api_type – str value containing Saavn api method from apis.saavnAPI.config module
params – dict value containing query key-value pairs
use_v4 – bool value. If True uses API v4 else ignores it. default value True
- Returns
returns a dict containing data else returns False if any status code is not 200
- Return type
dict or bool
- musicapy.saavn_api.endpoint.get_endpoint(api: str, is_version_4: bool = True) str
Get endpoint url
- Parameters
api – str value, api call from apis.saavnAPI.config module
is_version_4 – bool value, if True uses API version 4, else ignores it
- Returns
str value containing JioSaavn API endpoint
- Return type
str
musicapy.saavn_api.services module
- class musicapy.saavn_api.services.AlbumService
Bases:
object
AlbumService
class provides JioSaavn API wrapper class to perform operations on albums- static generate_album_download_links(identfier: dict) dict
Generates album song download links and returns it as dict
- Parameters
identifier – dictionary containing type and value as keys containing type(id or link) and its value(pids or token) respectively for JioSaavn API.
- Returns
returns details along with song download links as dict, if error occurs returns False
- Return type
dict or bool
- static get_album_details(identifier: dict) dict
Fetches album details and returns it as dict
- Parameters
album_query – str value, can be album link or album name
- Returns
returns album details as dict, if error occurs returns False
- Return type
dict or bool
- class musicapy.saavn_api.services.SearchService
Bases:
object
SearchService
used to search for songs based on albums or song name or all. Contains implemented to search for songs and albums, returns data in json format as python dict.- static search_album(album_query: str, page: int = 1, limit: int = 20) dict
Search for albums
- Parameters
query (album) – str containing album name
page – int value containing page number
limit – int value representing number of results on a single page
- Returns
False if anything goes wrong else returns python dict containing dict
- Return type
dict or bool
- static search_all(query: str) dict
Search for songs and albums
- Parameters
query – str containing query (artist, song or album name)
- Returns
returns dict if no error occurs else returns False
- Return type
dict or bool
- static search_song(song_query: str, page: int = 1, limit: int = 20) dict
Searchs for songs using song name and returns data based on passed arguments
- Parameters
song_query – string containing name of the song
page – int value used for pagination
limit – int value used for total results fetched on single page
- Returns
returns a dict containing data if error occurs returns False
- Return type
dict or bool
- class musicapy.saavn_api.services.SongService
Bases:
object
SongService
class wraps various JioSaavn API functions such as extracting song id, encrypted url, get trending songs, charts, etc.- static generate_song_download_links(identifier: dict)
static method of
SongService
Generates download links for song in various bitrate formats using identifier from JioSaavn API.- Parameters
identifier – dictionary containing type and value as keys containing type(id or link) and its value(pids or token) respectively for JioSaavn API.
- Returns
returns a dictionary containing song auth url, file type and status if error occurs then returns False
- Return type
dict | bool
- static get_charts() dict
Get song charts list as json data in form of dict
- Returns
dict containing charts
- Return type
None or dict
- static get_song_details(identifier: dict, use_v4=False) dict
Get song details using identifier
- Parameters
identifier – dictionary containing type and value as keys containing type(id or link) and its value(pids or token) respectively for JioSaavn API.
use_v4 – bool value notifying Service to use API version 4, default value is False
- Returns
returns data in form of dict, if error occurs or data is absent then returns False
- Return type
dict or bool
- static get_song_id(identifier: dict) str
Retreives Song Main Id which is used to get lyrics
- Parameters
identifier – dictionary containing type and value as keys containing type(id or link) and its value(pids or token) respectively for JioSaavn API.
- Returns
Song Id as str if id found else False
- Return type
str or bool
- static get_song_link(identifier: dict, bitrate: str = '320') dict
static method of
SongService
Generates link for song using identifier from JioSaavn API.- Parameters
identifier – dictionary containing type and value as keys containing type(id or link) and its value(pids or token) respectively for JioSaavn API.
bitrate – bitrate of the song, default value 320 i.e. 320 kbps
- Returns
returns a dictionary containing song auth url, file type and status if error occurs then returns False
- Return type
dict | bool
- static get_song_lyrics(identifier: dict) str
Get song lyrics
- Parameters
identifier – dictionary containing type and value as keys containing type(id or link) and its value(pids or token) respectively for JioSaavn API.
- Returns
dict containing charts
- Return type
dict or bool
- static get_trending() dict
Get trending songs list as json data in form of dict
- Returns
dict containing trending songs list
- Return type
None or dict
- static save_song(identifier: dict, floc: str, bitrate: str = '320')
Saves song to local machine using identifier
- Parameters
identifier – dictionary containing type and value as keys containing type(id or link) and its value(pids or token) respectively for JioSaavn API.
floc – str value, containing downloaded file location
bitrate – str value, bitrate of the song, default value 320 i.e. 320 kbps
- Returns
dict containing trending songs list
- Return type
dict
musicapy.saavn_api.utils module
- class musicapy.saavn_api.utils.Utils
Bases:
object
- static create_identifier(link: str, identifier_type: str = 'song')
Creates identifier dict used with SongService to perform various actions.
- Parameters
link – str value containing link of the JioSaavn song/album
identifier_type – str value can be of type song or album
- Returns
returns dictionary with keys type containing identifier type i.e. id or link and value key containing pids or token
- Return type
dict
- static extract_id_from_link(link: str, identifier_type: str = 'album')
Extracts id from the song or album JioSaavn URL
- Parameters
link – str value containing song or album URL
identifier_type – str value can take values song or album based on URL type
- Returns
id from the URL as str
- Return type
str
- static generate_album_song_download_links(album_details: dict) dict
Generates album song download links from data fetched from SaavnAPI
- Parameters
album_details – dict value containing data fetched from SaavnAPI using AlbumService.get_album_details static method
- Returns
returns album song download links as a dictionary, if error occurs returns False
- Return type
dict or bool
- static generate_download_links(preview_url: str, preview_bitrate: str = '_96_p') dict
Generates download links from preview url extracted from previous version of Jio Saavn API
- Parameters
preview_link – str value containing song preview URL
preview_bitrate – str value containing preview bit rate, default value is _96_p
- Returns
returns dictionary of bitrate as key and download link as urls i.e. { bitrate : download_link}
- Return type
dict