Update python_mpv_jsonipc to 1.1.13 keeping our changes
This commit is contained in:
parent
a03f59526c
commit
7301870d7c
@ -189,7 +189,7 @@ class MPVProcess:
|
|||||||
"""
|
"""
|
||||||
Manages an MPV process, ensuring the socket or pipe is available. (Internal)
|
Manages an MPV process, ensuring the socket or pipe is available. (Internal)
|
||||||
"""
|
"""
|
||||||
def __init__(self, ipc_socket, mpv_location=None, **kwargs):
|
def __init__(self, ipc_socket, mpv_location=None, env=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Create and start the MPV process. Will block until socket/pipe is available.
|
Create and start the MPV process. Will block until socket/pipe is available.
|
||||||
|
|
||||||
@ -205,7 +205,6 @@ class MPVProcess:
|
|||||||
mpv_location = "mpv"
|
mpv_location = "mpv"
|
||||||
|
|
||||||
log.debug("Staring MPV from {0}.".format(mpv_location))
|
log.debug("Staring MPV from {0}.".format(mpv_location))
|
||||||
ipc_socket_name = ipc_socket
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
ipc_socket = "\\\\.\\pipe\\" + ipc_socket
|
ipc_socket = "\\\\.\\pipe\\" + ipc_socket
|
||||||
|
|
||||||
@ -214,14 +213,12 @@ class MPVProcess:
|
|||||||
|
|
||||||
log.debug("Using IPC socket {0} for MPV.".format(ipc_socket))
|
log.debug("Using IPC socket {0} for MPV.".format(ipc_socket))
|
||||||
self.ipc_socket = ipc_socket
|
self.ipc_socket = ipc_socket
|
||||||
args = [mpv_location]
|
args = self._get_arglist(mpv_location, **kwargs)
|
||||||
self._set_default(kwargs, "idle", True)
|
|
||||||
self._set_default(kwargs, "input_ipc_server", ipc_socket_name)
|
self._start_process(ipc_socket, args, env=env)
|
||||||
self._set_default(kwargs, "input_terminal", False)
|
|
||||||
self._set_default(kwargs, "terminal", False)
|
def _start_process(self, ipc_socket, args, env):
|
||||||
args.extend("--{0}={1}".format(v[0].replace("_", "-"), self._mpv_fmt(v[1]))
|
self.process = subprocess.Popen(args, env=env)
|
||||||
for v in kwargs.items())
|
|
||||||
self.process = subprocess.Popen(args)
|
|
||||||
ipc_exists = False
|
ipc_exists = False
|
||||||
for _ in range(100): # Give MPV 10 seconds to start.
|
for _ in range(100): # Give MPV 10 seconds to start.
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@ -245,6 +242,16 @@ class MPVProcess:
|
|||||||
if key not in prop_dict:
|
if key not in prop_dict:
|
||||||
prop_dict[key] = value
|
prop_dict[key] = value
|
||||||
|
|
||||||
|
def _get_arglist(self, exec_location, **kwargs):
|
||||||
|
args = [exec_location]
|
||||||
|
self._set_default(kwargs, "idle", True)
|
||||||
|
self._set_default(kwargs, "input_ipc_server", self.ipc_socket)
|
||||||
|
self._set_default(kwargs, "input_terminal", False)
|
||||||
|
self._set_default(kwargs, "terminal", False)
|
||||||
|
args.extend("--{0}={1}".format(v[0].replace("_", "-"), self._mpv_fmt(v[1]))
|
||||||
|
for v in kwargs.items())
|
||||||
|
return args
|
||||||
|
|
||||||
def _mpv_fmt(self, data):
|
def _mpv_fmt(self, data):
|
||||||
if data == True:
|
if data == True:
|
||||||
return "yes"
|
return "yes"
|
||||||
@ -412,16 +419,7 @@ class MPV:
|
|||||||
ipc_socket = "/tmp/{0}".format(rand_file)
|
ipc_socket = "/tmp/{0}".format(rand_file)
|
||||||
|
|
||||||
if start_mpv:
|
if start_mpv:
|
||||||
# Attempt to start MPV 3 times.
|
self._start_mpv(ipc_socket, mpv_location, **kwargs)
|
||||||
for i in range(3):
|
|
||||||
try:
|
|
||||||
self.mpv_process = MPVProcess(ipc_socket, mpv_location, **kwargs)
|
|
||||||
break
|
|
||||||
except MPVError:
|
|
||||||
log.warning("MPV start failed.", exc_info=1)
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
raise MPVError("MPV process retry limit reached.")
|
|
||||||
|
|
||||||
self.mpv_inter = MPVInter(ipc_socket, self._callback, self._quit_callback)
|
self.mpv_inter = MPVInter(ipc_socket, self._callback, self._quit_callback)
|
||||||
self.properties = set(x.replace("-", "_") for x in self.command("get_property", "property-list"))
|
self.properties = set(x.replace("-", "_") for x in self.command("get_property", "property-list"))
|
||||||
@ -458,6 +456,18 @@ class MPV:
|
|||||||
if len(args) == 2 and args[0] == "custom-bind":
|
if len(args) == 2 and args[0] == "custom-bind":
|
||||||
self.event_handler.put_task(self.key_bindings[args[1]])
|
self.event_handler.put_task(self.key_bindings[args[1]])
|
||||||
|
|
||||||
|
def _start_mpv(self, ipc_socket, mpv_location, **kwargs):
|
||||||
|
# Attempt to start MPV 3 times.
|
||||||
|
for i in range(3):
|
||||||
|
try:
|
||||||
|
self.mpv_process = MPVProcess(ipc_socket, mpv_location, **kwargs)
|
||||||
|
break
|
||||||
|
except MPVError:
|
||||||
|
log.warning("MPV start failed.", exc_info=1)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise MPVError("MPV process retry limit reached.")
|
||||||
|
|
||||||
def _quit_callback(self):
|
def _quit_callback(self):
|
||||||
"""
|
"""
|
||||||
Internal handler for quit events.
|
Internal handler for quit events.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user