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
|
VERSION
|
||||||
DATE
|
DATE
|
||||||
NX-60FPS-RES-GFX-Cheats-main
|
NX-60FPS-RES-GFX-Cheats-main
|
||||||
|
@ -6,7 +6,7 @@ import cloudscraper
|
|||||||
import json
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import date
|
from datetime import date, datetime
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
import process_cheats
|
import process_cheats
|
||||||
@ -40,12 +40,10 @@ class GbatempCheatsInfo:
|
|||||||
self.gbatemp_version = self.fetch_gbatemp_version()
|
self.gbatemp_version = self.fetch_gbatemp_version()
|
||||||
|
|
||||||
def fetch_gbatemp_version(self):
|
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")
|
soup = BeautifulSoup(page.content, "html.parser")
|
||||||
# There are two occurances of the version, we pick the biggest one
|
version = datetime.fromisoformat(soup.find("div", {"class": "block-container"}).find("time").get("datetime"))
|
||||||
version1 = version_parser(soup.find("ol", {"class": "block-body"}).find("div").getText())
|
return version.date()
|
||||||
version2 = version_parser(soup.find("span", {"class": "u-muted"}).getText())
|
|
||||||
return max(version1, version2)
|
|
||||||
|
|
||||||
def has_new_cheats(self, database_version):
|
def has_new_cheats(self, database_version):
|
||||||
return self.gbatemp_version > database_version
|
return self.gbatemp_version > database_version
|
||||||
|
@ -39,7 +39,7 @@ class ProcessCheats:
|
|||||||
lines = cheatSheet.readlines()
|
lines = cheatSheet.readlines()
|
||||||
|
|
||||||
for i in range(len(lines)):
|
for i in range(len(lines)):
|
||||||
titles = re.search("(\[.+\]|\{.+\})", lines[i])
|
titles = re.search(r"(\[.+\]|\{.+\})", lines[i])
|
||||||
if titles:
|
if titles:
|
||||||
pos.append(i)
|
pos.append(i)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user