python-musicpd 0.8.0__tar.gz → 0.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/CHANGES.txt +13 -0
  2. python-musicpd-0.9.0/MANIFEST.in +3 -0
  3. python-musicpd-0.9.0/PKG-INFO +199 -0
  4. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/README.rst +2 -2
  5. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/doc/source/commands.rst +3 -4
  6. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/doc/source/commands.txt +8 -1
  7. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/doc/source/conf.py +3 -3
  8. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/doc/source/contribute.rst +1 -1
  9. python-musicpd-0.9.0/doc/source/doc.rst +12 -0
  10. python-musicpd-0.9.0/doc/source/examples/client.py +94 -0
  11. python-musicpd-0.9.0/doc/source/examples/connect.py +29 -0
  12. python-musicpd-0.9.0/doc/source/examples/connect_host.py +17 -0
  13. python-musicpd-0.9.0/doc/source/examples/exceptions.py +59 -0
  14. python-musicpd-0.9.0/doc/source/examples/findadd.py +8 -0
  15. python-musicpd-0.9.0/doc/source/examples/playback.py +7 -0
  16. python-musicpd-0.9.0/doc/source/examples.rst +57 -0
  17. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/doc/source/index.rst +7 -7
  18. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/doc/source/use.rst +87 -27
  19. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/musicpd.py +139 -85
  20. python-musicpd-0.9.0/pyproject.toml +37 -0
  21. python-musicpd-0.9.0/python_musicpd.egg-info/PKG-INFO +199 -0
  22. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/python_musicpd.egg-info/SOURCES.txt +9 -2
  23. python-musicpd-0.9.0/python_musicpd.egg-info/requires.txt +3 -0
  24. python-musicpd-0.9.0/setup.cfg +4 -0
  25. python-musicpd-0.8.0/MANIFEST.in +0 -2
  26. python-musicpd-0.8.0/PKG-INFO +0 -34
  27. python-musicpd-0.8.0/doc/source/doc.rst +0 -15
  28. python-musicpd-0.8.0/python_musicpd.egg-info/PKG-INFO +0 -34
  29. python-musicpd-0.8.0/setup.cfg +0 -44
  30. python-musicpd-0.8.0/setup.py +0 -10
  31. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/LICENSE.txt +0 -0
  32. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/python_musicpd.egg-info/dependency_links.txt +0 -0
  33. {python-musicpd-0.8.0 → python-musicpd-0.9.0}/python_musicpd.egg-info/top_level.txt +0 -0
@@ -1,6 +1,19 @@
1
1
  python-musicpd Changes List
2
2
  ===========================
3
3
 
4
+ Changes in 0.9.0
5
+ ----------------
6
+
7
+ * Use right SPDX identifier for license headers
8
+ * mpd_version attribute init to empty string instead of None
9
+ * Fixed send_noidle (introduced with e8daa719)
10
+ * Improved Range object to deal with window parameter
11
+ * Add logging
12
+ * Switch to pyproject.toml (setuptools build system)
13
+ * The connect sequence raises ConnectionError only on error,
14
+ previously getaddrinfo or unix socket connection error raised an OSError
15
+ * Improved documentation, add examples
16
+
4
17
  Changes in 0.8.0
5
18
  ----------------
6
19
 
