python-mpv-jsonipc 1.2.0__py3-none-any.whl → 1.2.1__py3-none-any.whl
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.0.dist-info → python_mpv_jsonipc-1.2.1.dist-info}/METADATA +4 -6
- python_mpv_jsonipc-1.2.1.dist-info/RECORD +6 -0
- {python_mpv_jsonipc-1.2.0.dist-info → python_mpv_jsonipc-1.2.1.dist-info}/WHEEL +1 -1
- python_mpv_jsonipc.py +22 -21
- python_mpv_jsonipc-1.2.0.dist-info/RECORD +0 -6
- {python_mpv_jsonipc-1.2.0.dist-info → python_mpv_jsonipc-1.2.1.dist-info}/LICENSE.md +0 -0
- {python_mpv_jsonipc-1.2.0.dist-info → python_mpv_jsonipc-1.2.1.dist-info}/top_level.txt +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-mpv-jsonipc
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Python API to MPV using JSON IPC
|
|
5
5
|
Home-page: https://github.com/iwalton3/python-mpv-jsonipc
|
|
6
|
-
Author:
|
|
7
|
-
Author-email:
|
|
6
|
+
Author: Izzie Walton
|
|
7
|
+
Author-email: izzie@iwalton.com
|
|
8
8
|
License: Apache-2.0
|
|
9
|
-
Platform: UNKNOWN
|
|
10
9
|
Classifier: Programming Language :: Python :: 3
|
|
11
10
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
11
|
Classifier: Operating System :: OS Independent
|
|
13
12
|
Requires-Python: >=3.6
|
|
14
13
|
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE.md
|
|
15
15
|
|
|
16
16
|
# Python MPV JSONIPC
|
|
17
17
|
|
|
@@ -69,5 +69,3 @@ def handle_eof(name, value):
|
|
|
69
69
|
# Or simply wait for the value to change once.
|
|
70
70
|
mpv.wait_for_property("duration")
|
|
71
71
|
```
|
|
72
|
-
|
|
73
|
-
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
python_mpv_jsonipc.py,sha256=huWL8FWm8rgOmeQC8OEx2C6ijKscJz5weSPQrXotJQM,23654
|
|
2
|
+
python_mpv_jsonipc-1.2.1.dist-info/LICENSE.md,sha256=7GQBUOA3dNG1Jk-yaPOCncNnRVURCRMev23QpZ1ew-s,10495
|
|
3
|
+
python_mpv_jsonipc-1.2.1.dist-info/METADATA,sha256=uE-UpqjWJqQBLZh5l0Am0IRcsFAIWgRxpyxsA7lnJjM,2301
|
|
4
|
+
python_mpv_jsonipc-1.2.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
5
|
+
python_mpv_jsonipc-1.2.1.dist-info/top_level.txt,sha256=nGk4yjpVHKmIrL39XdGD2PhCeWF0oMjwey0nsNOd2TM,19
|
|
6
|
+
python_mpv_jsonipc-1.2.1.dist-info/RECORD,,
|
python_mpv_jsonipc.py
CHANGED
|
@@ -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
|
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
python_mpv_jsonipc.py,sha256=F6rSnv0QKkqR1XKYkao0aXFqsXGr-22EV9gkXU7dHCA,23629
|
|
2
|
-
python_mpv_jsonipc-1.2.0.dist-info/LICENSE.md,sha256=7GQBUOA3dNG1Jk-yaPOCncNnRVURCRMev23QpZ1ew-s,10495
|
|
3
|
-
python_mpv_jsonipc-1.2.0.dist-info/METADATA,sha256=1gom4VqEf_32RzxScob2OuXe3cAnNAeDHktQwjLK-eA,2295
|
|
4
|
-
python_mpv_jsonipc-1.2.0.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
5
|
-
python_mpv_jsonipc-1.2.0.dist-info/top_level.txt,sha256=nGk4yjpVHKmIrL39XdGD2PhCeWF0oMjwey0nsNOd2TM,19
|
|
6
|
-
python_mpv_jsonipc-1.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|