home · contact · privacy
In /playlist, don't block moving up/down towards playing entry, rather jump over it.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 16 Dec 2024 14:33:36 +0000 (15:33 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 16 Dec 2024 14:33:36 +0000 (15:33 +0100)
src/ytplom/misc.py

index 4f30cf5a82f08f2feb7ada652f420cb97b6cfede..3a0be6dc26d6915b885757b904880c03428d7e3a 100644 (file)
@@ -669,16 +669,15 @@ class Player:
 
     def move_entry(self, start_idx: int, upwards: bool = 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.playlist) - 2)):
-            return
         i0, i1 = start_idx, start_idx + (-1 if upwards else 1)
+        if i1 < 0 or i1 >= len(self.playlist):
+            return
         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
+            if self._idx == i1:  # currently playing entries to be jumped over
+                self._idx = i0
+                i0, i1 = i1, i0
             path = self.playlist[i1].full_path
             self._mpv.command('playlist-remove', i1)
             self._mpv.command('loadfile', path, 'insert-at', i0)