queue_items.insert(new_index, queue_items.pop(item_index))
self.update_items(queue_id, queue_items)
+ @api_command("player_queues/move_item_end")
+ def move_item_end(self, queue_id: str, queue_item_id: str) -> None:
+ """
+ Move queue item to the end the queue.
+
+ - queue_id: id of the queue to process this request.
+ - queue_item_id: the item_id of the queueitem that needs to be moved.
+ """
+ queue = self._queues[queue_id]
+ item_index = self.index_by_id(queue_id, queue_item_id)
+ if item_index is None:
+ raise InvalidDataError(f"Item {queue_item_id} not found in queue")
+ if queue.index_in_buffer is not None and item_index <= queue.index_in_buffer:
+ msg = f"{item_index} is already played/buffered"
+ raise IndexError(msg)
+
+ queue_items = self._queue_items[queue_id]
+ if item_index == (len(queue_items) - 1):
+ return
+ queue_items = queue_items.copy()
+
+ new_index = len(self._queue_items[queue_id]) - 1
+
+ # move the item in the list
+ queue_items.insert(new_index, queue_items.pop(item_index))
+ self.update_items(queue_id, queue_items)
+
@api_command("player_queues/delete_item")
def delete_item(self, queue_id: str, item_id_or_index: int | str) -> None:
"""Delete item (by id or index) from the queue."""