Mercurial > code > home > repos > video
comparison 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 |
comparison
equal
deleted
inserted
replaced
16:838eb0223bdb | 17:071943adf000 |
---|---|
1 import asyncio | |
2 from dataclasses import dataclass | |
3 from typing import Any, Coroutine | |
4 | |
5 import dl_queue | |
6 from video_file_store import VideoFileStore | |
7 | |
8 | |
9 @dataclass | |
10 class VideoIngest: | |
11 store: VideoFileStore | |
12 | |
13 async def addContent(self, name: str, body: Coroutine[Any, Any, bytes]): | |
14 await self.store.save(name, iter([await body])) | |
15 | |
16 async def ingestUrl(self, url: str): | |
17 dl_queue.queue.put({'url': url, 'outDir': str(self.store.top)}) | |
18 | |
19 async def events(self): | |
20 prev = None | |
21 while True: | |
22 p = dl_queue.pending() | |
23 if p != prev: | |
24 prev = p | |
25 yield p | |
26 await asyncio.sleep(1) |