+ def move_entry(self, start_idx: int, upwards=True) -> None:
+ """Move playlist entry at start_idx up or down one step."""
+ if (start_idx == self._idx
+ or (upwards and start_idx == self._idx + 1)
+ or ((not upwards) and start_idx == self._idx - 1)
+ or (upwards and start_idx < 1)
+ or ((not upwards) and start_idx > len(self._files) - 2)):
+ return
+ i0, i1 = start_idx, start_idx + (-1 if upwards else 1)
+ if self._mpv:
+ # NB: a functional playlist-move would do this in a single step,
+ # but for some reason I don't seem to get it to do anything
+ path = self._files[i1].full_path
+ self._mpv.command('playlist-remove', i1)
+ self._mpv.command('loadfile', path, 'insert-at', i0)
+ self._files[i0], self._files[i1] = self._files[i1], self._files[i0]
+