Skip to content

Commit

Permalink
Update tikdb.py
Browse files Browse the repository at this point in the history
vaultdb changed the way the content is compressed, but it's been fixed now
  • Loading branch information
Cristiano committed Apr 25, 2019
1 parent c015887 commit edc2335
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tikdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
root = pathlib.Path(os.getcwd())
tmpfold = root / "tikdb_tmpfold"
try: os.mkdir(tmpfold)
except OSError:
except FileExistsError:
print("[WARNING] Temp folder already created...")
shutil.rmtree(tmpfold,True)
os.mkdir(tmpfold)
Expand Down Expand Up @@ -41,14 +41,14 @@ def parse_titledb():
# parse name
result = name_pattern.search(text,end_title,next_title)
if result is None:
result = title_pattern.search(text,next_title)
result = next_title_result
continue
start_name, end_name = result.span()
name = text[start_name:end_name]
# parse region
result = reg_pattern.search(text,end_name,next_title)
if result is None:
result = title_pattern.search(text,next_title)
result = next_title_result
continue
start_reg, end_reg = result.span()
region = (text[start_reg:end_reg]).upper()
Expand Down Expand Up @@ -82,7 +82,14 @@ def download_tickets_from_vault():
open(vaultdb, 'wb').write(r.content)
tar = tarfile.open(vaultdb)
tar.extractall()
os.chdir('ticket') # cwd: tmpfold/ticket
tar.close()
os.remove(vaultdb)
# search for tickets
for dirpath, _, files in os.walk(tmpfold):
tiks = [x for x in files if '.tik' in x]
if len(tiks) != 0:
os.chdir(dirpath)
break

download_tickets_from_vault()

Expand All @@ -93,9 +100,8 @@ def download_tickets_from_vault():
# make region folders
regs = ['EUR','USA','JPN']
for reg in regs:
try:
os.mkdir(reg)
except OSError:
try: os.mkdir(reg)
except FileExistsError:
print("[WARNING] " + reg + " folder already created...")
shutil.rmtree(reg,True)
os.mkdir(reg)
Expand Down Expand Up @@ -123,7 +129,8 @@ def download_tickets_from_vault():
try: os.mkdir(name_path) # same game can have multiple folders (dlcs and updates)
except FileExistsError: pass
os.mkdir(title_path)
os.rename(tik, title_path / 'title.tik')
shutil.copyfile(tik, title_path / 'title.tik')
#os.rename(tik, title_path / 'title.tik')

# all tickets moved into folders, time to zip
def zipdir(path, ziph):
Expand Down

0 comments on commit edc2335

Please sign in to comment.