diff --git a/files/classes/submission.py b/files/classes/submission.py index 7959c2c9d..bea221810 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -26,6 +26,7 @@ class Submission(Base): edited_utc = Column(Integer, default=0) created_utc = Column(Integer) thumburl = Column(String) + posterurl = Column(String) is_banned = Column(Boolean, default=False) bannedfor = Column(String) chuddedfor = Column(String) @@ -162,6 +163,13 @@ class Submission(Base): return f"{SITE_FULL}/i/{SITE_NAME}/site_preview.webp?v=3009" else: return f"{SITE_FULL}/i/default_thumb_link.webp?v=1" + @property + @lazy + def poster_url(self): + if self.posterurl: return self.posterurl + if self.thumburl: return self.thumburl + return None + @lazy def json(self, db:scoped_session): if self.is_banned: diff --git a/files/routes/posts.py b/files/routes/posts.py index 51435a1ed..e2aef59eb 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -629,9 +629,13 @@ def submit_post(v:User, sub=None): p.url = process_video(file, v) name = f'/images/{time.time()}'.replace('.','') + '.webp' subprocess.run(['ffmpeg', '-y', '-loglevel', 'warning', - '-i', p.url, '-vf', "scale='min(500,iw)':-2", + '-i', p.url, '-vf', "scale='iw':-2", '-q:v', '3', '-frames:v', '1', name], check=True) - p.thumburl = name + p.posterurl = name + + name2 = name.replace('.webp', 'r.webp') + copyfile(name, name2) + p.thumburl = process_image(name2, v, resize=99) elif file.content_type.startswith('audio/'): p.url = process_audio(file, v) else: diff --git a/files/templates/submission.html b/files/templates/submission.html index 27f9c95da..94edd8352 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -137,7 +137,7 @@
- +
- +