summaryrefslogtreecommitdiff
path: root/mpv.py
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2017-08-02 10:46:13 +0200
committerjaseg <code@jaseg.net>2017-08-02 10:46:13 +0200
commit7dc375f85c254e1accfd0558bcb1a527f1737eee (patch)
tree81ce4791de9aa177ba71df9ffdefae14fa6196ea /mpv.py
parent1fa874db3782d076bc213a73528c85a8ceec5bd7 (diff)
downloadpython-mpv-7dc375f85c254e1accfd0558bcb1a527f1737eee.tar.gz
python-mpv-7dc375f85c254e1accfd0558bcb1a527f1737eee.tar.bz2
python-mpv-7dc375f85c254e1accfd0558bcb1a527f1737eee.zip
MPV constructor: Add loglevel argument
Diffstat (limited to 'mpv.py')
-rw-r--r--mpv.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/mpv.py b/mpv.py
index ec5b168..084be03 100644
--- a/mpv.py
+++ b/mpv.py
@@ -469,7 +469,7 @@ class MPV(object):
""" See man mpv(1) for the details of the implemented commands. All mpv
properties can be accessed as ```my_mpv.some_property``` and all mpv
options can be accessed as ```my_mpv['some-option']```. """
- def __init__(self, *extra_mpv_flags, log_handler=None, start_event_thread=True, **extra_mpv_opts):
+ def __init__(self, *extra_mpv_flags, log_handler=None, start_event_thread=True, loglevel=None, **extra_mpv_opts):
""" Create an MPV instance.
Extra arguments and extra keyword arguments will be passed to mpv as options. """
@@ -496,6 +496,8 @@ class MPV(object):
self._event_handle = _mpv_create_client(self.handle, b'py_event_handler')
self._loop = partial(_event_loop, self._event_handle, self._playback_cond, self._event_callbacks,
self._message_handlers, self._property_handlers, log_handler)
+ if loglevel is not None or log_handler is not None:
+ self.set_loglevel(loglevel or 'terminal-default')
if start_event_thread:
self._event_thread = threading.Thread(target=self._loop, name='MPVEventHandlerThread')
self._event_thread.setDaemon(True)
@@ -503,9 +505,6 @@ class MPV(object):
else:
self._event_thread = None
- if log_handler is not None:
- self.set_loglevel('terminal-default')
-
def wait_for_playback(self):
""" Waits until playback of the current title is paused or done """
with self._playback_cond: