Skip to content

Commit 1cbbe0e

Browse files
committed
fix updating
the test database is now empty but I'll be indexing them all soon
1 parent 63c4b00 commit 1cbbe0e

14 files changed

+379
-499
lines changed

database/README.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,41 @@
11
# This is a test database
22

3-
I will list the games in the database here by id number.
3+
I list some levels I have tested.
44

55
You can access the game files here ~/.local/share/TombRaiderLinuxLauncher/ID.TRLE
6-
where ID is the number listed here.
7-
If you use you own database you can update it
8-
with updateDB_1.0.0.py then updateDB_1.1.0.py then to updateDB_1.1.1.py.
9-
But make backup before. I can implement in app json scraping from trcustoms.org
10-
to get new levels. It has a nice json api with minimal compact data for info and nice
11-
picture urls with md5sums. There can be and index database that
12-
get new level id numbers from trcustoms.org or trle.net with very minimal traffic.
6+
where ID is the number listed when runngin tombll_manage_data.py -l
137

14-
1. The Infada Cult
8+
3573. The Infada Cult
159
* <https://www.trle.net/sc/levelfeatures.php?lid=3573>
1610
* <https://trcustoms.org/levels/3574>
1711
* have played through
1812
* no problems
1913

20-
2. Templars Secret
14+
3082. Templars Secret
2115
* <https://www.trle.net/sc/levelfeatures.php?lid=3082>
2216
* <https://trcustoms.org/levels/3025>
2317
* have played through
2418
* no problems
2519

26-
3. Secret of the Skull Temple
20+
3377. Secret of the Skull Temple
2721
* <https://www.trle.net/sc/levelfeatures.php?lid=3377>
2822
* <https://trcustoms.org/levels/3310>
2923
* have played through
30-
* lags sometimes
31-
* plying with lutris and dgvoodoo, can help
24+
* lags sometimes, plying with dgvoodoo can help
3225

33-
4. The Rescue 1-4
26+
318. The Rescue 1-4
3427
* <https://www.trle.net/sc/levelfeatures.php?lid=318>
3528
* <https://trcustoms.org/levels/317>
3629
* have not played through all of the game
3730
* no problems
3831

39-
5. War of the Worlds
32+
3430. War of the Worlds
4033
* <https://www.trle.net/sc/levelfeatures.php?lid=3430>
4134
* <https://trcustoms.org/levels/3363>
4235
* have not played through all of the game
4336
* plying with lutris and dgvoodoo, fix flashlight bug
4437

45-
6. The Hidden Dagger II - Dragon's Legacy
38+
3621. The Hidden Dagger II - Dragon's Legacy
4639
* <https://www.trle.net/sc/levelfeatures.php?lid=3621>
4740
* <https://trcustoms.org/levels/3642>
4841
* Starts the game and first map, backgrund audio is missing
@@ -53,13 +46,13 @@ get new level id numbers from trcustoms.org or trle.net with very minimal traffi
5346
* and run it from there right now
5447
* use dll ovride winmm=n,b
5548

56-
7. Create a Classic 2021 - The City of Petra
49+
3417. Create a Classic 2021 - The City of Petra
5750
* <https://www.trle.net/sc/levelfeatures.php?lid=3417>
5851
* <https://trcustoms.org/levels/3350>
5952
* have not played through all of the game
6053
* no problems
6154

