All checks were successful
Build and push / changes (push) Successful in 7s
Build and push / Lint-Python (push) Successful in 2s
Build and push / Build-and-Push-Docker (push) Successful in 2m31s
Build and push / sync-argocd-app (push) Successful in 2s
Build and push / post-status-to-discord (push) Successful in 2s
91 lines
2.5 KiB
Python
Executable File
91 lines
2.5 KiB
Python
Executable File
from bs4 import BeautifulSoup
|
|
import requests
|
|
|
|
|
|
def request_wiki(url, heading):
|
|
response = requests.get(
|
|
"https://escapefromtarkov.fandom.com/wiki/Category:" + url, timeout=25
|
|
).text
|
|
soup = BeautifulSoup(response, "html.parser")
|
|
h2_heading = soup.find("h2", string=f'Pages in category "{heading}"')
|
|
return [link.text for link in h2_heading.find_next("div").find_all("a")]
|
|
|
|
|
|
def query_tarkov_api(query):
|
|
headers = {"Content-Type": "application/json"}
|
|
return requests.post(
|
|
"https://api.tarkov.dev/graphql", headers=headers, json={"query": query}
|
|
).json()["data"]
|
|
|
|
|
|
def get_tarkov_boss_info():
|
|
"""
|
|
Returns a dict of boss spawn chances per map, and their escorts
|
|
"""
|
|
|
|
query = """{
|
|
maps {
|
|
name
|
|
bosses {
|
|
name
|
|
spawnChance
|
|
escorts {
|
|
boss {
|
|
name
|
|
}
|
|
amount {
|
|
count
|
|
}
|
|
}
|
|
boss {
|
|
name
|
|
imagePortraitLink
|
|
}
|
|
}
|
|
}
|
|
}"""
|
|
|
|
dont_care = [
|
|
"assault",
|
|
"BEAR",
|
|
"USEC",
|
|
]
|
|
response = query_tarkov_api(query)["maps"]
|
|
|
|
# Wasteful, but make a new dict to hold the info we care about
|
|
levels = {}
|
|
for level in response:
|
|
levels[level["name"]] = {
|
|
boss["boss"]["name"]: {
|
|
"escorts": sum(
|
|
escort["amount"][0]["count"] for escort in boss["escorts"]
|
|
),
|
|
"spawnChance": f"**{str(round(boss['spawnChance'] * 100, 2))}%**",
|
|
"picture": boss["boss"]["imagePortraitLink"],
|
|
}
|
|
for boss in level["bosses"]
|
|
if boss["boss"]["name"] not in dont_care
|
|
}
|
|
|
|
return dict(sorted(levels.items()))
|
|
|
|
|
|
def compare_boss_spawns(known_spawns: dict, spawns_from_api: dict) -> dict:
|
|
changes = {} # To store the changes
|
|
|
|
for level in known_spawns:
|
|
level_changes = {} # Store changes for each level
|
|
for boss in known_spawns.get(level, {}):
|
|
known_boss_info = known_spawns[level].get(boss, {})
|
|
api_boss_info = spawns_from_api[level].get(boss, {})
|
|
|
|
old = known_boss_info.get("spawnChance", "**0%**")
|
|
new = api_boss_info.get("spawnChance", "**0%**")
|
|
|
|
if new != old:
|
|
level_changes[boss] = f"{old} -> {new}"
|
|
|
|
changes[level] = level_changes
|
|
|
|
return changes
|