update @ Sun Dec 15 16:44:31 EET 2024

Signed-off-by: Ari Archer <ari@ari.lt>
This commit is contained in:
Arija A. 2024-12-15 16:44:31 +02:00
parent 8fdf660002
commit 002771908a
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: A50D5B4B599AF8A2
3 changed files with 18 additions and 3 deletions

1
.gitignore vendored
View file

@ -15,3 +15,4 @@ venv/
/sitemap.xml
/robots.txt
/stats/
/licenses.json

View file

@ -6,7 +6,7 @@
"alt": "A black cat sitting in a box peacefully",
"purpose": "To have a cute cat who looks over blog.ari.lt",
"title": "Tina in a box (2019-2020, I think)",
"license": "CC-BY-SA",
"license": "CC-BY-SA-1.0",
"credit": "Ari Archer",
"ext": "jpeg",
"mime": "image/jpeg",

View file

@ -439,6 +439,7 @@ STATS_TEMPLATE: typing.Final[str] = (
)
if NCI:
import requests
import http.server
import magic
@ -447,6 +448,7 @@ if NCI:
else:
pyfzf: typing.Any = None
http: typing.Any = None
requests: typing.Any = None
magic: typing.Any = None
Image: typing.Any = None
@ -570,7 +572,7 @@ def select_medias(type: typing.Optional[str] = None) -> tuple[str, ...]:
lambda opt: opt.split("|", maxsplit=1)[0].strip(),
select_multi(
tuple(
f"{mdx} | {mdy['type']}, {mdy['alt']} for {mdy['purpose']} | {mdy['title']}, {mdy['credit']}"
f"{mdx} | {mdy['type']}, {mdy['alt']} for {mdy['purpose']} | {mdy['title']}, {mdy['credit']} ({mdy['license']})"
for mdx, mdy in MEDIA_INDEX.items()
if mdy["type"] == type
)
@ -1720,6 +1722,17 @@ def media(config: dict[str, typing.Any]) -> int:
assert config is config, "Unused"
if os.path.exists("licenses.json"):
with open("licenses.json", "r") as fp:
licenses: tuple[str, ...] = json.load(fp)
else:
lnew("fetching SPDX license IDs")
licenses = tuple(license["licenseId"] for license in requests.get("https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json").json()["licenses"])
with open("licenses.json", "w") as fp:
json.dump(licenses, fp)
path: str = iinput("media path")
path = os.path.expanduser(path)
@ -1728,7 +1741,8 @@ def media(config: dict[str, typing.Any]) -> int:
purpose: str = iinput("media purpose")
title: str = iinput("media title")
license: str = iinput("media license (SPDX)")
license: str = ", ".join(select_multi(licenses))
credit: str = iinput("media credit")
# MIME stuff