62-
8. Into the Realm of Eternal Darkness
55+
3557. Into the Realm of Eternal Darkness
6356
* <https://www.trle.net/sc/levelfeatures.php?lid=3557>
6457
* <https://trcustoms.org/levels/3541>
6558
* have not played through all of the game
@@ -80,19 +73,19 @@ get new level id numbers from trcustoms.org or trle.net with very minimal traffi
8073
just package-linux
8174
```
8275

83-
9. The Experiment 3/1 - Under the Moonlight
76+
1388. The Experiment 3/1 - Under the Moonlight
8477
* <https://www.trle.net/sc/levelfeatures.php?lid=1388>
8578
* <https://trcustoms.org/levels/1360>
8679
* have not played through all of the game
8780
* no problems
8881

89-
10. The Ancient Knowledge
82+
1964. The Ancient Knowledge
9083
* <https://www.trle.net/sc/levelfeatures.php?lid=1964>
9184
* <https://trcustoms.org/levels/1947>
9285
* have not played through all of the game
9386
* no problems
9487

95-
11. Tomb Raider - Biohazard
88+
3372. Tomb Raider - Biohazard
9689
* <https://www.trle.net/sc/levelfeatures.php?lid=3372>
9790
* <https://trcustoms.org/levels/3305>
9891
* have not played through all of the game

database/data_factory.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,12 @@ def make_zip_file():
8383
"release": "",
8484
"version": ""
8585
}
86+
87+
88+
def make_picture():
89+
"""trcustoms.org or TRLE picture data."""
90+
return {
91+
"position": 0,
92+
"md5sum": "",
93+
"md5": b''
94+
}

database/index.db

-1.7 MB
Binary file not shown.

database/main.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Main loop for CLI menu like interfaces"""
1+
"""Main loop for CLI menu like interfaces."""
22
import sys
33
import os
44
import time
@@ -53,20 +53,15 @@ def test_trle_pic_local():
5353

5454

5555
def test_insert_trle_book():
56-
"""This must not bother the server but at the same time its not
57-
meant for normal users but the database admin to run this,
58-
it could take 30-45 min. there is a problem about how TRLE sort result
59-
so this method might not work, cus it will miss results, there is another
60-
method that is much slower but will work and accurate"""
61-
56+
"""Make a book."""
6257
# Get the first page to determine the total number of records
6358
page = scrape_trle.get_trle_page(0)
6459
total_records = page['records_total']
6560

6661
# Insert the first page of data
6762
index_query.insert_trle_page(page)
6863
print(f"Records number:20 of {total_records}")
69-
time.sleep(15)
64+
time.sleep(3)
7065

7166
# Start offset at 20 and loop through all records in steps of 20
7267
offset = 20
@@ -82,12 +77,12 @@ def test_insert_trle_book():
8277
offset += 20
8378
print(f"Records number:{offset} of {total_records}")
8479

85-
# Introduce a random delay of 15 seconds
86-
time.sleep(15)
80+
# Introduce a random delay of 3 seconds
81+
time.sleep(3)
8782

8883

8984
def show_menu():
90-
"""Main menu"""
85+
"""Print main menu."""
9186
print("\nPlease select a command:")
9287
print("1. new - Create a new empty index database and add static data")
9388
print("2. new - Create a new full index database, without info and walkthrough data")

database/make_tombll_database.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class INT,
108108
C.execute('''
109109
CREATE TABLE Picture (
110110
PictureID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
111+
md5sum TEXT NOT NULL UNIQUE,
111112
data BLOB NOT NULL
112113
)''')
113114

@@ -130,7 +131,9 @@ class INT,
130131
CREATE TABLE Screens (
131132
pictureID INTEGER NOT NULL,
132133
levelID INTEGER NOT NULL,
134+
position INTEGER NOT NULL,
133135
PRIMARY KEY (pictureID, levelID),
136+
UNIQUE (levelID, position),
134137
FOREIGN KEY (pictureID) REFERENCES Picture(PictureID),
135138
FOREIGN KEY (levelID) REFERENCES Level(LevelID)
136139
)''')

database/scrape_common.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def trle_search_parser(url):
334334
.replace("'", r"%5C%27")
335335

336336

337-
def url_postfix(url):
337+
def url_basename_postfix(url):
338338
"""
339339
Extract the file extension from a URL without the leading dot.
340340
@@ -348,6 +348,20 @@ def url_postfix(url):
348348
return os.path.splitext(os.path.basename(urlparse(url).path))[1][1:]
349349

350350

351+
def url_basename_prefix(url):
352+
"""
353+
Extract the file naem from a URL without the extension.
354+
355+
Args:
356+
url (str): The URL to extract the file extension from.
357+
358+
Returns:
359+
str: The file name without the extension,
360+
or an empty string if no extension is present.
361+
"""
362+
return os.path.splitext(os.path.basename(urlparse(url).path))[0]
363+
364+
351365
###############################################################################
352366
# getter's for https
353367
###############################################################################
@@ -391,7 +405,7 @@ def get_image(url):
391405
if validate_url(url) is None:
392406
print(f"{url} had wrong domain")
393407
sys.exit(1)
394-
ext = url_postfix(url).lower()
408+
ext = url_basename_postfix(url).lower()
395409
if ext in ('jpg', 'jpeg'):
396410
return get_jpg(url)
397411
if ext == 'png':

database/scrape_trle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def get_trle_walkthrough(level_soup):
283283
url = "https://www.trle.net" + iframe_src
284284

285285
# Check the type of "document"
286-
typ = scrape_common.url_postfix(url)
286+
typ = scrape_common.url_basename_postfix(url)
287287
if typ == 'jpg':
288288
# we should handle all images here but right now
289289
# we return "" this is a bit more complex

database/tombll.db

-3.49 MB
Binary file not shown.

0 commit comments

Comments
 (0)