rewrote looping

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

View File

@ -332,13 +332,13 @@ class Plex(commands.Cog):
if not self.current_track and self.loop_queue:
bot_log.debug("swapping loop queue and play queue")
for item in self.loop_queue:
await self.play_queue.put(item)
try:
self.current_track = await self.loop_queue.get()
self.current_track = await self.play_queue.get()
except CancelledError:
bot_log.debug("failed to pop queue")
self.play_queue = self.loop_queue
self.loop_queue = asyncio.Queue()
async def _audio_player_task(self):
"""
@ -393,9 +393,6 @@ class Plex(commands.Cog):
Raises:
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.bot.loop.call_soon_threadsafe(self.play_next_event.set)
@ -810,7 +807,12 @@ class Plex(commands.Cog):
None
"""
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()
async def unloop(self, ctx):