@@ -0,0 +1,3 @@
1
+ include CHANGES.txt
2
+ graft doc/source
3
+ global-exclude *~ *.py[cod] *.so
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-musicpd
3
+ Version: 0.9.0
4
+ Summary: An MPD (Music Player Daemon) client library written in pure Python.
5
+ Author-email: Kaliko Jack <kaliko@azylum.org>
6
+ License: GNU LESSER GENERAL PUBLIC LICENSE
7
+ Version 3, 29 June 2007
8
+
9
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
10
+ Everyone is permitted to copy and distribute verbatim copies
11
+ of this license document, but changing it is not allowed.
12
+
13
+
14
+ This version of the GNU Lesser General Public License incorporates
15
+ the terms and conditions of version 3 of the GNU General Public
16
+ License, supplemented by the additional permissions listed below.
17
+
18
+ 0. Additional Definitions.
19
+
20
+ As used herein, "this License" refers to version 3 of the GNU Lesser
21
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
22
+ General Public License.
23
+
24
+ "The Library" refers to a covered work governed by this License,
25
+ other than an Application or a Combined Work as defined below.
26
+
27
+ An "Application" is any work that makes use of an interface provided
28
+ by the Library, but which is not otherwise based on the Library.
29
+ Defining a subclass of a class defined by the Library is deemed a mode
30
+ of using an interface provided by the Library.
31
+
32
+ A "Combined Work" is a work produced by combining or linking an
33
+ Application with the Library. The particular version of the Library
34
+ with which the Combined Work was made is also called the "Linked
35
+ Version".
36
+
37
+ The "Minimal Corresponding Source" for a Combined Work means the
38
+ Corresponding Source for the Combined Work, excluding any source code
39
+ for portions of the Combined Work that, considered in isolation, are
40
+ based on the Application, and not on the Linked Version.
41
+
42
+ The "Corresponding Application Code" for a Combined Work means the
43
+ object code and/or source code for the Application, including any data
44
+ and utility programs needed for reproducing the Combined Work from the
45
+ Application, but excluding the System Libraries of the Combined Work.
46
+
47
+ 1. Exception to Section 3 of the GNU GPL.
48
+
49
+ You may convey a covered work under sections 3 and 4 of this License
50
+ without being bound by section 3 of the GNU GPL.
51
+
52
+ 2. Conveying Modified Versions.
53
+
54
+ If you modify a copy of the Library, and, in your modifications, a
55
+ facility refers to a function or data to be supplied by an Application
56
+ that uses the facility (other than as an argument passed when the
57
+ facility is invoked), then you may convey a copy of the modified
58
+ version:
59
+
60
+ a) under this License, provided that you make a good faith effort to
61
+ ensure that, in the event an Application does not supply the
62
+ function or data, the facility still operates, and performs
63
+ whatever part of its purpose remains meaningful, or
64
+
65
+ b) under the GNU GPL, with none of the additional permissions of
66
+ this License applicable to that copy.
67
+
68
+ 3. Object Code Incorporating Material from Library Header Files.
69
+
70
+ The object code form of an Application may incorporate material from
71
+ a header file that is part of the Library. You may convey such object
72
+ code under terms of your choice, provided that, if the incorporated
73
+ material is not limited to numerical parameters, data structure
74
+ layouts and accessors, or small macros, inline functions and templates
75
+ (ten or fewer lines in length), you do both of the following:
76
+
77
+ a) Give prominent notice with each copy of the object code that the
78
+ Library is used in it and that the Library and its use are
79
+ covered by this License.
80
+
81
+ b) Accompany the object code with a copy of the GNU GPL and this license
82
+ document.
83
+
84
+ 4. Combined Works.
85
+
86
+ You may convey a Combined Work under terms of your choice that,
87
+ taken together, effectively do not restrict modification of the
88
+ portions of the Library contained in the Combined Work and reverse
89
+ engineering for debugging such modifications, if you also do each of
90
+ the following:
91
+
92
+ a) Give prominent notice with each copy of the Combined Work that
93
+ the Library is used in it and that the Library and its use are
94
+ covered by this License.
95
+
96
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
97
+ document.
98
+
99
+ c) For a Combined Work that displays copyright notices during
100
+ execution, include the copyright notice for the Library among
101
+ these notices, as well as a reference directing the user to the
102
+ copies of the GNU GPL and this license document.
103
+
104
+ d) Do one of the following:
105
+
106
+ 0) Convey the Minimal Corresponding Source under the terms of this
107
+ License, and the Corresponding Application Code in a form
108
+ suitable for, and under terms that permit, the user to
109
+ recombine or relink the Application with a modified version of
110
+ the Linked Version to produce a modified Combined Work, in the
111
+ manner specified by section 6 of the GNU GPL for conveying
112
+ Corresponding Source.
113
+
114
+ 1) Use a suitable shared library mechanism for linking with the
115
+ Library. A suitable mechanism is one that (a) uses at run time
116
+ a copy of the Library already present on the user's computer
117
+ system, and (b) will operate properly with a modified version
118
+ of the Library that is interface-compatible with the Linked
119
+ Version.
120
+
121
+ e) Provide Installation Information, but only if you would otherwise
122
+ be required to provide such information under section 6 of the
123
+ GNU GPL, and only to the extent that such information is
124
+ necessary to install and execute a modified version of the
125
+ Combined Work produced by recombining or relinking the
126
+ Application with a modified version of the Linked Version. (If
127
+ you use option 4d0, the Installation Information must accompany
128
+ the Minimal Corresponding Source and Corresponding Application
129
+ Code. If you use option 4d1, you must provide the Installation
130
+ Information in the manner specified by section 6 of the GNU GPL
131
+ for conveying Corresponding Source.)
132
+
133
+ 5. Combined Libraries.
134
+
135
+ You may place library facilities that are a work based on the
136
+ Library side by side in a single library together with other library
137
+ facilities that are not Applications and are not covered by this
138
+ License, and convey such a combined library under terms of your
139
+ choice, if you do both of the following:
140
+
141
+ a) Accompany the combined library with a copy of the same work based
142
+ on the Library, uncombined with any other library facilities,
143
+ conveyed under the terms of this License.
144
+
145
+ b) Give prominent notice with the combined library that part of it
146
+ is a work based on the Library, and explaining where to find the
147
+ accompanying uncombined form of the same work.
148
+
149
+ 6. Revised Versions of the GNU Lesser General Public License.
150
+
151
+ The Free Software Foundation may publish revised and/or new versions
152
+ of the GNU Lesser General Public License from time to time. Such new
153
+ versions will be similar in spirit to the present version, but may
154
+ differ in detail to address new problems or concerns.
155
+
156
+ Each version is given a distinguishing version number. If the
157
+ Library as you received it specifies that a certain numbered version
158
+ of the GNU Lesser General Public License "or any later version"
159
+ applies to it, you have the option of following the terms and
160
+ conditions either of that published version or of any later version
161
+ published by the Free Software Foundation. If the Library as you
162
+ received it does not specify a version number of the GNU Lesser
163
+ General Public License, you may choose any version of the GNU Lesser
164
+ General Public License ever published by the Free Software Foundation.
165
+
166
+ If the Library as you received it specifies that a proxy can decide
167
+ whether future versions of the GNU Lesser General Public License shall
168
+ apply, that proxy's public statement of acceptance of any version is
169
+ permanent authorization for you to choose that version for the
170
+ Library.
171
+
172
+ Project-URL: Homepage, https://kaliko.me/python-musicpd/
173
+ Keywords: mpd,Music Player Daemon
174
+ Classifier: Development Status :: 5 - Production/Stable
175
+ Classifier: Intended Audience :: Developers
176
+ Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
177
+ Classifier: Natural Language :: English
178
+ Classifier: Operating System :: OS Independent
179
+ Classifier: Programming Language :: Python :: 3
180
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
181
+ Requires-Python: >=3.6
182
+ Description-Content-Type: text/x-rst
183
+ License-File: LICENSE.txt
184
+ Provides-Extra: sphinx
185
+ Requires-Dist: Sphinx>=5.3.0; extra == "sphinx"
186
+
187
+ Music Player Daemon client module
188
+ *********************************
189
+
190
+ An MPD (Music Player Daemon) client library written in pure Python.
191
+
192
+ ----
193
+
194
+ :Documentation: https://kaliko.gitlab.io/python-musicpd
195
+ :MPD Protocol: https://www.musicpd.org/doc/html/protocol.html
196
+ :Code: https://gitlab.com/kaliko/python-musicpd
197
+ :Dependencies: None
198
+ :Compatibility: Python 3.6+
199
+ :Licence: GNU LGPLv3
@@ -1,5 +1,5 @@
1
- Python MusicPlayerDaemon client module
2
- ***************************************
1
+ Music Player Daemon client module
2
+ *********************************
3
3
 
