Add domain name renew dates

Closes: #49
This commit is contained in:
Edward Betts 2023-11-12 19:58:56 +01:00
parent 41380a3138
commit 3d8eadb011
2 changed files with 30 additions and 0 deletions

View file

@ -20,6 +20,7 @@ from . import (
birthday,
calendar,
conference,
domains,
economist,
fx,
gwr,
@ -250,6 +251,8 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]:
events += subscription.get_events(os.path.join(my_data, "subscriptions.yaml"))
events += economist.publication_dates(last_week, next_year)
events += domains.renewal_dates(my_data)
events.sort(key=operator.attrgetter("as_datetime"))
observer = sun.bristol()

27
agenda/domains.py Normal file
View file

@ -0,0 +1,27 @@
"""Accomodation."""
import csv
import os
from datetime import datetime
from .types import Event
url = "https://admin.gandi.net/domain/01578ef0-a84b-11e7-bdf3-00163e6dc886/"
def renewal_dates(data_dir: str) -> list[Event]:
"""Get domain renewal dates."""
domain_files = [
(datetime.strptime(f, "export_domains_%m_%d_%Y_%I_%M_%p.csv"), f)
for f in os.listdir(data_dir)
if f.startswith("export_domains_")
]
return [
Event(
name="domain",
title=row["fqdn"],
date=datetime.fromisoformat(row["date_registry_end_utc"][:10]).date(),
url=url + row["fqdn"],
)
for row in csv.DictReader(open(os.path.join(data_dir, max(domain_files)[1])))
]