From 6053b2ef5a708b0025141dba3a5288642b508ff8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 3 May 2020 01:53:15 +0200 Subject: [PATCH] Fix bugs? --- royalpack/stars/api_fiorygi_get.py | 10 ++++++---- royalpack/utils/royalpool.py | 19 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/royalpack/stars/api_fiorygi_get.py b/royalpack/stars/api_fiorygi_get.py index 64cf1ad7..5e31e9b9 100644 --- a/royalpack/stars/api_fiorygi_get.py +++ b/royalpack/stars/api_fiorygi_get.py @@ -29,8 +29,10 @@ class ApiFiorygiGetStar(ApiStar): transactions: JSON = sorted(fiorygi.transactions, key=lambda t: -t.id) return { "fiorygi": fiorygi.fiorygi, - "transactions": list(map(lambda t: {"id": t.id, - "change": t.change, - "reason": t.reason, - "timestamp": t.timestamp.isoformat()}, transactions)) + "transactions": list(map(lambda t: { + "id": t.id, + "change": t.change, + "reason": t.reason, + "timestamp": t.timestamp.isoformat() if t.timestamp else None + }, transactions)) } diff --git a/royalpack/utils/royalpool.py b/royalpack/utils/royalpool.py index c594ca3c..40301e4c 100644 --- a/royalpack/utils/royalpool.py +++ b/royalpack/utils/royalpool.py @@ -32,16 +32,15 @@ class RoyalPool(Playable): else: self.remaining_pool = self.full_pool.copy() random.shuffle(self.remaining_pool) - else: - log.debug(f"Dequeuing an item...") - # Get the first YtdlDiscord of the queue - self.now_playing: YtdlDiscord = self.remaining_pool.pop(0) - log.debug(f"Yielding FileAudioSource from: {self.now_playing}") - # Create a FileAudioSource from the YtdlDiscord - # If the file hasn't been fetched / downloaded / converted yet, it will do so before yielding - async with self.now_playing.spawn_audiosource() as fas: - # Yield the resulting AudioSource - yield fas + log.debug(f"Dequeuing an item...") + # Get the first YtdlDiscord of the queue + self.now_playing: YtdlDiscord = self.remaining_pool.pop(0) + log.debug(f"Yielding FileAudioSource from: {self.now_playing}") + # Create a FileAudioSource from the YtdlDiscord + # If the file hasn't been fetched / downloaded / converted yet, it will do so before yielding + async with self.now_playing.spawn_audiosource() as fas: + # Yield the resulting AudioSource + yield fas async def destroy(self): for file in self.full_pool: