Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: loadfile for mpv v0.38.0, fix #823 #824

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions feeluown/mpv.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,8 @@ def __init__(self, *extra_mpv_flags, log_handler=None, start_event_thread=True,
self._event_thread.start()
else:
self._event_thread = None
if m := re.search(r'(\d+)\.(\d+)\.(\d+)', self.mpv_version):
self.mpv_version_tuple = tuple(map(int, m.groups()))

def _loop(self):
for event in _event_generator(self._event_handle):
Expand Down Expand Up @@ -1152,9 +1154,16 @@ def playlist_play_index(self, idx):
def _encode_options(options):
return ','.join('{}={}'.format(_py_to_mpv(str(key)), str(val)) for key, val in options.items())

def loadfile(self, filename, mode='replace', **options):
def loadfile(self, filename, mode='replace', index=None, **options):
"""Mapped mpv loadfile command, see man mpv(1)."""
self.command('loadfile', filename.encode(fs_enc), mode, MPV._encode_options(options))
if self.mpv_version_tuple >= (0, 38, 0):
if index is None:
index = -1
self.command('loadfile', filename.encode(fs_enc), mode, index, MPV._encode_options(options))
else:
if index is not None:
warn(f'The index argument to the loadfile command is only supported on mpv >= 0.38.0')
self.command('loadfile', filename.encode(fs_enc), mode, MPV._encode_options(options))

def loadlist(self, playlist, mode='replace'):
"""Mapped mpv loadlist command, see man mpv(1)."""
Expand Down
Loading