4
4
  An MPD (Music Player Daemon) client library written in pure Python.
5
5
 
@@ -1,5 +1,5 @@
1
- .. SPDX-FileCopyrightText: 2018-2021 kaliko <kaliko@azylum.org>
2
- .. SPDX-License-Identifier: GPL-3.0-or-later
1
+ .. SPDX-FileCopyrightText: 2018-2023 kaliko <kaliko@azylum.org>
2
+ .. SPDX-License-Identifier: LGPL-3.0-or-later
3
3
 
4
4
  .. _commands:
5
5
 
@@ -13,7 +13,6 @@ Get current available commands:
13
13
  import musicpd
14
14
  print(' '.join([cmd for cmd in musicpd.MPDClient()._commands.keys()]))
15
15
 
16
-
17
- List, last updated for v0.6.0:
16
+ List, last updated for v0.8.0:
18
17
 
19
18
  .. literalinclude:: commands.txt
@@ -7,7 +7,7 @@ status -> fetch_object
7
7
  stats -> fetch_object
8
8
 
9
9
  == Playback Option Commands
10
- consume <bool> -> fetch_nothing
10
+ consume <str> -> fetch_nothing
11
11
  crossfade <int> -> fetch_nothing
12
12
  mixrampdb <str> -> fetch_nothing
