Merge branch 'frost' of https://github.com/Aevann1/rDrama into frost

remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-10-22 12:26:52 -05:00
commit 60dd29bc6b
8 changed files with 28 additions and 31 deletions

View File

@ -75,7 +75,8 @@ if not path.isfile(f'/site_settings.json'):
@app.before_request
def before_request():
app.config['SESSION_COOKIE_DOMAIN'] = f'.{request.host}'
if SITE != 'localhost':
app.config['SESSION_COOKIE_DOMAIN'] = f'.{request.host}'
if request.host == 'marsey.world' and request.path != '/kofi':
abort(404)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 826 KiB

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 955 KiB

After

Width:  |  Height:  |  Size: 356 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 664 KiB

After

Width:  |  Height:  |  Size: 336 KiB

View File

@ -154,36 +154,32 @@ def process_image(filename=None, resize=0, trim=False, uploader=None, patron=Fal
i.save(filename, format="WEBP", method=6, quality=88)
if resize in (300,400,1200):
if resize:
if os.stat(filename).st_size > MAX_IMAGE_SIZE_BANNER_RESIZED_KB * 1024:
os.remove(filename)
abort(413, f"Max size for banners, sidebars, and badges is {MAX_IMAGE_SIZE_BANNER_RESIZED_KB} KB")
if resize == 1200:
path = f'files/assets/images/{SITE_NAME}/banners'
elif resize == 400:
path = f'files/assets/images/{SITE_NAME}/sidebar'
else:
path = f'files/assets/images/badges'
if filename.startswith('files/assets/images/'):
path = filename.rsplit('/', 1)[0]
hashes = {}
hashes = {}
for img in os.listdir(path):
if resize == 400 and img in ('256.webp','585.webp'): continue
img_path = f'{path}/{img}'
if img_path == filename: continue
img = Image.open(img_path)
i_hash = str(imagehash.phash(img))
for img in os.listdir(path):
if resize == 400 and img in ('256.webp','585.webp'): continue
img_path = f'{path}/{img}'
if img_path == filename: continue
img = Image.open(img_path)
i_hash = str(imagehash.phash(img))
if i_hash in hashes.keys():
print(hashes[i_hash], flush=True)
print(img_path, flush=True)
else: hashes[i_hash] = img_path
i = Image.open(filename)
i_hash = str(imagehash.phash(i))
if i_hash in hashes.keys():
print(hashes[i_hash], flush=True)
print(img_path, flush=True)
else: hashes[i_hash] = img_path
i = Image.open(filename)
i_hash = str(imagehash.phash(i))
if i_hash in hashes.keys():
os.remove(filename)
abort(409, "Image already exists!")
os.remove(filename)
abort(409, "Image already exists!")
db = db or g.db

View File

@ -843,7 +843,7 @@ def agendaposter(user_id, v):
g.db.add(user)
if days:
days_txt = str(days).rstrip('.0')
days_txt = str(days).split('.0')[0]
note = f"for {days_txt} days"
else: note = "permanently"
@ -1013,7 +1013,7 @@ def ban_user(user_id, v):
duration = "permanently"
if days:
days_txt = str(days).rstrip('.0')
days_txt = str(days).split('.0')[0]
duration = f"for {days_txt} day"
if days != 1: duration += "s"
if reason: text = f"@{v.username} (Admin) has banned you for **{days_txt}** days for the following reason:\n\n> {reason}"

View File

@ -244,7 +244,7 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
filename = f'/asset_submissions/hats/{name}.webp'
copyfile(highquality, filename)
process_image(filename)
process_image(filename, resize=100)
hat = HatDef(name=name, author_id=author.id, description=description, price=price, submitter_id=v.id)
g.db.add(hat)
@ -451,7 +451,7 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
filename = f"files/assets/images/hats/{name}.webp"
copyfile(new_path, filename)
process_image(filename)
process_image(filename, resize=100)
purge_files_in_cache([f"https://{SITE}/i/hats/{name}.webp", f"https://{SITE}/assets/images/hats/{name}.webp", f"https://{SITE}/asset_submissions/hats/original/{name}.{format}"])
ma = ModAction(
kind="update_hat",

View File

@ -480,7 +480,7 @@ def sub_banner(v, sub):
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
bannerurl = process_image(name, patron=v.patron)
bannerurl = process_image(name, patron=v.patron, resize=1200)
if bannerurl:
if sub.bannerurl and '/images/' in sub.bannerurl:
@ -512,7 +512,7 @@ def sub_sidebar(v, sub):
file = request.files["sidebar"]
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
sidebarurl = process_image(name, patron=v.patron)
sidebarurl = process_image(name, patron=v.patron, resize=400)
if sidebarurl:
if sub.sidebarurl and '/images/' in sub.sidebarurl:
@ -544,7 +544,7 @@ def sub_marsey(v, sub):
file = request.files["marsey"]
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
marseyurl = process_image(name, patron=v.patron)
marseyurl = process_image(name, patron=v.patron, resize=200)
if marseyurl:
if sub.marseyurl and '/images/' in sub.marseyurl: