Skip to content

Commit

Permalink
Code Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
0AwsD0 committed May 4, 2024
1 parent 076cad1 commit 72d988e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 65 deletions.
45 changes: 12 additions & 33 deletions download.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
#BTW selenium 420 ~blaze it XD

def download(**data):
print("Download function invoked with arguments: ", data)

#below code checks if the basic option is selected - if yes -> the universal function will be invoked | if no -> the advanced functions will be invoked - tailored to the data that is for set game type
try:
if data["mode"] == "basic":
print("Basic mode activated.")
if data["game"] == "KK":
url = "https://db.bepis.moe/koikatsu"
basic_download(url, data["name"], data["tags"])
elif data["game"] == "AA2":
url = "https://db.bepis.moe/aa2"
basic_download(url, data["name"], data["tags"])
elif data["game"] == "HS":
url = "https://db.bepis.moe/honeyselect"
basic_download(url, data["name"], data["tags"])
elif data["game"] == "PH":
url = "https://db.bepis.moe/playhome"
basic_download(url, data["name"], data["tags"])
elif data["game"] == "AI_HS2":
url = "https://db.bepis.moe/aishoujo"
basic_download(url, data["name"], data["tags"])
elif data["game"] == "COM3D2":
url = "https://db.bepis.moe/com3d2"
basic_download(url, data["name"], data["tags"])
elif data["game"] == "SH":
url = "https://db.bepis.moe/summerheat"
basic_download(url, data["name"], data["tags"])
elif data["game"] == "HC":
url = "https://db.bepis.moe/honeycome"
basic_download(url, data["name"], data["tags"])
else:
print("ERROR! Unknown value at key -> 'game' | Program will exit in 5 seconds.")
time.sleep(5)
exit(code=1)
basic_download(data["url"], data["name"], data["tags"])
else:
advanced_download(data)
except Exception:
print("ERROR - basic_download couldn't be invoked. Is website down?")
print("ERROR - download function couldn't be invoked. Is website down?")
print("Exiting in 5 seconds.")
time.sleep(5)
exit(1)

advanced_download()


def basic_download(url, name, tags):
Expand Down Expand Up @@ -128,7 +105,7 @@ def basic_download(url, name, tags):
url2 = url
print("Got url - adding page number...")
url2 += "&page=" + str(i)
print("I got url - waiting 5 seconds for page to load...")
print("Waiting 5 seconds for page to load...")
driver.get(url2)
time.sleep(5)
i2 = 1
Expand All @@ -141,12 +118,14 @@ def basic_download(url, name, tags):
exit(1)
except Exception:
print("Exception in basic_download(): "+Exception)
print("Exiting in 5 seconds.")
time.sleep(5)
driver.quit()
exit(1)

def advanced_download():
def advanced_download(data):
print("Advanced download function invoked")
print("DATA: "+data)
#KK download(game = game, name = name, tags = tags, gender = gender, personality = personality, game_type = game_type, modded_content = modded_content, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
#AA2 download(game = game, name = name, tags = tags, gender = gender, personality = personality, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured) *
#HS download(game = game, name = name, tags = tags, gender = gender, personality = personality, game_type = game_type, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
Expand Down
72 changes: 40 additions & 32 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,74 +18,82 @@ def menu():
#for all of em like KK AA2 for example - kk.txt -> contains setings for that one | AA2.txt -> contains settings for that one / if the row isblank the user inoputs the data here like -> tags = long_hair; name = ; <- will be prompted toinsert name in consoleor click enter to set default
if selected == "1":
game = "KK"
url = "https://db.bepis.moe/koikatsu"
print("If you wish to enter only name and/or tags press 1 or ENTER (or anything else really). For advance download press 2.")
selected = input()
if selected == "2":
KK(game)
KK(game, url)
else:
basic(game)
basic(game, url)
elif selected == "2":
game = "AA2"
url = "https://db.bepis.moe/aa2"
print("If you wish to enter only name and/or tags press 1 or ENTER (or anything else really). For advance download press 2.")
selected = input()
if selected == "2":
AA2_and_AI_HS2(game)
AA2_and_AI_HS2(game, url)
else:
basic(game)
basic(game, url)
elif selected == "3":
game = "HS"
url = "https://db.bepis.moe/honeyselect"
print("If you wish to enter only name and/or tags press 1 or ENTER (or anything else really). For advance download press 2.")
selected = input()
if selected == "2":
HS(game)
HS(game, url)
else:
basic(game)
basic(game, url)
elif selected == "4":
game = "PH"
url = "https://db.bepis.moe/playhome"
print("If you wish to enter only name and/or tags press 1 or ENTER (or anything else really). For advance download press 2.")
selected = input()
if selected == "2":
PH(game)
PH(game, url)
else:
basic(game)
basic(game, url)
elif selected == "5":
game = "AI_HS2"
url = "https://db.bepis.moe/aishoujo"
print("If you wish to enter only name and/or tags press 1 or ENTER (or anything else really). For advance download press 2.")
selected = input()
if selected == "2":
AA2_and_AI_HS2(game)
AA2_and_AI_HS2(game, url)
else:
basic(game)
basic(game, url)
elif selected == "6":
game = "COM3D2"
url = "https://db.bepis.moe/com3d2"
print("If you wish to enter only name and/or tags press 1 or ENTER (or anything else really). For advance download press 2.")
selected = input()
if selected == "2":
COM3D2(game)
COM3D2(game, url)
else:
basic(game)
basic(game, url)
elif selected == "7":
game = "SH"
url = "https://db.bepis.moe/summerheat"
print("If you wish to enter only name and/or tags press 1 or ENTER (or anything else really). For advance download press 2.")
selected = input()
if selected == "2":
SH(game)
SH(game, url)
else:
basic(game)
basic(game, url)
elif selected == "8":
game = "HC"
url = "https://db.bepis.moe/honeycome"
print("If you wish to enter only name and/or tags press 1 or ENTER (or anything else really). For advance download press 2.")
selected = input()
if selected == "2":
HC(game)
HC(game, url)
else:
basic(game)
basic(game, url)
else:
print("Please select one of the correct options (1-6):")
main()


