forked from masagrator/FPSLocker-Warehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckUpdate.py
73 lines (68 loc) · 2.35 KB
/
CheckUpdate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from github import Github
from urllib.request import Request, urlopen
import json
import re
import sys
class DATA:
database = {}
def DownloadDatabase():
g = Github()
try:
repo = g.get_repo("blawar/titledb")
except:
print("Github API requests limit was achieved.")
print("We cannot check when last time file was updated.")
else:
commits = repo.get_commits(path="versions.txt")
print("Last database update (YYYY/MM/DD):")
print(commits[0].commit.committer.date)
print("\n---\n")
site = "https://github.com/blawar/titledb/raw/master/versions.txt"
request_site = Request(site, headers={"User-Agent": "Mozilla/5.0"})
text = urlopen(request_site).read().decode("ascii").split("\n")
for line in text:
if (line.find("id") != -1):
continue
array = line.rstrip("\n").rstrip("\r").split("|")
if (len(array) < 3):
continue
if (array[2] == ""):
continue
DATA.database[array[0]] = int(int(array[2]) / 65536)
print("Downloading database...")
DownloadDatabase()
file = open("README.md", "r", encoding="UTF-8")
for line in file:
if line.find("| `0100") == -1:
continue
gameTitle = line.split("|")[1]
pos = line.find("| `0100") + 3
titleid = line[pos:pos+16].upper()
if titleid[15:16] != "0":
continue
versionColumn = line.split("|")[3]
pos = versionColumn.find(", v") + 3
if (versionColumn.find("<br>") == -1):
version = int(re.sub("\D", "", versionColumn[pos:pos+2]))
else:
pos = versionColumn.rfind("<br>")
pos = versionColumn.find(", v", pos) + 3
version = int(re.sub("\D", "", versionColumn[pos:pos+2]))
try:
latestUpdate = DATA.database[titleid]
except:
print(f"Titleid not found: {titleid}")
print(f"Title:{gameTitle}\n")
continue
try:
latestUpdate = DATA.database[titleid[:13] + "800"]
except:
pass
if (version != latestUpdate):
print(titleid)
print(f"Title:{gameTitle}")
print(f"Newest update: v{latestUpdate}")
print(f"Latest patch: v{version}")
if (line.count("`0100") > 1):
print("Game has more than one titleid! Possible mismatch")
print("---")