X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=doc%2Fsource%2Ftutorial%2Ftutorial-01.py;h=c8197e57596ee1cd2ffdf44771094a59295d1a28;hb=refs%2Fheads%2Fmain;hp=1ef066c692371e44da3c77ba6ad9a6187c30f6e1;hpb=cdf2dd0c1021639a4aebae4eac44fbb09a224877;p=python-musicpdaio.git diff --git a/doc/source/tutorial/tutorial-01.py b/doc/source/tutorial/tutorial-01.py index 1ef066c..c8197e5 100644 --- a/doc/source/tutorial/tutorial-01.py +++ b/doc/source/tutorial/tutorial-01.py @@ -1,7 +1,7 @@ import asyncio import logging -from mpdaio.client import MPDClient +from mpdaio import MPDClient # Configure loggers logging.basicConfig(level=logging.INFO, format='%(levelname)-8s %(message)s') @@ -11,20 +11,30 @@ log = logging.getLogger('mpdaio.client') log.setLevel(logging.DEBUG) +async def search(fltr): + # Look for and add + await client.searchadd(fltr) + + async def run(): - # Use defaults to access MPD server - client = MPDClient() # Make an initial connection to MPD server # The connection is kept open an reused for later commands await client.ping() - + await client.clear() + filters = [ + '(Artist == "Neurosis")', + '(Artist == "Isis")', + '(Artist == "Cult of Luna")', + ] # Each task gathered here will run with it's own connection - await asyncio.gather(...) + await asyncio.gather(*map(search, filters)) # Closes all connections to MPD server await client.close() if __name__ == '__main__': + # Use defaults to access MPD server + client = MPDClient() asyncio.run(run())