|
1 |
| -connect.py |
2 |
| -========== |
| 1 | +async-connect.py |
| 2 | +================ |
3 | 3 |
|
4 |
| -Coming soon to an asynchronous script near you... |
| 4 | +.. image:: https://img.shields.io/pypi/v/async-connect.py.svg |
| 5 | + :target: https://pypi.python.org/pypi/async-connect.py |
| 6 | +.. image:: https://img.shields.io/pypi/pyversions/async-connect.py.svg |
| 7 | + :target: https://pypi.python.org/pypi/async-connect.py |
| 8 | +.. image:: https://travis-ci.org/GiovanniMCMXCIX/async-connect.py.svg?branch=master |
| 9 | + :target: https://travis-ci.org/GiovanniMCMXCIX/async-connect.py |
| 10 | +.. image:: https://discordapp.com/api/v7/guilds/119860281919668226/embed.png?style=shield |
| 11 | + :target: https://discord.gg/u5F8y9W |
| 12 | + |
| 13 | +async-connect.py is the asynchronous version of `connect.py <https://github.com/GiovanniMCMXCIX/connect.py>`__ |
| 14 | + |
| 15 | +If you want to report errors, bugs or typos you can join the discord guild listed next to the build shield. |
| 16 | + |
| 17 | +Installing |
| 18 | +---------- |
| 19 | + |
| 20 | +To install the library, you can just run the following command: |
| 21 | + |
| 22 | +.. code:: sh |
| 23 | +
|
| 24 | + python3 -m pip install -U async-connect.py |
| 25 | +
|
| 26 | +To install the development version, do the following: |
| 27 | + |
| 28 | +.. code:: sh |
| 29 | +
|
| 30 | + python3 -m pip install -U https://github.com/GiovanniMCMXCIX/async-connect.py/archive/master.zip |
| 31 | +
|
| 32 | +Requirements |
| 33 | +------------ |
| 34 | + |
| 35 | +- Python 3.6+ |
| 36 | +- `aiohttp` library |
| 37 | + |
| 38 | +Extra Requirements |
| 39 | +------------------ |
| 40 | + |
| 41 | +This library contains an extra requirement that is name `performance` in other the library to work faster. |
| 42 | +You can install it using the following command: |
| 43 | + |
| 44 | +.. code:: sh |
| 45 | +
|
| 46 | + python3 -m pip install -U async-connect.py#egg=async-connect.py[performance] |
| 47 | +
|
| 48 | +Note for using `uvloop` on async-connect.py you need to parse it to `connect.Client()` like so: |
| 49 | + |
| 50 | +.. code:: sh |
| 51 | +
|
| 52 | + import asyncio |
| 53 | + import uvloop |
| 54 | + import async_connect as connect |
| 55 | +
|
| 56 | + asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) |
| 57 | + loop = asyncio.get_event_loop() |
| 58 | + client = connect.Client(loop) |
| 59 | +
|
| 60 | + # rest of your code here |
| 61 | +
|
| 62 | +Example |
| 63 | +------- |
| 64 | + |
| 65 | +.. code:: sh |
| 66 | +
|
| 67 | + import async_connect as connect |
| 68 | +
|
| 69 | + async def get_release(): |
| 70 | + releases = await client.search_release('friends') |
| 71 | + print('Found the following:') |
| 72 | + for release in releases: |
| 73 | + print('{0.title} by {0.artists} [{0.catalog_id}] was released on {0.release_date} ' |
| 74 | + 'and has {1} track(s)'.format(release, len(await release.tracks()))) |
| 75 | +
|
| 76 | + if __name__ == "__main__": |
| 77 | + client = connect.Client() |
| 78 | + client.loop.run_until_complete(get_release()) |
0 commit comments