def KK(game):
def KK(game, url):
print("Enter in order (or use config file) the parameters or press enter to set default.")
print("Name: (text) <Default> = blank")
name = input()
Expand All @@ -105,10 +113,10 @@ def KK(game):
show_hidden = input()
print("Show only featured: (checkbox - enter '1' to check - 0 or nothig to leave unchecked <Default>)")
show_only_featured = input()
download(game = game, name = name, tags = tags, gender = gender, personality = personality, game_type = game_type, modded_content = modded_content, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
download(game = game, url = url, name = name, tags = tags, gender = gender, personality = personality, game_type = game_type, modded_content = modded_content, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)


def AA2_and_AI_HS2(game):
def AA2_and_AI_HS2(game, url):
print("Enter in order (or use config file) the parameters or press enter to set default.")
print("Name: (text) <Default> = blank")
name = input()
Expand All @@ -124,9 +132,9 @@ def AA2_and_AI_HS2(game):
show_hidden = input()
print("Show only featured: (checkbox - enter '1' to check - 0 or nothig to leave unchecked <Default>)")
show_only_featured = input()
download(game = game, name = name, tags = tags, gender = gender, personality = personality, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
download(game = game, url = url, name = name, tags = tags, gender = gender, personality = personality, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)

def HS(game):
def HS(game, url):
print("Enter in order (or use config file) the parameters or press enter to set default.")
print("Name: (text) <Default> = blank")
name = input()
Expand All @@ -144,10 +152,10 @@ def HS(game):
show_hidden = input()
print("Show only featured: (checkbox - enter '1' to check - 0 or nothig to leave unchecked <Default>)")
show_only_featured = input()
download(game = game, name = name, tags = tags, gender = gender, personality = personality, game_type = game_type, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
download(game = game, url = url, name = name, tags = tags, gender = gender, personality = personality, game_type = game_type, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)


def PH(game):
def PH(game, url):
print("Enter in order (or use config file) the parameters or press enter to set default.")
print("Name: (text) <Default> = blank")
name = input()
Expand All @@ -159,9 +167,9 @@ def PH(game):
show_hidden = input()
print("Show only featured: (checkbox - enter '1' to check - 0 or nothig to leave unchecked <Default>)")
show_only_featured = input()
download(game = game, name = name, tags = tags, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
download(game = game, url = url, name = name, tags = tags, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)

def COM3D2(game):
def COM3D2(game, url):
print("Enter in order (or use config file) the parameters or press enter to set default.")
print("Name: (text) <Default> = blank")
name = input()
Expand All @@ -175,10 +183,10 @@ def COM3D2(game):
show_hidden = input()
print("Show only featured: (checkbox - enter '1' to check - 0 or nothig to leave unchecked <Default>)")
show_only_featured = input()
download(game = game, name = name, tags = tags, preset_type = preset_type, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
download(game = game, url = url, name = name, tags = tags, preset_type = preset_type, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)


def SH(game):
def SH(game, url):
print("Enter in order (or use config file) the parameters or press enter to set default.")
print("Name: (text) <Default> = blank")
name = input()
Expand All @@ -190,9 +198,9 @@ def SH(game):
show_hidden = input()
print("Show only featured: (checkbox - enter '1' to check - 0 or nothig to leave unchecked <Default>)")
show_only_featured = input()
download(game = game, name = name, tags = tags, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
download(game = game, url = url, name = name, tags = tags, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)

def HC(game):
def HC(game, url):
print("Enter in order (or use config file) the parameters or press enter to set default.")
print("Name: (text) <Default> = blank")
name = input()
Expand All @@ -206,15 +214,15 @@ def HC(game):
show_hidden = input()
print("Show only featured: (checkbox - enter '1' to check - 0 or nothig to leave unchecked <Default>)")
show_only_featured = input()
download(game = game, name = name, tags = tags, gender = gender, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)
download(game = game, url = url, name = name, tags = tags, gender = gender, order_by = order_by, show_hidden = show_hidden, show_only_featured = show_only_featured)

def basic(game):
def basic(game, url):
print("Enter in order (or use config file) the parameters or press enter to set default.")
print("Name: (text) <Default> = blank")
name = input()
print("Tags: (text) <Default> = blank")
tags = input()
download(mode="basic", game=game, name=name, tags=tags)
download(mode = "basic", game = game, url = url, name=name, tags=tags)

def main():
menu()
Expand Down

0 comments on commit 72d988e

Please sign in to comment.