Even more error handling and stopped using Windows stupid ass backslash.
parent
2e647ae28d
commit
a1da7d3f2d
|
@ -11,10 +11,10 @@ main_directory = os.getcwd()
|
|||
|
||||
# Making sure a .wvd file exists and using that as the extracted device
|
||||
try:
|
||||
extracted_device = glob.glob(f'{main_directory}\\helper_scripts\\TPD_Keys\\CDMs\\*.wvd')[0]
|
||||
extracted_device = glob.glob(f'{main_directory}/helper_scripts/TPD_Keys/CDMs/*.wvd')[0]
|
||||
except:
|
||||
extracted_cdm = None
|
||||
print(f"Please place a WVD in {main_directory}\\helper_scripts\\TPD_Keys\\CDMs")
|
||||
print(f"Please place a WVD in {main_directory}/helper_scripts/TPD_Keys/CDMs")
|
||||
|
||||
|
||||
# Defining decrypt function
|
||||
|
@ -52,26 +52,35 @@ def decrypt_content(pssh: str = None, license_url: str = None,
|
|||
|
||||
# send license challenge
|
||||
if xdt_auth_token and auth_token is None:
|
||||
licence = requests.post(
|
||||
url=license_url,
|
||||
data=challenge,
|
||||
headers={
|
||||
'x-dt-auth-token': xdt_auth_token,
|
||||
}
|
||||
)
|
||||
try:
|
||||
licence = requests.post(
|
||||
url=license_url,
|
||||
data=challenge,
|
||||
headers={
|
||||
'x-dt-auth-token': xdt_auth_token,
|
||||
}
|
||||
)
|
||||
except Exception as error:
|
||||
return error
|
||||
elif auth_token and xdt_auth_token is None:
|
||||
licence = requests.post(
|
||||
url=license_url,
|
||||
data=challenge,
|
||||
headers={
|
||||
'Authorization': auth_token,
|
||||
}
|
||||
)
|
||||
try:
|
||||
licence = requests.post(
|
||||
url=license_url,
|
||||
data=challenge,
|
||||
headers={
|
||||
'Authorization': auth_token,
|
||||
}
|
||||
)
|
||||
except Exception as error:
|
||||
return error
|
||||
else:
|
||||
licence = requests.post(
|
||||
url=license_url,
|
||||
data=challenge
|
||||
)
|
||||
try:
|
||||
licence = requests.post(
|
||||
url=license_url,
|
||||
data=challenge
|
||||
)
|
||||
except Exception as error:
|
||||
return error
|
||||
if licence.status_code != 200:
|
||||
return "Could not complete license challenge"
|
||||
licence = licence.content
|
||||
|
|
17
main.py
17
main.py
|
@ -13,14 +13,14 @@ main_directory = os.getcwd()
|
|||
bot = Client(intents=Intents.DEFAULT)
|
||||
|
||||
# Check if discord bot token file exists, if not create file
|
||||
if not os.path.isfile(f"{main_directory}\\discord\\bot-token.txt"):
|
||||
with open(f'{main_directory}\\discord\\bot-token.txt', 'w') as discord_bot_token:
|
||||
if not os.path.isfile(f"{main_directory}/discord/bot-token.txt"):
|
||||
with open(f'{main_directory}/discord/bot-token.txt', 'w') as discord_bot_token:
|
||||
print("Please put your bot token in /discord/bot-token.txt")
|
||||
discord_bot_token.write("Delete this and place your bot token on this line")
|
||||
exit()
|
||||
|
||||
# Check if bot token exists and if it has been changed
|
||||
with open(f'{main_directory}\\discord\\bot-token.txt') as discord_bot_token:
|
||||
with open(f'{main_directory}/discord/bot-token.txt') as discord_bot_token:
|
||||
bot_token = discord_bot_token.readline()
|
||||
if bot_token == "Delete this and place your bot token on this line":
|
||||
print("Please put your bot token in /discord/bot-token.txt")
|
||||
|
@ -68,10 +68,13 @@ async def decrypt(ctx: SlashContext, pssh: str, license_url: str,
|
|||
keys = TPD_Keys.decrypt_content(pssh=pssh, license_url=license_url, auth_token=auth_bearer,
|
||||
xdt_auth_token=x_dt_auth)
|
||||
if keys != "Unable to retrieve service certificate" and keys != "Could not complete license challenge" and keys != "Invalid PSSH":
|
||||
DB_Cache.cache_key.cache_keys(pssh=pssh, keys=keys)
|
||||
embed = interactions.Embed(title="uWu")
|
||||
embed.set_image(url=f"{anime_api.waifu_pics.get_image()}")
|
||||
await ctx.send(f"Keys:\n\n```{keys}```", embed=embed)
|
||||
try:
|
||||
DB_Cache.cache_key.cache_keys(pssh=pssh, keys=keys)
|
||||
embed = interactions.Embed(title="uWu")
|
||||
embed.set_image(url=f"{anime_api.waifu_pics.get_image()}")
|
||||
await ctx.send(f"Keys:\n\n```{keys}```", embed=embed)
|
||||
except:
|
||||
await ctx.send(f"An error occurred `{keys}`!")
|
||||
else:
|
||||
await ctx.send(f"An error occurred `{keys}`!")
|
||||
|
||||
|
|
Loading…
Reference in New Issue