Files
xtreamium/backend/server/lib/streamer.py
2022-04-11 11:51:11 +01:00

20 lines
605 B
Python

from httpx import AsyncClient
import ffmpeg_streaming
class Streamer:
@staticmethod
async def receive_file(url):
async with AsyncClient(follow_redirects=True) as client:
response = await client.get(url)
async for dataBytes in response.aiter_bytes():
yield dataBytes
@staticmethod
async def receive_stream(url):
async with AsyncClient(follow_redirects=True) as client:
async with client.stream('GET', url) as response:
async for dataBytes in response.aiter_bytes():
yield dataBytes