Added exception handling for invalid license parsing, removed unused features. Probably will rewrite the whole thing again here soon.

main
TPD94 2024-03-02 13:07:38 -05:00
parent cca5e59ff5
commit 1ac82dc821
4 changed files with 10 additions and 30 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.idea
venv
.git

View File

@ -77,7 +77,10 @@ def decrypt_content(pssh: str = None, license_url: str = None,
licence = licence.content
# parse license challenge
cdm.parse_license(session_id, licence)
try:
cdm.parse_license(session_id, licence)
except Exception as error:
return error
# assign variable for returned keys
returned_keys = ""
@ -90,10 +93,3 @@ def decrypt_content(pssh: str = None, license_url: str = None,
return returned_keys
def key_test():
keys = decrypt_content(
pssh="AAAAW3Bzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADsIARIQ62dqu8s0Xpa7z2FmMPGj2hoNd2lkZXZpbmVfdGVzdCIQZmtqM2xqYVNkZmFsa3IzaioCSEQyAA==",
license_url="https://cwip-shaka-proxy.appspot.com/no_auth",
service_certificate=True)
return keys

View File

@ -8,9 +8,3 @@ def get_image():
image = image.json()["url"]
return image
# Define get NSFW image
def get_image_nsfw():
image = requests.get(url="https://api.waifu.pics/nsfw/waifu")
image = image.json()["url"]
return image

19
main.py
View File

@ -1,8 +1,6 @@
# Import dependencies
import os
import interactions
from helper_scripts import TPD_Keys
from helper_scripts import DB_Cache
from helper_scripts import anime_api
@ -66,8 +64,9 @@ DB_Cache.create_database.create_database()
opt_type=OptionType.STRING,
)
async def decrypt(ctx: SlashContext, pssh: str, license_url: str,
auth_bearer: str = None, x_dt_auth: str = None):
keys = TPD_Keys.decrypt_content(pssh=pssh, license_url=license_url, auth_token=auth_bearer, xdt_auth_token=x_dt_auth)
auth_bearer: str = None, x_dt_auth: str = None):
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")
@ -121,16 +120,4 @@ async def upload_database(ctx: SlashContext):
await message.edit(content="Finished!", embeds=embed)
# Defining uwu command
@slash_command(
name="uwu",
description="Send a NSFW image to #stuff-you-wouldnt-post-on-general"
)
async def uwu(ctx: SlashContext):
channel = await bot.fetch_channel(1123340072322863124, force=True)
embed = interactions.Embed(title="uWu")
embed.set_image(url=f"{anime_api.waifu_pics.get_image_nsfw()}")
uwu = await channel.send(embed=embed)
await ctx.send(f"Posted in #{uwu.channel.name}", ephemeral=True)
bot.start(token=discord_bot_token)