13
13
  mixrampdelay <int> -> fetch_nothing
@@ -133,3 +133,10 @@ commands -> fetch_list
133
133
  notcommands -> fetch_list
134
134
  urlhandlers -> fetch_list
135
135
  decoders -> fetch_plugins
136
+
137
+ == Client to Client
138
+ subscribe <str> -> self._fetch_nothing,
139
+ unsubscribe <str> -> self._fetch_nothing,
140
+ channels -> self._fetch_list,
141
+ readmessages -> self._fetch_messages,
142
+ sendmessage <str> <str> -> self._fetch_nothing,
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  # SPDX-FileCopyrightText: 2018-2021 kaliko <kaliko@azylum.org>
3
- # SPDX-License-Identifier: GPL-3.0-or-later
3
+ # SPDX-License-Identifier: LGPL-3.0-or-later
4
4
  #
5
5
  # Python MPD Module documentation build configuration file, created by
6
6
  # sphinx-quickstart on Mon Mar 12 14:37:32 2018.
@@ -76,7 +76,7 @@ release = VERSION
76
76
  #
77
77
  # This is also used if you do content translation via gettext catalogs.
78
78
  # Usually you set "language" from the command line for these cases.
79
- language = None
79
+ #language = None
80
80
 
81
81
  # There are two options for replacing |today|: either, you set today to some
82
82
  # non-false value, then it is used:
@@ -438,7 +438,7 @@ epub_exclude_files = ['search.html']
438
438
 
439
439
 
440
440
  # Example configuration for intersphinx: refer to the Python standard library.
441
- intersphinx_mapping = {'https://docs.python.org/': None}
441
+ intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
442
442
 
443
443
  # autodoc config
444
444
  autodoc_member_order = 'bysource'
@@ -1,5 +1,5 @@
1
1
  .. SPDX-FileCopyrightText: 2018-2021 kaliko <kaliko@azylum.org>
2
- .. SPDX-License-Identifier: GPL-3.0-or-later
2
+ .. SPDX-License-Identifier: LGPL-3.0-or-later
3
3
 
4
4
  Contributing
5
5
  =============
