forked from MarseyWorld/MarseyWorld
add poster_url for videos
parent
64f0c42913
commit
25312029aa
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
<div class="row no-gutters mb-4">
|
||||
<div class="col">
|
||||
<p class="resizable">
|
||||
<video {% if p.thumburl %}poster="{{p.thumb_url}}"{% endif %} controls preload="none" src="{{p.realurl(v)}}"></video>
|
||||
<video {% if p.poster_url %}poster="{{p.poster_url}}"{% endif %} controls preload="none" src="{{p.realurl(v)}}"></video>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -225,7 +225,7 @@
|
|||
{% if p.is_video %}
|
||||
<div id="video-{{p.id}}" class="ml-md-5 d-none mt-4 mx-sm-auto">
|
||||
<p class="resizable">
|
||||
<video {% if p.thumburl %}poster="{{p.thumb_url}}"{% endif %} id="video2-{{p.id}}" controls preload="none" src="{{p.realurl(v)}}"></video>
|
||||
<video {% if p.poster_url %}poster="{{p.poster_url}}"{% endif %} id="video2-{{p.id}}" controls preload="none" src="{{p.realurl(v)}}"></video>
|
||||
</p>
|
||||
</div>
|
||||
{% elif p.is_audio %}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
alter table submissions add column posterurl varchar(200);
|
Loading…
Reference in New Issue