Fix rerendering

This commit is contained in:
BarsTiger
2023-11-21 22:29:47 +02:00
parent d4a7708ef9
commit cae8dcc3df

View File

@@ -4,6 +4,8 @@ from pytube import YouTube, Stream
from pydub import AudioSegment from pydub import AudioSegment
from io import BytesIO from io import BytesIO
from concurrent.futures import ThreadPoolExecutor
import asyncio import asyncio
@@ -27,7 +29,7 @@ class YouTubeBytestream:
duration=int(duration), duration=int(duration),
) )
async def __rerender(self): def __rerender(self):
segment = AudioSegment.from_file( segment = AudioSegment.from_file(
file=BytesIO(self.file) file=BytesIO(self.file)
) )
@@ -36,8 +38,9 @@ class YouTubeBytestream:
return self return self
async def rerender(self): async def rerender(self):
return await asyncio.get_event_loop().run_in_executor( with ThreadPoolExecutor() as executor:
None, self.__rerender return await asyncio.get_running_loop().run_in_executor(
executor, self.__rerender
) )