python-mpv-jsonipc 1.2.0__tar.gz → 1.2.1__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.
- python-mpv-jsonipc-1.2.1/LICENSE.md +195 -0
- python-mpv-jsonipc-1.2.1/PKG-INFO +71 -0
- python-mpv-jsonipc-1.2.1/python_mpv_jsonipc.egg-info/PKG-INFO +71 -0
- {python-mpv-jsonipc-1.2.0 → python-mpv-jsonipc-1.2.1}/python_mpv_jsonipc.egg-info/SOURCES.txt +1 -0
- {python-mpv-jsonipc-1.2.0 → python-mpv-jsonipc-1.2.1}/python_mpv_jsonipc.py +22 -21
- {python-mpv-jsonipc-1.2.0 → python-mpv-jsonipc-1.2.1}/setup.py +9 -9
- python-mpv-jsonipc-1.2.0/PKG-INFO +0 -71
- python-mpv-jsonipc-1.2.0/python_mpv_jsonipc.egg-info/PKG-INFO +0 -71
- {python-mpv-jsonipc-1.2.0 → python-mpv-jsonipc-1.2.1}/README.md +0 -0
- {python-mpv-jsonipc-1.2.0 → python-mpv-jsonipc-1.2.1}/python_mpv_jsonipc.egg-info/dependency_links.txt +0 -0
- {python-mpv-jsonipc-1.2.0 → python-mpv-jsonipc-1.2.1}/python_mpv_jsonipc.egg-info/top_level.txt +0 -0
- {python-mpv-jsonipc-1.2.0 → python-mpv-jsonipc-1.2.1}/setup.cfg +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
_Version 2.0, January 2004_
|
|
5
|
+
_<<http://www.apache.org/licenses/>>_
|
|
6
|
+
|
|
7
|
+
### Terms and Conditions for use, reproduction, and distribution
|
|
8
|
+
|
|
9
|
+
#### 1. Definitions
|
|
10
|
+
|
|
11
|
+
“License” shall mean the terms and conditions for use, reproduction, and
|
|
12
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
“Licensor” shall mean the copyright owner or entity authorized by the copyright
|
|
15
|
+
owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
“Legal Entity” shall mean the union of the acting entity and all other entities
|
|
18
|
+
that control, are controlled by, or are under common control with that entity.
|
|
19
|
+
For the purposes of this definition, “control” means **(i)** the power, direct or
|
|
20
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
21
|
+
contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or **(iii)** beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
“You” (or “Your”) shall mean an individual or Legal Entity exercising
|
|
25
|
+
permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
“Source” form shall mean the preferred form for making modifications, including
|
|
28
|
+
but not limited to software source code, documentation source, and configuration
|
|
29
|
+
files.
|
|
30
|
+
|
|
31
|
+
“Object” form shall mean any form resulting from mechanical transformation or
|
|
32
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
33
|
+
generated documentation, and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
“Work” shall mean the work of authorship, whether in Source or Object form, made
|
|
36
|
+
available under the License, as indicated by a copyright notice that is included
|
|
37
|
+
in or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
“Derivative Works” shall mean any work, whether in Source or Object form, that
|
|
40
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
41
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
42
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
43
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
44
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
45
|
+
|
|
46
|
+
“Contribution” shall mean any work of authorship, including the original version
|
|
47
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
48
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
49
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
50
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
51
|
+
“submitted” means any form of electronic, verbal, or written communication sent
|
|
52
|
+
to the Licensor or its representatives, including but not limited to
|
|
53
|
+
communication on electronic mailing lists, source code control systems, and
|
|
54
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
55
|
+
the purpose of discussing and improving the Work, but excluding communication
|
|
56
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
57
|
+
owner as “Not a Contribution.”
|
|
58
|
+
|
|
59
|
+
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
|
|
60
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
61
|
+
incorporated within the Work.
|
|
62
|
+
|
|
63
|
+
#### 2. Grant of Copyright License
|
|
64
|
+
|
|
65
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
66
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
67
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
68
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
69
|
+
Derivative Works in Source or Object form.
|
|
70
|
+
|
|
71
|
+
#### 3. Grant of Patent License
|
|
72
|
+
|
|
73
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
74
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
75
|
+
irrevocable (except as stated in this section) patent license to make, have
|
|
76
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
77
|
+
such license applies only to those patent claims licensable by such Contributor
|
|
78
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
79
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
80
|
+
submitted. If You institute patent litigation against any entity (including a
|
|
81
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
82
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
|
83
|
+
patent infringement, then any patent licenses granted to You under this License
|
|
84
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
85
|
+
|
|
86
|
+
#### 4. Redistribution
|
|
87
|
+
|
|
88
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
89
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
90
|
+
provided that You meet the following conditions:
|
|
91
|
+
|
|
92
|
+
* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
|
|
93
|
+
this License; and
|
|
94
|
+
* **(b)** You must cause any modified files to carry prominent notices stating that You
|
|
95
|
+
changed the files; and
|
|
96
|
+
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
|
|
97
|
+
all copyright, patent, trademark, and attribution notices from the Source form
|
|
98
|
+
of the Work, excluding those notices that do not pertain to any part of the
|
|
99
|
+
Derivative Works; and
|
|
100
|
+
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
|
|
101
|
+
Derivative Works that You distribute must include a readable copy of the
|
|
102
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
103
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
104
|
+
following places: within a NOTICE text file distributed as part of the
|
|
105
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
106
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
107
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
108
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
109
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
110
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
111
|
+
provided that such additional attribution notices cannot be construed as
|
|
112
|
+
modifying the License.
|
|
113
|
+
|
|
114
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
115
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
116
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
117
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
118
|
+
with the conditions stated in this License.
|
|
119
|
+
|
|
120
|
+
#### 5. Submission of Contributions
|
|
121
|
+
|
|
122
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
123
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
124
|
+
conditions of this License, without any additional terms or conditions.
|
|
125
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
126
|
+
any separate license agreement you may have executed with Licensor regarding
|
|
127
|
+
such Contributions.
|
|
128
|
+
|
|
129
|
+
#### 6. Trademarks
|
|
130
|
+
|
|
131
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
132
|
+
service marks, or product names of the Licensor, except as required for
|
|
133
|
+
reasonable and customary use in describing the origin of the Work and
|
|
134
|
+
reproducing the content of the NOTICE file.
|
|
135
|
+
|
|
136
|
+
#### 7. Disclaimer of Warranty
|
|
137
|
+
|
|
138
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
139
|
+
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
|
140
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
141
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
142
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
143
|
+
solely responsible for determining the appropriateness of using or
|
|
144
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
145
|
+
permissions under this License.
|
|
146
|
+
|
|
147
|
+
#### 8. Limitation of Liability
|
|
148
|
+
|
|
149
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
150
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
151
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
152
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
153
|
+
or consequential damages of any character arising as a result of this License or
|
|
154
|
+
out of the use or inability to use the Work (including but not limited to
|
|
155
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
156
|
+
any and all other commercial damages or losses), even if such Contributor has
|
|
157
|
+
been advised of the possibility of such damages.
|
|
158
|
+
|
|
159
|
+
#### 9. Accepting Warranty or Additional Liability
|
|
160
|
+
|
|
161
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
162
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
163
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
164
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
165
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
166
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
167
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
168
|
+
accepting any such warranty or additional liability.
|
|
169
|
+
|
|
170
|
+
_END OF TERMS AND CONDITIONS_
|
|
171
|
+
|
|
172
|
+
### APPENDIX: How to apply the Apache License to your work
|
|
173
|
+
|
|
174
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
175
|
+
notice, with the fields enclosed by brackets `[]` replaced with your own
|
|
176
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
177
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
178
|
+
recommend that a file or class name and description of purpose be included on
|
|
179
|
+
the same “printed page” as the copyright notice for easier identification within
|
|
180
|
+
third-party archives.
|
|
181
|
+
|
|
182
|
+
Copyright [yyyy] [name of copyright owner]
|
|
183
|
+
|
|
184
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
185
|
+
you may not use this file except in compliance with the License.
|
|
186
|
+
You may obtain a copy of the License at
|
|
187
|
+
|
|
188
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
189
|
+
|
|
190
|
+
Unless required by applicable law or agreed to in writing, software
|
|
191
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
192
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
193
|
+
See the License for the specific language governing permissions and
|
|
194
|
+
limitations under the License.
|
|
195
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: python-mpv-jsonipc
|
|
3
|
+
Version: 1.2.1
|
|
4
|
+
Summary: Python API to MPV using JSON IPC
|
|
5
|
+
Home-page: https://github.com/iwalton3/python-mpv-jsonipc
|
|
6
|
+
Author: Izzie Walton
|
|
7
|
+
Author-email: izzie@iwalton.com
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE.md
|
|
15
|
+
|
|
16
|
+
# Python MPV JSONIPC
|
|
17
|
+
|
|
18
|
+
This implements an interface similar to `python-mpv`, but it uses the JSON IPC protocol instead of the C API. This means
|
|
19
|
+
you can control external instances of MPV including players like SMPlayer, and it can use MPV players that are prebuilt
|
|
20
|
+
instead of needing `libmpv1`. It may also be more resistant to crashes such as Segmentation Faults, but since it isn't
|
|
21
|
+
directly communicating with MPV via the C API the performance will be worse.
|
|
22
|
+
|
|
23
|
+
Please note that this only implements the subset of `python-mpv` that is used by `plex-mpv-shim` and
|
|
24
|
+
`jellyfin-mpv-shim`. Other functionality has not been implemented.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
sudo pip3 install python-mpv-jsonipc
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Basic usage
|
|
33
|
+
|
|
34
|
+
Create an instance of MPV. You can use an already running MPV or have the library start a
|
|
35
|
+
managed copy of MPV. Command arguments can be specified when initializing MPV if you are
|
|
36
|
+
starting a managed copy of MPV.
|
|
37
|
+
|
|
38
|
+
Please also see the [API Documentation](https://github.com/iwalton3/python-mpv-jsonipc/blob/master/docs.md).
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from python_mpv_jsonipc import MPV
|
|
42
|
+
|
|
43
|
+
# Uses MPV that is in the PATH.
|
|
44
|
+
mpv = MPV()
|
|
45
|
+
|
|
46
|
+
# Use MPV that is running and connected to /tmp/mpv-socket.
|
|
47
|
+
mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv-socket")
|
|
48
|
+
|
|
49
|
+
# Uses MPV that is found at /path/to/mpv.
|
|
50
|
+
mpv = MPV(mpv_location="/path/to/mpv")
|
|
51
|
+
|
|
52
|
+
# After you have an MPV, you can read and set (if applicable) properties.
|
|
53
|
+
mpv.volume # 100.0 by default
|
|
54
|
+
mpv.volume = 20
|
|
55
|
+
|
|
56
|
+
# You can also send commands.
|
|
57
|
+
mpv.command_name(arg1, arg2)
|
|
58
|
+
|
|
59
|
+
# Bind to key press events with a decorator
|
|
60
|
+
@mpv.on_key_press("space")
|
|
61
|
+
def space_handler():
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
# You can also observe and wait for properties.
|
|
65
|
+
@mpv.property_observer("eof-reached")
|
|
66
|
+
def handle_eof(name, value):
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
# Or simply wait for the value to change once.
|
|
70
|
+
mpv.wait_for_property("duration")
|
|
71
|
+
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: python-mpv-jsonipc
|
|
3
|
+
Version: 1.2.1
|
|
4
|
+
Summary: Python API to MPV using JSON IPC
|
|
5
|
+
Home-page: https://github.com/iwalton3/python-mpv-jsonipc
|
|
6
|
+
Author: Izzie Walton
|
|
7
|
+
Author-email: izzie@iwalton.com
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE.md
|
|
15
|
+
|
|
16
|
+
# Python MPV JSONIPC
|
|
17
|
+
|
|
18
|
+
This implements an interface similar to `python-mpv`, but it uses the JSON IPC protocol instead of the C API. This means
|
|
19
|
+
you can control external instances of MPV including players like SMPlayer, and it can use MPV players that are prebuilt
|
|
20
|
+
instead of needing `libmpv1`. It may also be more resistant to crashes such as Segmentation Faults, but since it isn't
|
|
21
|
+
directly communicating with MPV via the C API the performance will be worse.
|
|
22
|
+
|
|
23
|
+
Please note that this only implements the subset of `python-mpv` that is used by `plex-mpv-shim` and
|
|
24
|
+
`jellyfin-mpv-shim`. Other functionality has not been implemented.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
sudo pip3 install python-mpv-jsonipc
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Basic usage
|
|
33
|
+
|
|
34
|
+
Create an instance of MPV. You can use an already running MPV or have the library start a
|
|
35
|
+
managed copy of MPV. Command arguments can be specified when initializing MPV if you are
|
|
36
|
+
starting a managed copy of MPV.
|
|
37
|
+
|
|
38
|
+
Please also see the [API Documentation](https://github.com/iwalton3/python-mpv-jsonipc/blob/master/docs.md).
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from python_mpv_jsonipc import MPV
|
|
42
|
+
|
|
43
|
+
# Uses MPV that is in the PATH.
|
|
44
|
+
mpv = MPV()
|
|
45
|
+
|
|
46
|
+
# Use MPV that is running and connected to /tmp/mpv-socket.
|
|
47
|
+
mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv-socket")
|
|
48
|
+
|
|
49
|
+
# Uses MPV that is found at /path/to/mpv.
|
|
50
|
+
mpv = MPV(mpv_location="/path/to/mpv")
|
|
51
|
+
|
|
52
|
+
# After you have an MPV, you can read and set (if applicable) properties.
|
|
53
|
+
mpv.volume # 100.0 by default
|
|
54
|
+
mpv.volume = 20
|
|
55
|
+
|
|
56
|
+
# You can also send commands.
|
|
57
|
+
mpv.command_name(arg1, arg2)
|
|
58
|
+
|
|
59
|
+
# Bind to key press events with a decorator
|
|
60
|
+
@mpv.on_key_press("space")
|
|
61
|
+
def space_handler():
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
# You can also observe and wait for properties.
|
|
65
|
+
@mpv.property_observer("eof-reached")
|
|
66
|
+
def handle_eof(name, value):
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
# Or simply wait for the value to change once.
|
|
70
|
+
mpv.wait_for_property("duration")
|
|
71
|
+
```
|
|
@@ -38,7 +38,7 @@ class MPVError(Exception):
|
|
|
38
38
|
class WindowsSocket(threading.Thread):
|
|
39
39
|
"""
|
|
40
40
|
Wraps a Windows named pipe in a high-level interface. (Internal)
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
Data is automatically encoded and decoded as JSON. The callback
|
|
43
43
|
function will be called for each inbound message.
|
|
44
44
|
"""
|
|
@@ -52,7 +52,7 @@ class WindowsSocket(threading.Thread):
|
|
|
52
52
|
ipc_socket = "\\\\.\\pipe\\" + ipc_socket
|
|
53
53
|
self.callback = callback
|
|
54
54
|
self.quit_callback = quit_callback
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
access = _winapi.GENERIC_READ | _winapi.GENERIC_WRITE
|
|
57
57
|
limit = 5 # Connection may fail at first. Try 5 times.
|
|
58
58
|
for _ in range(limit):
|
|
@@ -123,7 +123,7 @@ class WindowsSocket(threading.Thread):
|
|
|
123
123
|
class UnixSocket(threading.Thread):
|
|
124
124
|
"""
|
|
125
125
|
Wraps a Unix/Linux socket in a high-level interface. (Internal)
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
Data is automatically encoded and decoded as JSON. The callback
|
|
128
128
|
function will be called for each inbound message.
|
|
129
129
|
"""
|
|
@@ -206,7 +206,7 @@ class MPVProcess:
|
|
|
206
206
|
mpv_location = "mpv.exe"
|
|
207
207
|
else:
|
|
208
208
|
mpv_location = "mpv"
|
|
209
|
-
|
|
209
|
+
|
|
210
210
|
log.debug("Staring MPV from {0}.".format(mpv_location))
|
|
211
211
|
ipc_socket_name = ipc_socket
|
|
212
212
|
if os.name == 'nt':
|
|
@@ -248,7 +248,7 @@ class MPVProcess:
|
|
|
248
248
|
else:
|
|
249
249
|
self.process.terminate()
|
|
250
250
|
raise MPVError("MPV start timed out.")
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
if not ipc_exists or self.process.returncode is not None:
|
|
253
253
|
self.process.terminate()
|
|
254
254
|
raise MPVError("MPV not started.")
|
|
@@ -290,7 +290,7 @@ class MPVInter:
|
|
|
290
290
|
self.quit_callback = quit_callback
|
|
291
291
|
if self.callback is None:
|
|
292
292
|
self.callback = lambda event, data: None
|
|
293
|
-
|
|
293
|
+
|
|
294
294
|
self.socket = Socket(ipc_socket, self.event_callback, self.quit_callback)
|
|
295
295
|
self.socket.start()
|
|
296
296
|
self.command_id = 1
|
|
@@ -298,7 +298,7 @@ class MPVInter:
|
|
|
298
298
|
self.socket_lock = threading.Lock()
|
|
299
299
|
self.cid_result = {}
|
|
300
300
|
self.cid_wait = {}
|
|
301
|
-
|
|
301
|
+
|
|
302
302
|
def stop(self, join=True):
|
|
303
303
|
"""Terminate the underlying connection."""
|
|
304
304
|
self.socket.stop(join)
|
|
@@ -310,11 +310,11 @@ class MPVInter:
|
|
|
310
310
|
self.cid_wait[data["request_id"]].set()
|
|
311
311
|
elif "event" in data:
|
|
312
312
|
self.callback(data["event"], data)
|
|
313
|
-
|
|
313
|
+
|
|
314
314
|
def command(self, command, *args):
|
|
315
315
|
"""
|
|
316
316
|
Issue a command to MPV. Will block until completed or timeout is reached.
|
|
317
|
-
|
|
317
|
+
|
|
318
318
|
*command* is the name of the MPV command
|
|
319
319
|
|
|
320
320
|
All further arguments are forwarded to the MPV command.
|
|
@@ -356,13 +356,13 @@ class EventHandler(threading.Thread):
|
|
|
356
356
|
"""Create an instance of the thread."""
|
|
357
357
|
self.queue = queue.Queue()
|
|
358
358
|
threading.Thread.__init__(self)
|
|
359
|
-
|
|
359
|
+
|
|
360
360
|
def put_task(self, func, *args):
|
|
361
361
|
"""
|
|
362
362
|
Put a new task to the thread.
|
|
363
|
-
|
|
363
|
+
|
|
364
364
|
*func* is the function to call
|
|
365
|
-
|
|
365
|
+
|
|
366
366
|
All further arguments are forwarded to *func*.
|
|
367
367
|
"""
|
|
368
368
|
self.queue.put((func, args))
|
|
@@ -386,15 +386,15 @@ class EventHandler(threading.Thread):
|
|
|
386
386
|
class MPV:
|
|
387
387
|
"""
|
|
388
388
|
The main MPV interface class. Use this to control MPV.
|
|
389
|
-
|
|
389
|
+
|
|
390
390
|
This will expose all mpv commands as callable methods and all properties.
|
|
391
391
|
You can set properties and call the commands directly.
|
|
392
|
-
|
|
392
|
+
|
|
393
393
|
Please note that if you are using a really old MPV version, a fallback command
|
|
394
394
|
list is used. Not all commands may actually work when this fallback is used.
|
|
395
395
|
"""
|
|
396
396
|
def __init__(self, start_mpv=True, ipc_socket=None, mpv_location=None,
|
|
397
|
-
log_handler=None, loglevel=None, quit_callback=None, **kwargs):
|
|
397
|
+
log_handler=None, loglevel=None, quit_callback=None, start_retries=5, start_retry_delay_ms=1000, **kwargs):
|
|
398
398
|
"""
|
|
399
399
|
Create the interface to MPV and process instance.
|
|
400
400
|
|
|
@@ -424,13 +424,14 @@ class MPV:
|
|
|
424
424
|
ipc_socket = "/tmp/{0}".format(rand_file)
|
|
425
425
|
|
|
426
426
|
if start_mpv:
|
|
427
|
-
# Attempt to start MPV
|
|
428
|
-
for i in range(
|
|
427
|
+
# Attempt to start MPV multiple times.
|
|
428
|
+
for i in range(start_retries):
|
|
429
429
|
try:
|
|
430
430
|
self.mpv_process = MPVProcess(ipc_socket, mpv_location, **kwargs)
|
|
431
431
|
break
|
|
432
432
|
except MPVError:
|
|
433
433
|
log.warning("MPV start failed.", exc_info=1)
|
|
434
|
+
time.sleep(start_retry_delay_ms / 1000)
|
|
434
435
|
continue
|
|
435
436
|
else:
|
|
436
437
|
raise MPVError("MPV process retry limit reached.")
|
|
@@ -455,7 +456,7 @@ class MPV:
|
|
|
455
456
|
self.observer_lock = threading.Lock()
|
|
456
457
|
self.keybind_id = 1
|
|
457
458
|
self.keybind_lock = threading.Lock()
|
|
458
|
-
|
|
459
|
+
|
|
459
460
|
if log_handler is not None and loglevel is not None:
|
|
460
461
|
self.command("request_log_messages", loglevel)
|
|
461
462
|
@self.on_event("log-message")
|
|
@@ -582,7 +583,7 @@ class MPV:
|
|
|
582
583
|
self.bind_property_observer(name, func)
|
|
583
584
|
return func
|
|
584
585
|
return wrapper
|
|
585
|
-
|
|
586
|
+
|
|
586
587
|
def wait_for_property(self, name):
|
|
587
588
|
"""
|
|
588
589
|
Waits for the value of a property to change.
|
|
@@ -630,11 +631,11 @@ class MPV:
|
|
|
630
631
|
"""
|
|
631
632
|
Send a command to MPV. All commands are bound to the class by default,
|
|
632
633
|
except JSON IPC specific commands. This may also be useful to retain
|
|
633
|
-
compatibility with python-mpv, as it does not bind all of the commands.
|
|
634
|
+
compatibility with python-mpv, as it does not bind all of the commands.
|
|
634
635
|
|
|
635
636
|
*command* is the command name.
|
|
636
637
|
|
|
637
|
-
All further arguments are forwarded to the MPV command.
|
|
638
|
+
All further arguments are forwarded to the MPV command.
|
|
638
639
|
"""
|
|
639
640
|
return self.mpv_inter.command(command, *args)
|
|
640
641
|
|
|
@@ -5,21 +5,21 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
long_description = fh.read()
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
|
-
name=
|
|
9
|
-
version=
|
|
10
|
-
author="
|
|
11
|
-
author_email="
|
|
8
|
+
name="python-mpv-jsonipc",
|
|
9
|
+
version="1.2.1",
|
|
10
|
+
author="Izzie Walton",
|
|
11
|
+
author_email="izzie@iwalton.com",
|
|
12
12
|
description="Python API to MPV using JSON IPC",
|
|
13
|
-
license=
|
|
14
|
-
long_description=open(
|
|
13
|
+
license="Apache-2.0",
|
|
14
|
+
long_description=open("README.md").read(),
|
|
15
15
|
long_description_content_type="text/markdown",
|
|
16
16
|
url="https://github.com/iwalton3/python-mpv-jsonipc",
|
|
17
|
-
py_modules=[
|
|
17
|
+
py_modules=["python_mpv_jsonipc"],
|
|
18
18
|
classifiers=[
|
|
19
19
|
"Programming Language :: Python :: 3",
|
|
20
20
|
"License :: OSI Approved :: Apache Software License",
|
|
21
21
|
"Operating System :: OS Independent",
|
|
22
22
|
],
|
|
23
|
-
python_requires=
|
|
24
|
-
install_requires=[]
|
|
23
|
+
python_requires=">=3.6",
|
|
24
|
+
install_requires=[],
|
|
25
25
|
)
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: python-mpv-jsonipc
|
|
3
|
-
Version: 1.2.0
|
|
4
|
-
Summary: Python API to MPV using JSON IPC
|
|
5
|
-
Home-page: https://github.com/iwalton3/python-mpv-jsonipc
|
|
6
|
-
Author: Ian Walton
|
|
7
|
-
Author-email: iwalton3@gmail.com
|
|
8
|
-
License: Apache-2.0
|
|
9
|
-
Description: # Python MPV JSONIPC
|
|
10
|
-
|
|
11
|
-
This implements an interface similar to `python-mpv`, but it uses the JSON IPC protocol instead of the C API. This means
|
|
12
|
-
you can control external instances of MPV including players like SMPlayer, and it can use MPV players that are prebuilt
|
|
13
|
-
instead of needing `libmpv1`. It may also be more resistant to crashes such as Segmentation Faults, but since it isn't
|
|
14
|
-
directly communicating with MPV via the C API the performance will be worse.
|
|
15
|
-
|
|
16
|
-
Please note that this only implements the subset of `python-mpv` that is used by `plex-mpv-shim` and
|
|
17
|
-
`jellyfin-mpv-shim`. Other functionality has not been implemented.
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
sudo pip3 install python-mpv-jsonipc
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Basic usage
|
|
26
|
-
|
|
27
|
-
Create an instance of MPV. You can use an already running MPV or have the library start a
|
|
28
|
-
managed copy of MPV. Command arguments can be specified when initializing MPV if you are
|
|
29
|
-
starting a managed copy of MPV.
|
|
30
|
-
|
|
31
|
-
Please also see the [API Documentation](https://github.com/iwalton3/python-mpv-jsonipc/blob/master/docs.md).
|
|
32
|
-
|
|
33
|
-
```python
|
|
34
|
-
from python_mpv_jsonipc import MPV
|
|
35
|
-
|
|
36
|
-
# Uses MPV that is in the PATH.
|
|
37
|
-
mpv = MPV()
|
|
38
|
-
|
|
39
|
-
# Use MPV that is running and connected to /tmp/mpv-socket.
|
|
40
|
-
mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv-socket")
|
|
41
|
-
|
|
42
|
-
# Uses MPV that is found at /path/to/mpv.
|
|
43
|
-
mpv = MPV(mpv_location="/path/to/mpv")
|
|
44
|
-
|
|
45
|
-
# After you have an MPV, you can read and set (if applicable) properties.
|
|
46
|
-
mpv.volume # 100.0 by default
|
|
47
|
-
mpv.volume = 20
|
|
48
|
-
|
|
49
|
-
# You can also send commands.
|
|
50
|
-
mpv.command_name(arg1, arg2)
|
|
51
|
-
|
|
52
|
-
# Bind to key press events with a decorator
|
|
53
|
-
@mpv.on_key_press("space")
|
|
54
|
-
def space_handler():
|
|
55
|
-
pass
|
|
56
|
-
|
|
57
|
-
# You can also observe and wait for properties.
|
|
58
|
-
@mpv.property_observer("eof-reached")
|
|
59
|
-
def handle_eof(name, value):
|
|
60
|
-
pass
|
|
61
|
-
|
|
62
|
-
# Or simply wait for the value to change once.
|
|
63
|
-
mpv.wait_for_property("duration")
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Platform: UNKNOWN
|
|
67
|
-
Classifier: Programming Language :: Python :: 3
|
|
68
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
69
|
-
Classifier: Operating System :: OS Independent
|
|
70
|
-
Requires-Python: >=3.6
|
|
71
|
-
Description-Content-Type: text/markdown
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: python-mpv-jsonipc
|
|
3
|
-
Version: 1.2.0
|
|
4
|
-
Summary: Python API to MPV using JSON IPC
|
|
5
|
-
Home-page: https://github.com/iwalton3/python-mpv-jsonipc
|
|
6
|
-
Author: Ian Walton
|
|
7
|
-
Author-email: iwalton3@gmail.com
|
|
8
|
-
License: Apache-2.0
|
|
9
|
-
Description: # Python MPV JSONIPC
|
|
10
|
-
|
|
11
|
-
This implements an interface similar to `python-mpv`, but it uses the JSON IPC protocol instead of the C API. This means
|
|
12
|
-
you can control external instances of MPV including players like SMPlayer, and it can use MPV players that are prebuilt
|
|
13
|
-
instead of needing `libmpv1`. It may also be more resistant to crashes such as Segmentation Faults, but since it isn't
|
|
14
|
-
directly communicating with MPV via the C API the performance will be worse.
|
|
15
|
-
|
|
16
|
-
Please note that this only implements the subset of `python-mpv` that is used by `plex-mpv-shim` and
|
|
17
|
-
`jellyfin-mpv-shim`. Other functionality has not been implemented.
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
sudo pip3 install python-mpv-jsonipc
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Basic usage
|
|
26
|
-
|
|
27
|
-
Create an instance of MPV. You can use an already running MPV or have the library start a
|
|
28
|
-
managed copy of MPV. Command arguments can be specified when initializing MPV if you are
|
|
29
|
-
starting a managed copy of MPV.
|
|
30
|
-
|
|
31
|
-
Please also see the [API Documentation](https://github.com/iwalton3/python-mpv-jsonipc/blob/master/docs.md).
|
|
32
|
-
|
|
33
|
-
```python
|
|
34
|
-
from python_mpv_jsonipc import MPV
|
|
35
|
-
|
|
36
|
-
# Uses MPV that is in the PATH.
|
|
37
|
-
mpv = MPV()
|
|
38
|
-
|
|
39
|
-
# Use MPV that is running and connected to /tmp/mpv-socket.
|
|
40
|
-
mpv = MPV(start_mpv=False, ipc_socket="/tmp/mpv-socket")
|
|
41
|
-
|
|
42
|
-
# Uses MPV that is found at /path/to/mpv.
|
|
43
|
-
mpv = MPV(mpv_location="/path/to/mpv")
|
|
44
|
-
|
|
45
|
-
# After you have an MPV, you can read and set (if applicable) properties.
|
|
46
|
-
mpv.volume # 100.0 by default
|
|
47
|
-
mpv.volume = 20
|
|
48
|
-
|
|
49
|
-
# You can also send commands.
|
|
50
|
-
mpv.command_name(arg1, arg2)
|
|
51
|
-
|
|
52
|
-
# Bind to key press events with a decorator
|
|
53
|
-
@mpv.on_key_press("space")
|
|
54
|
-
def space_handler():
|
|
55
|
-
pass
|
|
56
|
-
|
|
57
|
-
# You can also observe and wait for properties.
|
|
58
|
-
@mpv.property_observer("eof-reached")
|
|
59
|
-
def handle_eof(name, value):
|
|
60
|
-
pass
|
|
61
|
-
|
|
62
|
-
# Or simply wait for the value to change once.
|
|
63
|
-
mpv.wait_for_property("duration")
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Platform: UNKNOWN
|
|
67
|
-
Classifier: Programming Language :: Python :: 3
|
|
68
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
69
|
-
Classifier: Operating System :: OS Independent
|
|
70
|
-
Requires-Python: >=3.6
|
|
71
|
-
Description-Content-Type: text/markdown
|
|
File without changes
|
|
File without changes
|
{python-mpv-jsonipc-1.2.0 → python-mpv-jsonipc-1.2.1}/python_mpv_jsonipc.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|