summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2016-08-20 11:20:20 +0200
committerjaseg <code@jaseg.net>2016-08-20 11:20:20 +0200
commit1ee4361bdd41e8ae0a6d0d9570d75e85a44d19ff (patch)
tree309b76d3a84fa3c77a1c16818d92a9b19d34cf73
parent669c4bbfeca57de862ce470d20122637cf8df2ff (diff)
downloadpython-mpv-1ee4361bdd41e8ae0a6d0d9570d75e85a44d19ff.tar.gz
python-mpv-1ee4361bdd41e8ae0a6d0d9570d75e85a44d19ff.tar.bz2
python-mpv-1ee4361bdd41e8ae0a6d0d9570d75e85a44d19ff.zip
Pimp loadfile to accept per-file options
-rwxr-xr-xmpv-test.py2
-rw-r--r--mpv.py8
2 files changed, 7 insertions, 3 deletions
diff --git a/mpv-test.py b/mpv-test.py
index 14d5b6d..f35f160 100755
--- a/mpv-test.py
+++ b/mpv-test.py
@@ -197,7 +197,7 @@ class TestLifecycle(unittest.TestCase):
m.wait_for_playback()
del m
handler.assert_has_calls([
- mock.call('info', 'cplayer', 'Playing: ./test.webm'),
+ mock.call('info', 'cplayer', 'Playing: test.webm'),
mock.call('info', 'cplayer', ' Video --vid=1 (*) (vp8)'),
mock.call('fatal', 'cplayer', 'No video or audio streams selected.')])
diff --git a/mpv.py b/mpv.py
index 2131fa2..993cf67 100644
--- a/mpv.py
+++ b/mpv.py
@@ -495,8 +495,12 @@ class MPV(object):
def playlist_prev(self, mode='weak'):
self.command('playlist_prev', mode)
- def loadfile(self, filename, mode='replace'):
- self.command('loadfile', filename.encode(fs_enc), mode)
+ @staticmethod
+ def _encode_options(options):
+ return ','.join('{}={}'.format(str(key), str(val)) for key, val in options.items())
+
+ def loadfile(self, filename, mode='replace', **options):
+ self.command('loadfile', filename.encode(fs_enc), mode, MPV._encode_options(options))
def loadlist(self, playlist, mode='replace'):
self.command('loadlist', playlist.encode(fs_enc), mode)