Mercurial > code > home > repos > video
diff ingest.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 |
line wrap: on
line diff
--- a/ingest.py Tue Dec 03 00:08:22 2024 -0800 +++ b/ingest.py Tue Dec 03 19:28:11 2024 -0800 @@ -16,6 +16,7 @@ durationSec """ +import asyncio import logging from pathlib import Path import re @@ -25,6 +26,7 @@ import pymongo.database import pymongo.collection from mongo_required import open_mongo_or_die +import thumbnail logging.basicConfig(level=logging.INFO) log = logging.getLogger() @@ -89,18 +91,26 @@ for fn in files: p = root / fn if p.suffix not in VIDEO_EXTNS: - if p.suffix == '.webp': + if p.suffix in ['.jpg','.webp']: # youtube thumbnail is ok in here continue log.info(f'ignoring {p=} {p.suffix=}') continue _updateOneFile(p, fs, source) - -# thumb = db.get_collection('thumb') -# probe = db.get_collection('probe') +async def updateThumbnails(db: pymongo.database.Database): + fs = db.get_collection('fs') + thumb = db.get_collection('thumb') + n=0 + for doc in fs.find({'type': 'file'}): + n+=1 + # if n>10: + # log.info('updateThumbnails: stop') + # break + await thumbnail.createThumbnail(thumb, doc['diskPath']) if __name__ == '__main__': while True: updateFs(db, sources) + asyncio.run(updateThumbnails(db)) time.sleep(600)