Mercurial > code > home > repos > video
view video_ingest.py @ 17:071943adf000
dnd a file or a url which we'll queue and fetch
author | drewp@bigasterisk.com |
---|---|
date | Sun, 16 Apr 2023 03:19:33 -0700 |
parents | |
children | 9e56e86a6814 |
line wrap: on
line source
import asyncio from dataclasses import dataclass from typing import Any, Coroutine import dl_queue from video_file_store import VideoFileStore @dataclass class VideoIngest: store: VideoFileStore async def addContent(self, name: str, body: Coroutine[Any, Any, bytes]): await self.store.save(name, iter([await body])) async def ingestUrl(self, url: str): dl_queue.queue.put({'url': url, 'outDir': str(self.store.top)}) async def events(self): prev = None while True: p = dl_queue.pending() if p != prev: prev = p yield p await asyncio.sleep(1)