30 lines
787 B
Python
30 lines
787 B
Python
|
|
import glob
|
|
import re
|
|
import os
|
|
|
|
def is_in_year(year, content):
|
|
return re.search(r"date:\s?\"?" + str(year) + "-", content) is not None
|
|
|
|
def end_of_year(year):
|
|
games = []
|
|
for name in glob.glob('../content/games/**/*.md'):
|
|
if not '/_index.md' in name:
|
|
with open(name) as file:
|
|
content = file.read()
|
|
|
|
if is_in_year(year, content):
|
|
parts = name.split('/')
|
|
games.append("../static/games/" + parts[-2] + "/" + parts[-1].replace(".md", "") + "/" + "cover.jpg")
|
|
|
|
return games
|
|
|
|
def montage(coverlist, year):
|
|
cmd = "montage " + " ".join(coverlist) + " -geometry +0+0 -tile 8x5 -resize 170x200! collage-" + str(year) + ".jpg"
|
|
os.system(cmd)
|
|
|
|
os.system("rm -rf *.jpg")
|
|
games_list = end_of_year(2021)
|
|
montage(games_list, 2021)
|
|
print(" -- done, see collage-[year].jpg")
|