mirror of
https://github.com/HamletDuFromage/switch-cheats-db.git
synced 2025-04-24 08:25:17 +00:00
make date fetcher more robust
This commit is contained in:
parent
75e33d371e
commit
26b1809348
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
venv/
|
||||
VERSION
|
||||
DATE
|
||||
NX-60FPS-RES-GFX-Cheats-main
|
||||
|
@ -6,7 +6,7 @@ import cloudscraper
|
||||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from datetime import date
|
||||
from datetime import date, datetime
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
import process_cheats
|
||||
@ -40,12 +40,10 @@ class GbatempCheatsInfo:
|
||||
self.gbatemp_version = self.fetch_gbatemp_version()
|
||||
|
||||
def fetch_gbatemp_version(self):
|
||||
page = self.scraper.get(self.page_url)
|
||||
page = self.scraper.get(f"{self.page_url}/updates")
|
||||
soup = BeautifulSoup(page.content, "html.parser")
|
||||
# There are two occurances of the version, we pick the biggest one
|
||||
version1 = version_parser(soup.find("ol", {"class": "block-body"}).find("div").getText())
|
||||
version2 = version_parser(soup.find("span", {"class": "u-muted"}).getText())
|
||||
return max(version1, version2)
|
||||
version = datetime.fromisoformat(soup.find("div", {"class": "block-container"}).find("time").get("datetime"))
|
||||
return version.date()
|
||||
|
||||
def has_new_cheats(self, database_version):
|
||||
return self.gbatemp_version > database_version
|
||||
|
@ -39,7 +39,7 @@ class ProcessCheats:
|
||||
lines = cheatSheet.readlines()
|
||||
|
||||
for i in range(len(lines)):
|
||||
titles = re.search("(\[.+\]|\{.+\})", lines[i])
|
||||
titles = re.search(r"(\[.+\]|\{.+\})", lines[i])
|
||||
if titles:
|
||||
pos.append(i)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user