mirror of
https://github.com/jarulsamy/Plex-Bot.git
synced 2024-08-19 15:01:55 +02:00
rewrote looping
This commit is contained in:
parent
8b90fb8e34
commit
90c40fb0d6
@ -332,13 +332,13 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
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")
|
||||||
|
for item in self.loop_queue:
|
||||||
|
await self.play_queue.put(item)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.current_track = await self.loop_queue.get()
|
self.current_track = await self.play_queue.get()
|
||||||
except CancelledError:
|
except CancelledError:
|
||||||
bot_log.debug("failed to pop queue")
|
bot_log.debug("failed to pop queue")
|
||||||
self.play_queue = self.loop_queue
|
|
||||||
self.loop_queue = asyncio.Queue()
|
|
||||||
|
|
||||||
|
|
||||||
async def _audio_player_task(self):
|
async def _audio_player_task(self):
|
||||||
"""
|
"""
|
||||||
@ -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):
|
||||||
|
Loading…
Reference in New Issue
Block a user