From 61fcb942102afeb48c432b0ddce16d245f03fbb6 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 22 Jul 2022 01:56:39 +0200 Subject: [PATCH] A few small fixes (#432) * fix artist splitter do not split artist on & * fix repeat * fix add to queue when shuffle is enabled * typos --- music_assistant/helpers/tags.py | 5 ++++- music_assistant/models/player_queue.py | 19 ++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/music_assistant/helpers/tags.py b/music_assistant/helpers/tags.py index fa4547fa..3063c2f5 100644 --- a/music_assistant/helpers/tags.py +++ b/music_assistant/helpers/tags.py @@ -13,7 +13,10 @@ from music_assistant.models.errors import InvalidDataError FALLBACK_ARTIST = "Various Artists" -SPLITTERS = (";", ",", "Featuring", " Feat. ", " Feat ", "feat.", " & ", "/ ") +# allowed splitters for titles and artists strings +# NOTE: do not use '&' or '/' as splitter here as it will cause issues with artists +# actually having that in the name +SPLITTERS = (";", ",", "Featuring", " Feat. ", " Feat ", "feat.") def split_items(org_str: str) -> Tuple[str]: diff --git a/music_assistant/models/player_queue.py b/music_assistant/models/player_queue.py index be9c2b2c..0ee41734 100644 --- a/music_assistant/models/player_queue.py +++ b/music_assistant/models/player_queue.py @@ -618,14 +618,17 @@ class PlayerQueue: if cur_index is None: played_items = [] next_items = self.items + queue_items - cur_item = [] + cur_items = [] else: played_items = self.items[:cur_index] if cur_index is not None else [] next_items = self.items[cur_index + 1 :] + queue_items - cur_item = [self.get_item(cur_index)] + if cur_item := self.get_item(cur_index): + cur_items = [cur_item] + else: + cur_items = [] # do the shuffle next_items = random.sample(next_items, len(next_items)) - queue_items = played_items + cur_item + next_items + queue_items = played_items + cur_items + next_items else: queue_items = self._items + queue_items await self.update_items(queue_items) @@ -647,16 +650,10 @@ class PlayerQueue: self.signal_update() if self.player.state == PlayerState.IDLE: - # handle end of queue - if self._current_index is not None and self._current_index >= ( - len(self._items) - 1 - ): - self._current_index += 1 - self._current_item_elapsed_time = 0 - # handle case where stream stopped on purpose and we need to restart it - elif self.signal_next: + if self.signal_next: self.signal_next = False + self._current_item_elapsed_time = 0 self.mass.create_task(self.resume()) self.update_state() -- 2.34.1