@@ -90,7 +90,7 @@ async def request(self, method, url, **kwargs):
90
90
else :
91
91
raise HTTPSException (data .pop ('message' , 'Unknown error' ), response )
92
92
93
- async def download (self , url , path , ** kwargs ):
93
+ async def download (self , url , path , chunk_size = 4096 , ** kwargs ):
94
94
kwargs ['headers' ] = {'User-Agent' : self .user_agent }
95
95
async with self .session .request ('GET' , url , ** kwargs ) as response :
96
96
async def raise_error (error , resp , use_resp = False ):
@@ -117,7 +117,7 @@ async def raise_error(error, resp, use_resp=False):
117
117
filename = str .replace (re .findall ("filename=(.+)" , response .headers ['content-disposition' ])[0 ], "\" " , "" )
118
118
with open (f'{ path } /{ filename } ' , 'wb' ) as file :
119
119
while True :
120
- chunk = await response .content .read (4096 )
120
+ chunk = await response .content .read (chunk_size )
121
121
if not chunk :
122
122
break
123
123
file .write (chunk )
@@ -211,16 +211,16 @@ async def delete_playlist_track(self, playlist_id, track_id):
211
211
playlist = await self .get_playlist (playlist_id )
212
212
track = [item for item in playlist ['tracks' ] if item ['trackId' ] == track_id ][0 ]
213
213
del playlist ['tracks' ][playlist ['tracks' ].index (track )]
214
- return await self .request ('POST ' , f'{ self .PLAYLIST } /{ playlist_id } ' , json = playlist )
214
+ return await self .request ('PUT ' , f'{ self .PLAYLIST } /{ playlist_id } ' , json = playlist )
215
215
216
- async def download_release (self , album_id , path , audio_format ):
217
- return await self .download (self .download_link_gen .release (album_id , audio_format ), path )
216
+ async def download_release (self , album_id , path , audio_format , chunk_size = 8192 ):
217
+ return await self .download (self .download_link_gen .release (album_id , audio_format ), path , chunk_size = chunk_size )
218
218
219
- async def download_track (self , album_id , track_id , path , audio_format ):
220
- return await self .download (self .download_link_gen .track (album_id , track_id , audio_format ), path )
219
+ async def download_track (self , album_id , track_id , path , audio_format , chunk_size = 8192 ):
220
+ return await self .download (self .download_link_gen .track (album_id , track_id , audio_format ), path , chunk_size = chunk_size )
221
221
222
- async def download_playlist (self , playlist_id , page , path , audio_format ):
223
- return await self .download (self .download_link_gen .playlist (playlist_id , audio_format , page ), path )
222
+ async def download_playlist (self , playlist_id , page , path , audio_format , chunk_size = 8192 ):
223
+ return await self .download (self .download_link_gen .playlist (playlist_id , audio_format , page ), path , chunk_size = chunk_size )
224
224
225
225
async def get_self (self ):
226
226
return await self .request ('GET' , self .SELF )
0 commit comments