Include URL in live.yaml
This commit is contained in:
parent
aa22d76699
commit
ff0d81f32c
39
check.py
39
check.py
|
@ -7,6 +7,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import smtplib
|
import smtplib
|
||||||
import warnings
|
import warnings
|
||||||
|
from dataclasses import dataclass
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.utils import formatdate, make_msgid
|
from email.utils import formatdate, make_msgid
|
||||||
|
@ -168,20 +169,15 @@ def parse_opengraph_tags(html: str) -> dict[str, str]:
|
||||||
return og_tags
|
return og_tags
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class Conference:
|
class Conference:
|
||||||
"""Conference."""
|
"""Conference."""
|
||||||
|
|
||||||
name: str
|
name: str
|
||||||
src_url: str
|
src_url: str
|
||||||
year: int
|
year: int
|
||||||
response: None | requests.models.Response
|
response: requests.models.Response | None = None
|
||||||
|
redirect_to_url: str | None = None
|
||||||
def __init__(self, name: str, src_url: str, year: int):
|
|
||||||
"""Init."""
|
|
||||||
self.name = name
|
|
||||||
self.src_url = src_url
|
|
||||||
self.year = year
|
|
||||||
self.response = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self) -> str:
|
def url(self) -> str:
|
||||||
|
@ -246,6 +242,7 @@ class Conference:
|
||||||
):
|
):
|
||||||
body = f"{self.name}\n{self.url}\n"
|
body = f"{self.name}\n{self.url}\n"
|
||||||
else:
|
else:
|
||||||
|
self.redirect_to_url = redirect_to_url
|
||||||
body = f"{self.name}\n{self.url} redirects to {redirect_to_url}\n"
|
body = f"{self.name}\n{self.url} redirects to {redirect_to_url}\n"
|
||||||
|
|
||||||
body += f"Web page title: {msg}{og}" ""
|
body += f"Web page title: {msg}{og}" ""
|
||||||
|
@ -277,12 +274,6 @@ def send_mail(subject: str, body: str) -> None:
|
||||||
s.quit()
|
s.quit()
|
||||||
|
|
||||||
|
|
||||||
def check(name: str, src_url: str, year: int) -> bool:
|
|
||||||
"""Check to see if conference site is live."""
|
|
||||||
conf = Conference(name, src_url, year)
|
|
||||||
return conf.check_web_site()
|
|
||||||
|
|
||||||
|
|
||||||
def find_new_conference_web_sites(
|
def find_new_conference_web_sites(
|
||||||
today: date, live: list[LiveConference]
|
today: date, live: list[LiveConference]
|
||||||
) -> list[LiveConference]:
|
) -> list[LiveConference]:
|
||||||
|
@ -293,11 +284,21 @@ def find_new_conference_web_sites(
|
||||||
|
|
||||||
live_set = {(c["conference"], c["year"]) for c in live}
|
live_set = {(c["conference"], c["year"]) for c in live}
|
||||||
for name, src_url in load_yaml("conferences").items():
|
for name, src_url in load_yaml("conferences").items():
|
||||||
new += [
|
for year in (this_year, this_year + 1):
|
||||||
{"conference": name, "year": year, "live": today}
|
if (name, year) in live_set:
|
||||||
for year in (this_year, this_year + 1)
|
continue
|
||||||
if (name, year) not in live_set and check(name, src_url, year)
|
conf = Conference(name, src_url, year)
|
||||||
]
|
if not conf.check_web_site():
|
||||||
|
continue
|
||||||
|
c: LiveConference = {
|
||||||
|
"conference": name,
|
||||||
|
"year": year,
|
||||||
|
"live": today,
|
||||||
|
"url": conf.url,
|
||||||
|
}
|
||||||
|
if conf.redirect_to_url:
|
||||||
|
c["redirect_to_url"] = conf.redirect_to_url
|
||||||
|
new.append(c)
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ class LiveConference(typing.TypedDict, total=False):
|
||||||
year: int
|
year: int
|
||||||
live: date
|
live: date
|
||||||
url: str | None
|
url: str | None
|
||||||
|
redirect_to_url: str | None
|
||||||
|
|
||||||
|
|
||||||
def load_yaml(name: str) -> typing.Any:
|
def load_yaml(name: str) -> typing.Any:
|
||||||
|
|
Loading…
Reference in a new issue