Skip to content

Commit d65023b

Browse files
Cheap escuse to bump to version 0.1.0.1 in order to update the pypi description
Added the chunk_size parameter to download, download_release, download_track and download_release from connect.http.HTTPClient
1 parent 66c6fe7 commit d65023b

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

README.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ To install the development version, do the following:
2727

2828
.. code:: sh
2929
30-
python3 -m pip install -U https://github.com/GiovanniMCMXCIX/async-connect.py/archive/master.zip
30+
python3 -m pip install -U https://github.com/GiovanniMCMXCIX/async-connect.py/archive/master.zip#egg=async-connect.py[performance]
3131
3232
Requirements
3333
------------
3434

35-
- Python 3.6+
36-
- `aiohttp` library
35+
* Python 3.6+
36+
* ``aiohttp`` library
3737

3838
Extra Requirements
3939
------------------
4040

41-
This library contains an extra requirement that is name `performance` in other the library to work faster.
41+
This library contains an extra requirement that is name ``performance`` in other the library to work faster.
4242
You can install it using the following command:
4343

4444
.. code:: sh
4545
46-
python3 -m pip install -U async-connect.py#egg=async-connect.py[performance]
46+
python3 -m pip install -U async-connect.py[performance]
4747
48-
Note for using `uvloop` on async-connect.py you need to parse it to `connect.Client()` like so:
48+
Note for using ``uvloop`` on async-connect.py you need to parse it to ``connect.Client()`` like so:
4949

5050
.. code:: py
5151

async_connect/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__author__ = 'GiovanniMCMXCIX'
1414
__license__ = 'MIT'
1515
__copyright__ = 'Copyright 2017 GiovanniMCMXCIX'
16-
__version__ = '0.1.0'
16+
__version__ = '0.1.0.1'
1717

1818
from .errors import *
1919
from .client import Client
@@ -26,4 +26,4 @@
2626

2727
VersionInfo = namedtuple('VersionInfo', 'major minor micro releaselevel serial')
2828

29-
version_info = VersionInfo(major=0, minor=1, micro=0, releaselevel='final', serial=0)
29+
version_info = VersionInfo(major=0, minor=1, micro=0.1, releaselevel='final', serial=0)

async_connect/http.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async def request(self, method, url, **kwargs):
9090
else:
9191
raise HTTPSException(data.pop('message', 'Unknown error'), response)
9292

93-
async def download(self, url, path, **kwargs):
93+
async def download(self, url, path, chunk_size=4096, **kwargs):
9494
kwargs['headers'] = {'User-Agent': self.user_agent}
9595
async with self.session.request('GET', url, **kwargs) as response:
9696
async def raise_error(error, resp, use_resp=False):
@@ -117,7 +117,7 @@ async def raise_error(error, resp, use_resp=False):
117117
filename = str.replace(re.findall("filename=(.+)", response.headers['content-disposition'])[0], "\"", "")
118118
with open(f'{path}/{filename}', 'wb') as file:
119119
while True:
120-
chunk = await response.content.read(4096)
120+
chunk = await response.content.read(chunk_size)
121121
if not chunk:
122122
break
123123
file.write(chunk)
@@ -211,16 +211,16 @@ async def delete_playlist_track(self, playlist_id, track_id):
211211
playlist = await self.get_playlist(playlist_id)
212212
track = [item for item in playlist['tracks'] if item['trackId'] == track_id][0]
213213
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)
215215

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)
218218

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)
221221

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)
224224

225225
async def get_self(self):
226226
return await self.request('GET', self.SELF)

0 commit comments

Comments
 (0)