-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
2,933 additions
and
1,013 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ | |
|
||
__pycache__/ | ||
.venv/ | ||
dist | ||
JioSaavn.egg-info | ||
dist/ | ||
build/ | ||
jiosaavn.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from .__asyncJioSaavn import JioSaavn | ||
# from .__internal._async._fetch import * | ||
|
||
from ._asyncFetch import searchSong,searchAlbum,song,album,playlist,lyrics | ||
|
||
|
||
__all__ =[ | ||
'JioSaavn', | ||
'searchSong', | ||
'searchAlbum', | ||
'song', | ||
'album', | ||
'playlist', | ||
'lyrics' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from .__syncJioSaavn import JioSaavn | ||
|
||
from ._syncFetch import searchSong,searchAlbum,song,album,playlist,lyrics | ||
|
||
|
||
__all__ =[ | ||
'JioSaavn', | ||
'searchSong', | ||
'searchAlbum', | ||
'song', | ||
'album', | ||
'playlist', | ||
'lyrics' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
|
||
from typing import Optional | ||
from . import _asyncFetch | ||
|
||
class JioSaavn: | ||
''' | ||
### Create an instance of JioSaavn with async methods. | ||
''' | ||
@staticmethod | ||
async def searchSong(query:str,page:int=1,limit:int=10,response:str='json'): | ||
'''Searches for song in JioSaavn. | ||
Args: | ||
query (str): Sets the search query. | ||
page (int, optional): Sets page to the number of page. Defaults to 1. | ||
limit (int, optional): Sets limit to the number of results. Defaults to 10. Max to 30. | ||
response(str,optional): Sets the response of result. Defaults to `json`. | ||
Note: | ||
To get raw result Set `response` to `raw` | ||
Example: | ||
Calling `searchSong` method gives the search result. | ||
>>> from jiosaavn.Async import JioSaavn | ||
>>> search = await JioSaavn.searchSong('alone') | ||
>>> print(search) | ||
<https://github.com/vidyasagar1432/jiosaavn> | ||
''' | ||
return await _asyncFetch.searchSong(query=query,page=page,limit=limit,response=response) | ||
|
||
@staticmethod | ||
async def searchAlbum(query:str,response:str='json'): | ||
'''Searches for album in JioSaavn. | ||
Args: | ||
query (str): Sets the search query. | ||
response(str,optional): Sets the response of result. Defaults to `json`. | ||
Note: | ||
To get raw result Set `response` to `raw` | ||
Examples: | ||
Calling `searchAlbum` method gives the search result of albums. | ||
>>> from jiosaavn.Async import JioSaavn | ||
>>> search = await JioSaavn.searchAlbum('Alone') | ||
>>> print(search) | ||
<https://github.com/vidyasagar1432/jiosaavn> | ||
''' | ||
return await _asyncFetch.searchAlbum(query=query,response=response) | ||
|
||
@staticmethod | ||
async def song(url:Optional[str]=None,id:Optional[str]=None,lyrics:bool=False,response:str='json'): | ||
'''Get song info from JioSaavn. | ||
Args: | ||
url (str): Sets the url of song. | ||
id (str): Sets the id of song. | ||
lyrics (bool): Sets the lyrics whether to get lyrics. Defaults to `False`. | ||
response(str,optional): Sets the response of result. Defaults to `json`. | ||
Note: | ||
To get raw result Set `response` to `raw` | ||
Examples: | ||
Calling `song` method gives the song info. | ||
>>> from jiosaavn.Async import JioSaavn | ||
>>> result = await JioSaavn.song(id='veJXEDAz') | ||
>>> print(result) | ||
<https://github.com/vidyasagar1432/jiosaavn> | ||
''' | ||
return await _asyncFetch.song(url=url,id=id,lyrics=lyrics,response=response) | ||
|
||
@staticmethod | ||
async def album(url:Optional[str]=None,id:Optional[str]=None,lyrics:bool=False,response:str='json'): | ||
'''Get album info from JioSaavn. | ||
Args: | ||
url (str): Sets the url of album. | ||
id (str): Sets the id of album. | ||
lyrics (bool): Sets the lyrics whether to get lyrics. Defaults to `False`. | ||
response(str,optional): Sets the response of result. Defaults to `json`. | ||
Note: | ||
To get raw result Set `response` to `raw` | ||
Examples: | ||
Calling `album` method gives the album info. | ||
>>> from jiosaavn.Async import JioSaavn | ||
>>> result = await JioSaavn.album(id='10496527') | ||
>>> print(result) | ||
<https://github.com/vidyasagar1432/jiosaavn> | ||
''' | ||
return await _asyncFetch.album(url=url,id=id,lyrics=lyrics,response=response) | ||
|
||
@staticmethod | ||
async def playlist(url:Optional[str]=None,id:Optional[str]=None,lyrics:bool=False,response:str='json'): | ||
'''Get playlist info from JioSaavn. | ||
Args: | ||
url (str): Sets the url of playlist. | ||
id (str): Sets the id of playlist. | ||
lyrics (bool): Sets the lyrics whether to get lyrics. Defaults to `False`. | ||
response(str,optional): Sets the response of result. Defaults to `json`. | ||
Note: | ||
To get raw result Set `response` to `raw` | ||
Examples: | ||
Calling `playlist` method gives the playlist info. | ||
>>> from jiosaavn.Async import JioSaavn | ||
>>> result = await JioSaavn.playlist(url='https://www.jiosaavn.com/s/playlist/88063878238ad9a391a33c0e628d2b01/90s_Love/OykxHSA0YytFo9wdEAzFBA__') | ||
>>> print(result) | ||
<https://github.com/vidyasagar1432/jiosaavn> | ||
''' | ||
return await _asyncFetch.playlist(url=url,id=id,lyrics=lyrics,response=response) | ||
|
||
@staticmethod | ||
async def lyrics(url:Optional[str]=None,id:Optional[str]=None,response:str='json'): | ||
'''Get lyrics of a song (If Available) | ||
Args: | ||
url (str): Sets the url of playlist. | ||
id (str): Sets the id of song. | ||
response(str,optional): Sets the response of result. Defaults to `json`. | ||
Note: | ||
To get raw result Set `response` to `raw` | ||
Examples: | ||
Calling `lyrics` method gives the lyrics of song. | ||
>>> from jiosaavn.Async import JioSaavn | ||
>>> result = await JioSaavn.lyrics(id='blMuXL1P') | ||
>>> print(result) | ||
<https://github.com/vidyasagar1432/jiosaavn> | ||
''' | ||
return await _asyncFetch.lyrics(url=url,id=id,response=response) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
|
||
from . import __helper | ||
from . import _asyncFetch | ||
|
||
async def makeSongResponse(song,lyrics:bool=False): | ||
return { | ||
'id': song['id'], | ||
'songName':song['song'], | ||
'albumName':song['album'], | ||
'albumId': song['albumid'], | ||
'playCount': song['play_count'], | ||
'duration': song['duration'], | ||
'label': song['label'], | ||
'primaryArtists': song['primary_artists'], | ||
'primaryArtistsId':song['primary_artists_id'], | ||
'featuredArtists': song['featured_artists'], | ||
'featuredArtistsId':song['featured_artists_id'], | ||
# 'primaryArtists': [{'artist':artist,'id':id} for artist,id in zip((song['primary_artists']).split(', '),(song['primary_artists_id']).split(', '))], | ||
# 'featuredArtists': [{'artist':artist,'id':id} for artist,id in zip((song['featured_artists']).split(', '),(song['featured_artists_id']).split(', '))], | ||
'singers': song['singers'], | ||
'starring':song['starring'], | ||
'language': __helper.ucfirst(song['language']), | ||
'copyright': song['copyright_text'], | ||
'hasLyrics' : song['has_lyrics'], | ||
'lyrics': await _asyncFetch.lyrics(song['id']) if song['has_lyrics'] == "true" and lyrics else None, | ||
'releaseDate': song['release_date'], | ||
'songUrl':song['perma_url'], | ||
'albumUrl': song['album_url'], | ||
'imagesUrls': __helper.makeDifferentQualityImages(song['image']), | ||
'audioUrls':__helper.makeDifferentQualityMediaUrls(song['media_preview_url']), | ||
'labelUrl':f"https://www.jiosaavn.com{song['label_url']}", | ||
} | ||
|
||
|
||
async def makeSearchResponse(data): | ||
return [{ | ||
'id':i['id'], | ||
'songName':i['title'], | ||
'albumId':i['more_info']['album_id'], | ||
'albumName':i['more_info']['album'], | ||
'playCount': i['play_count'], | ||
'imagesUrls':__helper.makeDifferentQualityImages(i['image']), | ||
'primaryArtists':i['more_info']['artistMap']['primary_artists'], | ||
'featuredArtists':i['more_info']['artistMap']['featured_artists'], | ||
'artists':i['more_info']['artistMap']['artists'], | ||
'description':i['header_desc'], | ||
'hasLyrics':i['more_info']['has_lyrics'], | ||
'language':__helper.ucfirst(i['language']), | ||
'songUrl':i['perma_url'], | ||
'albumUrl':i['more_info']['album_url'], | ||
} for i in data['results']] | ||
|
||
|
||
|
||
async def makeAlbumSearchResponse(data): | ||
return [{ | ||
'id': i['id'], | ||
'albumName': i['title'], | ||
'music': i['music'], | ||
'description': i['description'], | ||
'year': i['more_info']['year'], | ||
'language': __helper.ucfirst(i['more_info']['language']), | ||
'songIds':i['more_info']['song_pids'], | ||
'albumUrl': i['url'], | ||
'imagesUrls':__helper.makeDifferentQualityImages(i['image']), | ||
}for i in data['albums']['data']] | ||
|
||
async def makeAlbumResponse(data,lyrics:bool=False): | ||
return { | ||
'albumId': data['albumid'], | ||
'title': data['title'], | ||
'name': data['name'], | ||
'year': data['year'], | ||
'primaryArtists': (data['primary_artists']).split(', '), | ||
'image': data['image'], | ||
'songs':[await makeSongResponse(song=song,lyrics=lyrics) for song in data['songs']], | ||
'songUrl': data['perma_url'], | ||
'releaseDate': data['release_date'], | ||
} | ||
|
||
async def makePlaylistResponse(data,lyrics:bool=False): | ||
return { | ||
'id': data['listid'], | ||
'listname': data['listname'], | ||
'username': data['username'], | ||
'listCount': data['list_count'], | ||
'playlistUrl': data['perma_url'], | ||
'image': data['image'], | ||
'songs':[await makeSongResponse(song=song,lyrics=lyrics) for song in data['songs']], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
# from enum import Enum | ||
|
||
# class Response(Enum): | ||
# json = 'json' | ||
# raw = 'raw' | ||
|
||
Response = ['json','raw'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.