From 3afecb326bcad97f1ca3ffcd12823fd3d408902a Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 7 Mar 2023 22:33:12 +0200 Subject: [PATCH] fix videos and image on WPD --- files/helpers/media.py | 10 ++++++---- files/routes/comments.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/files/helpers/media.py b/files/helpers/media.py index 4896125da..d738eb302 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -57,9 +57,9 @@ def process_files(files, v, body): name = f'/images/{time.time()}'.replace('.','') + '.webp' file.save(name) url = process_image(name, v) - body = body.replace(f'[{file.filename}]', url, 1) + body = body.replace(f'[{file.filename}]', f"![]({url})", 1) elif file.content_type.startswith('video/'): - body = body.replace(f'[{file.filename}]', f"{SITE_FULL}{process_video(file, v)}", 1) + body = body.replace(f'[{file.filename}]', process_video(file, v), 1) elif file.content_type.startswith('audio/'): body = body.replace(f'[{file.filename}]', f"{SITE_FULL}{process_audio(file, v)}", 1) else: @@ -152,8 +152,10 @@ def process_video(file, v): ) g.db.add(media) - if SITE == 'watchpeopledie.tv': f'https://videos.{SITE}{new}' - return new + if SITE == 'watchpeopledie.tv': + return f'https://videos.{SITE}{new}' + else: + return f"{SITE_FULL}{new}" def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[int]=None, db=None): # thumbnails are processed in a thread and not in the request context diff --git a/files/routes/comments.py b/files/routes/comments.py index c2e9ee8cb..414ea7758 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -213,7 +213,7 @@ def comment(v:User): abort(400, str(e)) body = body.replace(f'[{file.filename}]', f"![]({image})", 1) elif file.content_type.startswith('video/'): - body = body.replace(f'[{file.filename}]', f"{SITE_FULL}{process_video(file, v)}", 1) + body = body.replace(f'[{file.filename}]', process_video(file, v), 1) elif file.content_type.startswith('audio/'): body = body.replace(f'[{file.filename}]', f"{SITE_FULL}{process_audio(file, v)}", 1) else: