Rerender in executor

This commit is contained in:
BarsTiger
2023-11-20 23:01:42 +02:00
parent bc2663c17c
commit d4a7708ef9

View File

@@ -27,7 +27,7 @@ class YouTubeBytestream:
duration=int(duration), duration=int(duration),
) )
async def rerender(self): async def __rerender(self):
segment = AudioSegment.from_file( segment = AudioSegment.from_file(
file=BytesIO(self.file) file=BytesIO(self.file)
) )
@@ -35,6 +35,11 @@ class YouTubeBytestream:
self.file = segment.export(BytesIO(), format='mp3', codec='libmp3lame').read() self.file = segment.export(BytesIO(), format='mp3', codec='libmp3lame').read()
return self return self
async def rerender(self):
return await asyncio.get_event_loop().run_in_executor(
None, self.__rerender
)
@define @define
class Downloader: class Downloader: