diff video_file_store.py @ 37:7cacfae58430

thumbnails rewrite - store in db; don't use YT-provided pics for now
author drewp@bigasterisk.com
date Tue, 03 Dec 2024 19:28:11 -0800
parents ed16fdbb3996
children 0aea9e55899b
line wrap: on
line diff
--- a/video_file_store.py	Tue Dec 03 00:08:22 2024 -0800
+++ b/video_file_store.py	Tue Dec 03 19:28:11 2024 -0800
@@ -29,7 +29,7 @@
         for doc in self.fs.find({
                 'type': 'file',
                 'webRelParent': webRelParent
-        }):
+        }, sort=[('label', 1)]):
             yield VideoFile(Path(doc['diskPath']), doc['webRelPath'],
                             doc['webDataPath'], doc['label'])
 
@@ -39,31 +39,12 @@
                 'dir',
                 'webRelParent':
                 '.' if subdir == '/' else subdir
-        }):
+        }, sort=[('label', 1)]):
             yield {
                 'label': doc['label'],
                 'path': doc['webRelPath'],
             }
 
-    def thumbPath(self, vf: VideoFile) -> str:
-        return '_thumb/' + vf.webRelPath
-        sha256 = hashlib.sha256()
-        with open(vf.diskPath, 'rb') as f:
-            firstMb = f.read(1 << 20)
-            sha256.update(firstMb)
-        cksum = sha256.hexdigest()
-        return f'_thumb/{cksum}.jpg'
-
-    async def getOrCreateThumb(self, vf: VideoFile) -> str:
-        raise
-        p = self.top / self.thumbPath(vf)
-        if not p.exists():
-            sp = asyncio.create_subprocess_exec('ffmpegthumbnailer',
-                                                '-s', '250', '-i',
-                                                str(vf.diskPath), '-o', str(p))
-            await sp
-        return thumbWebPath(str(p.relative_to(self.top)))
-
     async def save(self, name: str, chunks: Iterator[bytes]):
         raise
         p = self.top / name