forked from rDrama/rDrama
rename remove_media to remove_media_using_link for clarity
parent
3eabcdb950
commit
1bce14efcd
|
@ -1785,7 +1785,7 @@ def delete_media_post(v):
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
return render_template("admin/delete_media.html", v=v, url=url, error="File not found on the server!")
|
return render_template("admin/delete_media.html", v=v, url=url, error="File not found on the server!")
|
||||||
|
|
||||||
remove_media(path)
|
remove_media_using_link(path)
|
||||||
|
|
||||||
ma=ModAction(
|
ma=ModAction(
|
||||||
kind="delete_media",
|
kind="delete_media",
|
||||||
|
|
|
@ -204,8 +204,8 @@ def remove_asset(cls, type_name:str, v:User, name:str) -> dict[str, str]:
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.delete(asset)
|
g.db.delete(asset)
|
||||||
remove_media(f"/asset_submissions/{type_name}s/{name}.webp")
|
remove_media_using_link(f"/asset_submissions/{type_name}s/{name}.webp")
|
||||||
remove_media(f"/asset_submissions/{type_name}s/{name}")
|
remove_media_using_link(f"/asset_submissions/{type_name}s/{name}")
|
||||||
|
|
||||||
return {"message": f"'{name}' removed!"}
|
return {"message": f"'{name}' removed!"}
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ def submit_hat(v:User):
|
||||||
|
|
||||||
with Image.open(highquality) as i:
|
with Image.open(highquality) as i:
|
||||||
if i.width > 100 or i.height > 130:
|
if i.width > 100 or i.height > 130:
|
||||||
remove_media(highquality)
|
remove_media_using_link(highquality)
|
||||||
return error("Images must be 100x130")
|
return error("Images must be 100x130")
|
||||||
|
|
||||||
if len(list(Iterator(i))) > 1: price = 1000
|
if len(list(Iterator(i))) > 1: price = 1000
|
||||||
|
@ -416,7 +416,7 @@ def update_marsey(v):
|
||||||
|
|
||||||
for x in IMAGE_FORMATS:
|
for x in IMAGE_FORMATS:
|
||||||
if path.isfile(f'/asset_submissions/marseys/original/{name}.{x}'):
|
if path.isfile(f'/asset_submissions/marseys/original/{name}.{x}'):
|
||||||
remove_media(f'/asset_submissions/marseys/original/{name}.{x}')
|
remove_media_using_link(f'/asset_submissions/marseys/original/{name}.{x}')
|
||||||
|
|
||||||
highquality = f"/asset_submissions/marseys/{name}"
|
highquality = f"/asset_submissions/marseys/{name}"
|
||||||
file.save(highquality)
|
file.save(highquality)
|
||||||
|
@ -482,7 +482,7 @@ def update_hat(v):
|
||||||
|
|
||||||
with Image.open(highquality) as i:
|
with Image.open(highquality) as i:
|
||||||
if i.width > 100 or i.height > 130:
|
if i.width > 100 or i.height > 130:
|
||||||
remove_media(highquality)
|
remove_media_using_link(highquality)
|
||||||
return error("Images must be 100x130")
|
return error("Images must be 100x130")
|
||||||
|
|
||||||
format = i.format.lower()
|
format = i.format.lower()
|
||||||
|
@ -490,7 +490,7 @@ def update_hat(v):
|
||||||
|
|
||||||
for x in IMAGE_FORMATS:
|
for x in IMAGE_FORMATS:
|
||||||
if path.isfile(f'/asset_submissions/hats/original/{name}.{x}'):
|
if path.isfile(f'/asset_submissions/hats/original/{name}.{x}'):
|
||||||
remove_media(f'/asset_submissions/hats/original/{name}.{x}')
|
remove_media_using_link(f'/asset_submissions/hats/original/{name}.{x}')
|
||||||
|
|
||||||
rename(highquality, new_path)
|
rename(highquality, new_path)
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ def settings_personal(v:User):
|
||||||
def remove_background(v):
|
def remove_background(v):
|
||||||
if v.background:
|
if v.background:
|
||||||
if v.background.startswith('/images/'):
|
if v.background.startswith('/images/'):
|
||||||
remove_media(v.background)
|
remove_media_using_link(v.background)
|
||||||
v.background = None
|
v.background = None
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
return {"message": "Background removed!"}
|
return {"message": "Background removed!"}
|
||||||
|
@ -69,7 +69,7 @@ def upload_custom_background(v):
|
||||||
|
|
||||||
if background:
|
if background:
|
||||||
if v.background and v.background.startswith('/images/'):
|
if v.background and v.background.startswith('/images/'):
|
||||||
remove_media(v.background)
|
remove_media_using_link(v.background)
|
||||||
v.background = background
|
v.background = background
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ def upload_profile_background(v):
|
||||||
|
|
||||||
if background:
|
if background:
|
||||||
if v.profile_background and path.isfile(v.profile_background):
|
if v.profile_background and path.isfile(v.profile_background):
|
||||||
remove_media(v.profile_background)
|
remove_media_using_link(v.profile_background)
|
||||||
v.profile_background = background
|
v.profile_background = background
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
badge_grant(badge_id=193, user=v)
|
badge_grant(badge_id=193, user=v)
|
||||||
|
@ -103,7 +103,7 @@ def upload_profile_background(v):
|
||||||
@auth_required
|
@auth_required
|
||||||
def delete_profile_background(v):
|
def delete_profile_background(v):
|
||||||
if v.profile_background:
|
if v.profile_background:
|
||||||
remove_media(v.profile_background)
|
remove_media_using_link(v.profile_background)
|
||||||
v.profile_background = None
|
v.profile_background = None
|
||||||
return {"message": "Profile background removed!"}
|
return {"message": "Profile background removed!"}
|
||||||
|
|
||||||
|
@ -549,10 +549,10 @@ def settings_images_profile(v):
|
||||||
if not imageurl: abort(400)
|
if not imageurl: abort(400)
|
||||||
|
|
||||||
if v.highres and '/images/' in v.highres and path.isfile(v.highres):
|
if v.highres and '/images/' in v.highres and path.isfile(v.highres):
|
||||||
remove_media(v.highres)
|
remove_media_using_link(v.highres)
|
||||||
|
|
||||||
if v.profileurl and '/images/' in v.profileurl and path.isfile(v.profileurl):
|
if v.profileurl and '/images/' in v.profileurl and path.isfile(v.profileurl):
|
||||||
remove_media(v.profileurl)
|
remove_media_using_link(v.profileurl)
|
||||||
|
|
||||||
v.highres = highres
|
v.highres = highres
|
||||||
v.profileurl = imageurl
|
v.profileurl = imageurl
|
||||||
|
@ -582,7 +582,7 @@ def settings_images_banner(v):
|
||||||
|
|
||||||
if bannerurl:
|
if bannerurl:
|
||||||
if v.bannerurl and '/images/' in v.bannerurl and path.isfile(v.bannerurl):
|
if v.bannerurl and '/images/' in v.bannerurl and path.isfile(v.bannerurl):
|
||||||
remove_media(v.bannerurl)
|
remove_media_using_link(v.bannerurl)
|
||||||
v.bannerurl = bannerurl
|
v.bannerurl = bannerurl
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
|
@ -749,11 +749,11 @@ def settings_song_change_mp3(v):
|
||||||
|
|
||||||
size = os.stat(name).st_size
|
size = os.stat(name).st_size
|
||||||
if size > 8 * 1024 * 1024:
|
if size > 8 * 1024 * 1024:
|
||||||
remove_media(name)
|
remove_media_using_link(name)
|
||||||
return redirect("/settings/personal?error=MP3 file must be smaller than 8MB")
|
return redirect("/settings/personal?error=MP3 file must be smaller than 8MB")
|
||||||
|
|
||||||
if path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
if path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
||||||
remove_media(f"/songs/{v.song}.mp3")
|
remove_media_using_link(f"/songs/{v.song}.mp3")
|
||||||
|
|
||||||
v.song = song
|
v.song = song
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
@ -766,7 +766,7 @@ def _change_song_youtube(vid, id):
|
||||||
v = db.get(User, vid)
|
v = db.get(User, vid)
|
||||||
|
|
||||||
if v.song and path.isfile(f"/songs/{v.song}.mp3") and db.query(User).filter_by(song=v.song).count() == 1:
|
if v.song and path.isfile(f"/songs/{v.song}.mp3") and db.query(User).filter_by(song=v.song).count() == 1:
|
||||||
remove_media(f"/songs/{v.song}.mp3")
|
remove_media_using_link(f"/songs/{v.song}.mp3")
|
||||||
|
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
'cookiefile': '/cookies',
|
'cookiefile': '/cookies',
|
||||||
|
@ -807,7 +807,7 @@ def settings_song_change(v):
|
||||||
|
|
||||||
if song == "" and v.song:
|
if song == "" and v.song:
|
||||||
if path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
if path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
||||||
remove_media(f"/songs/{v.song}.mp3")
|
remove_media_using_link(f"/songs/{v.song}.mp3")
|
||||||
v.song = None
|
v.song = None
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
return redirect("/settings/personal?msg=Profile Anthem successfully removed!")
|
return redirect("/settings/personal?msg=Profile Anthem successfully removed!")
|
||||||
|
|
|
@ -544,7 +544,7 @@ def delete_sub_banner(v:User, sub:str, index:int):
|
||||||
abort(404, f'Banner not found (banner index {index} is not between 0 and {len(sub.bannerurls)})')
|
abort(404, f'Banner not found (banner index {index} is not between 0 and {len(sub.bannerurls)})')
|
||||||
banner = sub.bannerurls[index]
|
banner = sub.bannerurls[index]
|
||||||
try:
|
try:
|
||||||
remove_media(banner)
|
remove_media_using_link(banner)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
del sub.bannerurls[index]
|
del sub.bannerurls[index]
|
||||||
|
@ -570,7 +570,7 @@ def delete_all_sub_banners(v:User, sub:str):
|
||||||
if v.shadowbanned: return redirect(f'/h/{sub}/settings')
|
if v.shadowbanned: return redirect(f'/h/{sub}/settings')
|
||||||
for banner in sub.banner_urls:
|
for banner in sub.banner_urls:
|
||||||
try:
|
try:
|
||||||
remove_media(banner)
|
remove_media_using_link(banner)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
sub.bannerurls = []
|
sub.bannerurls = []
|
||||||
|
@ -605,7 +605,7 @@ def sub_sidebar(v:User, sub):
|
||||||
|
|
||||||
if sidebarurl:
|
if sidebarurl:
|
||||||
if sub.sidebarurl:
|
if sub.sidebarurl:
|
||||||
remove_media(sub.sidebarurl)
|
remove_media_using_link(sub.sidebarurl)
|
||||||
sub.sidebarurl = sidebarurl
|
sub.sidebarurl = sidebarurl
|
||||||
g.db.add(sub)
|
g.db.add(sub)
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ def sub_marsey(v:User, sub):
|
||||||
|
|
||||||
if marseyurl:
|
if marseyurl:
|
||||||
if sub.marseyurl:
|
if sub.marseyurl:
|
||||||
remove_media(sub.marseyurl)
|
remove_media_using_link(sub.marseyurl)
|
||||||
sub.marseyurl = marseyurl
|
sub.marseyurl = marseyurl
|
||||||
g.db.add(sub)
|
g.db.add(sub)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue