|
from pathlib import Path
|
|
from datetime import datetime
|
|
import subprocess
|
|
|
|
year = datetime.now().year
|
|
|
|
sessions = Path('content','sessions',str(year))
|
|
|
|
for p in sessions.iterdir():
|
|
if p.is_dir():
|
|
thumbnail = p / 'thumbnail.png'
|
|
if thumbnail.exists():
|
|
continue
|
|
pdfs = [f for f in p.iterdir() if f.suffix == '.pdf']
|
|
if not pdfs:
|
|
continue
|
|
pdf = pdfs[0]
|
|
print(f"Making thumbnail for {p}")
|
|
subprocess.run(['pdftoppm',pdf,str(thumbnail.with_suffix('')),'-png','-f','1','-singlefile'])
|