@@ -0,0 +1,12 @@
1
+ .. SPDX-FileCopyrightText: 2018-2023 kaliko <kaliko@azylum.org>
2
+ .. SPDX-License-Identifier: LGPL-3.0-or-later
3
+
4
+ musicpd namespace
5
+ =================
6
+
7
+ .. automodule:: musicpd
8
+ :members:
9
+ :no-undoc-members:
10
+
11
+
12
+ .. vim: spell spelllang=en
@@ -0,0 +1,94 @@
1
+ """Plain client class
2
+ """
3
+ import logging
4
+ import select
5
+ import sys
6
+
7
+ import musicpd
8
+
9
+
10
+ class MyClient(musicpd.MPDClient):
11
+ """Plain client inheriting from MPDClient"""
12
+
13
+ def __init__(self):
14
+ # Set logging to debug level
15
+ logging.basicConfig(level=logging.DEBUG,
16
+ format='%(levelname)-8s %(module)-8s %(message)s')
17
+ self.log = logging.getLogger(__name__)
18
+ super().__init__()
19
+ # Set host/port/password after init to overrides defaults
20
+ # self.host = 'example.org'
21
+ # self.port = 4242
22
+ # self.pwd = 'secret'
23
+
24
+ def connect(self):
25
+ """Overriding explicitly MPDClient.connect()"""
26
+ try:
27
+ super().connect(host=self.host, port=self.port)
28
+ if hasattr(self, 'pwd') and self.pwd:
29
+ self.password(self.pwd)
30
+ except musicpd.ConnectionError as err:
31
+ # Catch socket error
32
+ self.log.error('Failed to connect: %s', err)
33
+ sys.exit(42)
34
+
35
+ def _wait_for_changes(self, callback):
36
+ select_timeout = 10 # second
37
+ while True:
38
+ self.send_idle() # use send_ API to avoid blocking on read
39
+ _read, _, _ = select.select([self], [], [], select_timeout)
40
+ if _read: # tries to read response
41
+ ret = self.fetch_idle()
42
+ # do something
43
+ callback(ret)
44
+ else: # cancels idle
45
+ self.noidle()
46
+
47
+ def callback(self, *args):
48
+ """Method launch on MPD event, cf. monitor method"""
49
+ self.log.info('%s', args)
50
+
51
+ def monitor(self):
52
+ """Continuously monitor MPD activity.
53
+ Launch callback method on event.
54
+ """
55
+ try:
56
+ self._wait_for_changes(self.callback)
57
+ except (OSError, musicpd.MPDError) as err:
58
+ self.log.error('%s: Something went wrong: %s',
59
+ type(err).__name__, err)
60
+
61
+ if __name__ == '__main__':
62
+ cli = MyClient()
63
+ # You can overrides host here or in init
64
+ #cli.host = 'example.org'
65
+ # Connect MPD server
66
+ try:
67
+ cli.connect()
68
+ except musicpd.ConnectionError as err:
69
+ cli.log.error(err)
70
+
71
+ # Monitor MPD changes, blocking/timeout idle approach
72
+ try:
73
+ cli.socket_timeout = 20 # seconds
74
+ ret = cli.idle()
75
+ cli.log.info('Leaving idle, got: %s', ret)
76
+ except TimeoutError as err:
77
+ cli.log.info('Nothing occured the last %ss', cli.socket_timeout)
78
+
79
+ # Reset connection
80
+ try:
81
+ cli.socket_timeout = None
82
+ cli.disconnect()
83
+ cli.connect()
84
+ except musicpd.ConnectionError as err:
85
+ cli.log.error(err)
86
+
87
+ # Monitor MPD changes, non blocking idle approach
88
+ try:
89
+ cli.monitor()
90
+ except KeyboardInterrupt as err:
91
+ cli.log.info(type(err).__name__)
92
+ cli.send_noidle()
93
+ cli.disconnect()
94
+
@@ -0,0 +1,29 @@
1
+ import logging
2
+
3
+ import musicpd
4
+
5
+ # Set logging to debug level
6
+ # it should log messages showing where defaults come from
7
+ logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s')
8
+ log = logging.getLogger()
9
+
10
+ client = musicpd.MPDClient()
11
+ # use MPD_HOST/MPD_PORT env var if set else
12
+ # test ${XDG_RUNTIME_DIR}/mpd/socket for existence
13
+ # fallback to localhost:6600
14
+ # connect support host/port argument as well
15
+ client.connect()
16
+
17
+ status = client.status()
18
+ if status.get('state') == 'play':
19
+ current_song_id = status.get('songid')
20
+ current_song = client.playlistid(current_song_id)[0]
21
+ log.info(f'Playing : {current_song.get("file")}')
22
+ next_song_id = status.get('nextsongid', None)
23
+ if next_song_id:
24
+ next_song = client.playlistid(next_song_id)[0]
25
+ log.info(f'Next song : {next_song.get("file")}')
26
+ else:
27
+ log.info('Not playing')
28
+
29
+ client.disconnect()
@@ -0,0 +1,17 @@
1
+ import sys
2
+ import logging
3
+
4
+ import musicpd
5
+
6
+ # Set logging to debug level
7
+ logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s')
8
+
9
+ client = musicpd.MPDClient()
10
+ try:
11
+ client.connect(host='example.lan')
12
+ client.password('secret')
13
+ client.status()
14
+ except musicpd.MPDError as err:
15
+ print(f'An error occured: {err}')
16
+ finally:
17
+ client.disconnect()
@@ -0,0 +1,59 @@
1
+ """client class dealing with all Exceptions
2
+ """
3
+ import logging
4
+
5
+ import musicpd
6
+
7
+
8
+ # Wrap Exception decorator
9
+ def wrapext(func):
10
+ """Decorator to wrap errors in musicpd.MPDError"""
11
+ errors=(OSError, TimeoutError)
12
+ into = musicpd.MPDError
13
+ def w_func(*args, **kwargs):
14
+ try:
15
+ return func(*args, **kwargs)
16
+ except errors as err:
17
+ strerr = str(err)
18
+ if hasattr(err, 'strerror'):
19
+ if err.strerror:
20
+ strerr = err.strerror
21
+ raise into(strerr) from err
22
+ return w_func
23
+
24
+
25
+ class MyClient(musicpd.MPDClient):
26
+ """Plain client inheriting from MPDClient"""
27
+
28
+ def __init__(self):
29
+ # Set logging to debug level
30
+ logging.basicConfig(level=logging.DEBUG,
31
+ format='%(levelname)-8s %(module)-10s %(message)s')
32
+ self.log = logging.getLogger(__name__)
33
+ super().__init__()
34
+
35
+ @wrapext
36
+ def __getattr__(self, cmd):
37
+ """Wrapper around MPDClient calls for abstract overriding"""
38
+ self.log.debug('cmd: %s', cmd)
39
+ return super().__getattr__(cmd)
40
+
41
+
42
+ if __name__ == '__main__':
43
+ cli = MyClient()
44
+ # You can overrides host here or in init
45
+ #cli.host = 'example.org'
46
+ # Connect MPD server
47
+ try:
48
+ cli.connect()
49
+ cli.currentsong()
50
+ cli.stats()
51
+ except musicpd.MPDError as error:
52
+ cli.log.fatal(error)
53
+ finally:
54
+ cli.log.info('Disconnecting')
55
+ try:
56
+ # Tries to close the socket anyway
57
+ cli.disconnect()
58
+ except OSError:
59
+ pass
@@ -0,0 +1,8 @@
1
+ import musicpd
2
+
3
+ # Using a context manager
4
+ # (use env var if you need to override default host)
5
+ with musicpd.MPDClient() as client:
6
+ client.clear()
7
+ client.findadd("(artist == 'Monkey3')")
8
+ client.play()
@@ -0,0 +1,7 @@
1
+ import musicpd
2
+
3
+ # Using a context manager
4
+ # (use env var if you need to override default host)
5
+ with musicpd.MPDClient() as client:
6
+ client.play()
7
+ client.setvol('80')
@@ -0,0 +1,57 @@
1
+ .. SPDX-FileCopyrightText: 2018-2023 kaliko <kaliko@azylum.org>
2
+ .. SPDX-License-Identifier: LGPL-3.0-or-later
3
+
4
+ .. _examples:
5
+
6
+ Examples
7
+ ========
8
+
9
+ Plain examples
10
+ --------------
11
+
12
+ Connect, if playing, get currently playing track, the next one:
13
+
14
+ .. literalinclude:: examples/connect.py
15
+ :language: python
16
+ :linenos:
17
+
18
+ Connect a specific password protected host:
19
+
20
+ .. literalinclude:: examples/connect_host.py
21
+ :language: python
22
+ :linenos:
23
+
24
+ Start playing current queue and set the volume:
25
+
26
+ .. literalinclude:: examples/playback.py
27
+ :language: python
28
+ :linenos:
29
+
30
+ Clear the queue, search artist, queue what's found and play:
31
+
32
+ .. literalinclude:: examples/findadd.py
33
+ :language: python
34
+ :linenos:
35
+
36
+ Object Oriented example
37
+ -----------------------
38
+
39
+ A plain client monitoring changes on MPD.
40
+
41
+ .. literalinclude:: examples/client.py
42
+ :language: python
43
+ :linenos:
44
+
45
+ .. _exceptions_example:
46
+
47
+ Dealing with Exceptions
48
+ -----------------------
49
+
50
+ Musicpd module will raise it's own :py:obj:`MPDError<musicpd.MPDError>`
51
+ exceptions **and** python :py:obj:`OSError`. Then you can wrap
52
+ :py:obj:`OSError` in :py:obj:`MPDError<musicpd.MPDError>` exceptions to have to deal
53
+ with a single type of exceptions in your code:
54
+
55
+ .. literalinclude:: examples/exceptions.py
56
+ :language: python
57
+ :linenos:
@@ -1,5 +1,5 @@
1
- .. SPDX-FileCopyrightText: 2018-2021 kaliko <kaliko@azylum.org>
2
- .. SPDX-License-Identifier: GPL-3.0-or-later
1
+ .. SPDX-FileCopyrightText: 2018-2023 kaliko <kaliko@azylum.org>
2
+ .. SPDX-License-Identifier: LGPL-3.0-or-later
3
3
 
