]> kaliko git repositories - python-musicpdaio.git/blobdiff - doc/source/tutorial/tutorial-01.py
Update documentation
[python-musicpdaio.git] / doc / source / tutorial / tutorial-01.py
index 1ef066c692371e44da3c77ba6ad9a6187c30f6e1..c8197e57596ee1cd2ffdf44771094a59295d1a28 100644 (file)
@@ -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())