rewrote looping

This commit is contained in:
Carsten Burgard 2022-04-15 16:11:44 +02:00
parent 8b90fb8e34
commit 90c40fb0d6

View File

@ -331,15 +331,15 @@ class Plex(commands.Cog):
bot_log.debug("failed to pop queue") bot_log.debug("failed to pop queue")
if not self.current_track and self.loop_queue: if not self.current_track and self.loop_queue:
bot_log.debug("swapping loop queue and play queue") bot_log.debug("swapping loop queue and play queue")
try: for item in self.loop_queue:
self.current_track = await self.loop_queue.get() await self.play_queue.put(item)
except CancelledError:
bot_log.debug("failed to pop queue")
self.play_queue = self.loop_queue
self.loop_queue = asyncio.Queue()
try:
self.current_track = await self.play_queue.get()
except CancelledError:
bot_log.debug("failed to pop queue")
async def _audio_player_task(self): async def _audio_player_task(self):
""" """
Coroutine to handle playback and queuing Coroutine to handle playback and queuing
@ -393,9 +393,6 @@ class Plex(commands.Cog):
Raises: Raises:
None None
""" """
if self.current_track and self.loop_queue:
bot_log.debug("pushing into loop queue: "+str(self.current_track))
self.bot.loop.call_soon_threadsafe(self.loop_queue.put,self.current_track)
self.current_track = None self.current_track = None
self.bot.loop.call_soon_threadsafe(self.play_next_event.set) self.bot.loop.call_soon_threadsafe(self.play_next_event.set)
@ -810,7 +807,12 @@ class Plex(commands.Cog):
None None
""" """
bot_log.debug("Looping current queue") bot_log.debug("Looping current queue")
self.loop_queue = asyncio.Queue() if self.current_track:
self.loop_queue = [ self.current_track ]
else:
self.loop_queue = []
for item in self.play_queue._queue:
self.loop_queue.append(item)
@command() @command()
async def unloop(self, ctx): async def unloop(self, ctx):