Skip to content

Commit f992384

Browse files
committed
Fix BtB mix of capital letters bug
1 parent 9ae4b6a commit f992384

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

database/scrape_trle_download.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ def _get_trcustoms_download_info(trcustom_level_dict):
190190
def _get_trle_btb_download_info(trle_btb_url, lid):
191191
zip_file = data_factory.make_zip_file()
192192
parted = trle_btb_url.split("BtB")
193-
btb_soup = scrape_common.get_soup(parted[0] + "BtB" + "/Web/downloads.html")
194-
193+
btb_soup = None
194+
for case in ["web", "Web"]:
195+
btb_soup = scrape_common.get_soup(parted[0] + "BtB" + f"/{case}/downloads.html")
196+
if btb_soup:
197+
break # Stop when a valid response is found
198+
199+
if not btb_soup:
200+
print("Fucked up")
201+
sys.exit(1)
195202
trle_info = _get_trle_info(lid)
196203
trle_title = trle_info[0]
197204
trle_zip_size = trle_info[2]
@@ -309,6 +316,7 @@ def get_zip_file_info(lid):
309316
_check_lid(lid)
310317
head = scrape_common.https.get(f"https://www.trle.net/scadm/trle_dl.php?lid={lid}", 'head')
311318
if head:
319+
print(f"head: {head}")
312320
redirect_url = head.partition("Location: ")[2].split("\r\n", 1)[0]
313321
print(f"Location: {redirect_url}")
314322
if redirect_url:
@@ -320,8 +328,8 @@ def get_zip_file_info(lid):
320328
trle_info = _get_trle_info(lid)
321329
return _search_trcustoms(trle_info)
322330

323-
if redirect_url.endswith("/BtB/Web/index.html") and \
324-
redirect_url.startswith("https://www.trle.net/levels/levels/"):
331+
if redirect_url.lower().endswith("/btb/web/index.html") and \
332+
redirect_url.startswith("https://www.trle.net/levels/levels"):
325333
return _get_trle_btb_download_info(redirect_url, lid)
326334

327335
if redirect_url.endswith(".htm") and \

0 commit comments

Comments
 (0)