Files
xtreamium/backend/app/lib/streamer.py
Fergal Moran f2cde38a0f Initial commit
2022-04-05 11:50:25 +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