mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
streamable #147
This commit is contained in:
parent
4c48f72dcd
commit
a8f7ebf442
3 changed files with 26 additions and 8 deletions
|
@ -500,7 +500,7 @@ def add_discussion_post(actor):
|
|||
if not community.local_only:
|
||||
federate_post(community, post)
|
||||
|
||||
return redirect(f"/c/{community.link()}")
|
||||
return redirect(f"/post/{post.id}")
|
||||
else:
|
||||
form.communities.data = community.id
|
||||
form.notify_author.data = True
|
||||
|
@ -573,7 +573,7 @@ def add_image_post(actor):
|
|||
if not community.local_only:
|
||||
federate_post(community, post)
|
||||
|
||||
return redirect(f"/c/{community.link()}")
|
||||
return redirect(f"/post/{post.id}")
|
||||
else:
|
||||
form.communities.data = community.id
|
||||
form.notify_author.data = True
|
||||
|
@ -646,7 +646,7 @@ def add_link_post(actor):
|
|||
if not community.local_only:
|
||||
federate_post(community, post)
|
||||
|
||||
return redirect(f"/c/{community.link()}")
|
||||
return redirect(f"/post/{post.id}")
|
||||
else:
|
||||
form.communities.data = community.id
|
||||
form.notify_author.data = True
|
||||
|
@ -719,7 +719,7 @@ def add_video_post(actor):
|
|||
if not community.local_only:
|
||||
federate_post(community, post)
|
||||
|
||||
return redirect(f"/c/{community.link()}")
|
||||
return redirect(f"/post/{post.id}")
|
||||
else:
|
||||
form.communities.data = community.id
|
||||
form.notify_author.data = True
|
||||
|
|
|
@ -310,6 +310,7 @@ def save_post(form, post: Post, type: str):
|
|||
post.image = file
|
||||
db.session.add(file)
|
||||
elif type == 'video':
|
||||
form.video_url.data = form.video_url.data.strip()
|
||||
post.title = form.video_title.data
|
||||
post.body = form.video_body.data
|
||||
post.body_html = markdown_to_html(post.body)
|
||||
|
@ -324,10 +325,23 @@ def save_post(form, post: Post, type: str):
|
|||
if post.image_id:
|
||||
remove_old_file(post.image_id)
|
||||
post.image_id = None
|
||||
|
||||
file = File(source_url=form.video_url.data) # make_image_sizes() will take care of turning this into a still image
|
||||
post.image = file
|
||||
db.session.add(file)
|
||||
if form.video_url.data.endswith('.mp4') or form.video_url.data.endswith('.webm'):
|
||||
file = File(source_url=form.video_url.data) # make_image_sizes() will take care of turning this into a still image
|
||||
post.image = file
|
||||
db.session.add(file)
|
||||
else:
|
||||
# check opengraph tags on the page and make a thumbnail if an image is available in the og:image meta tag
|
||||
opengraph = opengraph_parse(form.video_url.data)
|
||||
if opengraph and (opengraph.get('og:image', '') != '' or opengraph.get('og:image:url', '') != ''):
|
||||
filename = opengraph.get('og:image') or opengraph.get('og:image:url')
|
||||
filename_for_extension = filename.split('?')[0] if '?' in filename else filename
|
||||
unused, file_extension = os.path.splitext(filename_for_extension)
|
||||
if file_extension.lower() in allowed_extensions and not filename.startswith('/'):
|
||||
file = url_to_thumbnail_file(filename)
|
||||
if file:
|
||||
file.alt_text = shorten_string(opengraph.get('og:title'), 295)
|
||||
post.image = file
|
||||
db.session.add(file)
|
||||
|
||||
elif type == 'poll':
|
||||
...
|
||||
|
|
|
@ -113,6 +113,10 @@
|
|||
<source src="{{ post.url }}" media="video/webm" />
|
||||
{% endif %}
|
||||
</video></p>
|
||||
{% elif post.url.startswith('https://streamable.com') %}
|
||||
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="{{ post.url.replace('streamable.com/', 'streamable.com/e/') }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
|
||||
{% elif post.url.startswith('https://www.redgifs.com/watch/') %}
|
||||
<div style="padding-bottom: 56.25%; position: relative;"><iframe style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;" src="{{ post.url.replace('redgifs.com/watch/', 'redgifs.com/ifr/') }}" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture; fullscreen" width="100%" height="100%" frameborder="0"></iframe></div>
|
||||
{% endif %}
|
||||
{% if 'youtube.com' in post.url %}
|
||||
<p><a href="https://piped.video/watch?v={{ post.youtube_embed() }}">{{ _('Watch on piped.video') }} <span class="fe fe-external"></span></a></p>
|
||||
|
|
Loading…
Add table
Reference in a new issue