4
4
  .. include:: ../../README.rst
5
5
 
@@ -20,7 +20,7 @@ Installation
20
20
 
21
21
 
22
22
  Library overview
23
- ----------------
23
+ ================
24
24
  Here is a snippet allowing to list the last modified artists in the media library:
25
25
 
26
26
  .. code:: python3
@@ -46,7 +46,7 @@ Here is a snippet allowing to list the last modified artists in the media librar
46
46
 
47
47
 
48
48
  Build documentation
49
- --------------------
49
+ ===================
50
50
 
51
51
  .. code:: bash
52
52
 
@@ -55,9 +55,7 @@ Build documentation
55
55
  # Installs sphinx if needed
56
56
  python3 -m venv venv && . ./venv/bin/activate
57
57
  pip install sphinx
58
- # And build
59
- python3 setup.py build_sphinx
60
- # Or call sphinx
58
+ # Call sphinx
61
59
  sphinx-build -d ./doc/build/doctrees doc/source -b html ./doc/build/html
62
60
 
63
61
 
@@ -67,9 +65,11 @@ Contents
67
65
  .. toctree::
68
66
  :maxdepth: 2
69
67
 
68
+ self
70
69
  use.rst
71
70
  doc.rst
72
71
  commands.rst
72
+ examples.rst
73
73
  contribute.rst
74
74
 
75
75