live addon parsing

master
JoYo 2021-12-14 19:01:38 -05:00
parent 368413bb51
commit a5daac007d
2 changed files with 30 additions and 2 deletions

View File

@ -1,10 +1,15 @@
import requests
import re
from pathlib import Path
import logging
import re
import requests
esoui_prefix = re.compile("https://www.esoui.com/downloads/info[0-9]+\-")
esoui_version_html = re.compile('<div\s+id="version">Version:\s+[^<]+')
esoui_version_split = re.compile('<div\s+id="version">Version:\s+')
live_title = re.compile("##\s+Title:\s+.*")
live_title_split = re.compile("##\s+Title:\s+")
live_version = re.compile("##\s+Version:\s+.*")
live_version_split = re.compile("##\s+Version:\s+")
def esoui(url: str):
@ -20,3 +25,16 @@ def esoui(url: str):
response.raise_for_status()
return addon_name, version, esoui_dowload_uri
def live_addon(path: Path):
for meta in path.glob("*.txt"):
with meta.open("r") as file_open:
meta_data = file_open.read()
title = live_title.search(meta_data)
title = live_title_split.split(title.group(0))[1]
version = live_version.search(meta_data)
version = live_version_split.split(version.group(0))[1]
return title, version

View File

@ -54,3 +54,13 @@ def periodical_script():
for url in addon_urls:
esoui = parsing.esoui(url)
logging.info(esoui)
live_path = Path(args.eso_live_path).joinpath("AddOns")
if not live_path.is_dir():
logging.error(f"eso_live_path_invalid_dir {live_path}")
return
for child in live_path.iterdir():
live_addon = parsing.live_addon(child)
logging.info(live_addon)