Skip to content

Commit 06ce8d3

Browse files
committed
add War of the worlds download, hardcoded
1 parent 1d40fb7 commit 06ce8d3

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

database/scrape_trle_download.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,15 @@ def _get_generic_download(soup):
251251
return link
252252

253253

254+
def _get_war_of_the_worlds_download():
255+
zip_file = data_factory.make_zip_file()
256+
zip_file['name'] = "MD-WarOfTheWorlds.zip"
257+
zip_file['size'] = 2246.00
258+
zip_file['md5'] = "MISSING"
259+
zip_file['url'] = "https://www.trle.net/levels/levels/2021/1221/MD-WarOfTheWorlds.zip"
260+
return zip_file
261+
262+
254263
def _get_trlevel_download_info(trle_info):
255264
zip_file = []
256265
url = "https://www.trlevel.de/filebase/index.php?category-file-list/558-trle-custom-levels/"
@@ -348,26 +357,29 @@ def get_zip_file_info(lid):
348357
redirect_url.startswith("https://www.trle.net/levels/levels/"):
349358
files = [_get_download_info(lid, redirect_url)]
350359

351-
if redirect_url.startswith("https://www.trle.net/sc/levelfeatures.php?lid=") or \
360+
elif redirect_url.startswith("https://www.trle.net/sc/levelfeatures.php?lid=") or \
352361
redirect_url == "https://www.trlevel.de":
353362
trle_info = _get_trle_info(lid)
354363
files.extend(_search_trcustoms(trle_info))
355364
files.extend(_get_trlevel_download_info(trle_info))
356365

357-
if redirect_url.lower().endswith("/btb/web/index.html") and \
366+
elif redirect_url.startswith("https://trcustoms.org/levels/") and \
367+
redirect_url.split("/")[-1].isdigit():
368+
api_url = f"https://trcustoms.org/api/levels/{redirect_url.split("/")[-1]}/"
369+
trcustoms_level_dict = scrape_common.get_json(api_url)
370+
files = [_get_trcustoms_download_info(trcustoms_level_dict)]
371+
372+
elif redirect_url.lower().endswith("/btb/web/index.html") and \
358373
redirect_url.startswith("https://www.trle.net/levels/levels"):
359374
files = [_get_trle_btb_download_info(redirect_url, lid)]
360375

361-
if redirect_url.endswith(".htm") and \
376+
elif redirect_url.endswith(".htm") and \
362377
redirect_url.startswith("https://www.trle.net/levels/levels/"):
363378
url = _get_generic_download(scrape_common.get_soup(redirect_url))
364379
files = [_get_download_info(lid, url)]
365380

366-
if redirect_url.startswith("https://trcustoms.org/levels/") and \
367-
redirect_url.split("/")[-1].isdigit():
368-
api_url = f"https://trcustoms.org/api/levels/{redirect_url.split("/")[-1]}/"
369-
trcustoms_level_dict = scrape_common.get_json(api_url)
370-
files = [_get_trcustoms_download_info(trcustoms_level_dict)]
381+
elif redirect_url == "https://sites.google.com/view/trwotw/war-of-the-worlds/download":
382+
files = [_get_war_of_the_worlds_download()]
371383

372384
return files
373385

0 commit comments

Comments
 (0)