forked from rDrama/rDrama
is_audio
parent
5b007c2cc7
commit
02e98b46b0
|
@ -258,7 +258,8 @@ class Submission(Base):
|
|||
elif self.thumburl:
|
||||
if self.thumburl.startswith('/'): return SITE_FULL + self.thumburl
|
||||
return self.thumburl
|
||||
elif self.is_youtube or self.is_video: return f"{SITE_FULL}/assets/images/default_thumb_yt.webp?v=1"
|
||||
elif self.is_youtube or self.is_video: return f"{SITE_FULL}/assets/images/default_thumb_video.webp?v=1"
|
||||
elif self.is_audio: return f"{SITE_FULL}/assets/images/default_thumb_audio.webp?v=1"
|
||||
else: return f"{SITE_FULL}/assets/images/default_thumb_link.webp?v=1"
|
||||
|
||||
@property
|
||||
|
@ -473,6 +474,11 @@ class Submission(Base):
|
|||
def is_video(self):
|
||||
return self.url and any((self.url.lower().endswith(x) for x in ('.mp4','.webm','.mov'))) and embed_fullmatch_regex.fullmatch(self.url)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def is_audio(self):
|
||||
return self.url and any((self.url.lower().endswith(x) for x in ('.mp3','.wav','.ogg','.aac','.m4a','.flac'))) and embed_fullmatch_regex.fullmatch(self.url)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def is_image(self):
|
||||
|
|
|
@ -79,7 +79,7 @@ Text 2
|
|||
<tr>
|
||||
<td>Video Files</td>
|
||||
<td>https://files.catbox.moe/v4om92.mp4</td>
|
||||
<td><video controls preload="none"><source referrerpolicy="no-referrer" src="https://files.catbox.moe/v4om92.mp4" type="video/mp4"></video></td>
|
||||
<td><video controls preload="none"><source referrerpolicy="no-referrer" src="https://files.catbox.moe/v4om92.mp4"></video></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Emojis</td>
|
||||
|
|
|
@ -569,6 +569,8 @@
|
|||
<meta property="og:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb%}{{p.thumb_url}}{% else %}{{SITE_NAME}}/assets/images/{{SITE_NAME}}/site_preview.webp?v=1015{% endif %}">
|
||||
{% if p.is_video %}
|
||||
<meta property="og:video" content="{{p.realurl(v)}}">
|
||||
{% elif p.is_audio %}
|
||||
<meta property="og:audio" content="{{p.realurl(v)}}">
|
||||
{% endif %}
|
||||
<meta property="og:url" content="{{comment_info.permalink}}">
|
||||
<meta property="og:site_name" content="{{request.host}}">
|
||||
|
@ -592,9 +594,6 @@
|
|||
{% if p.author %}<meta property="og:author" name="author" content="{{'@'+p.author_name}}">{% endif %}
|
||||
<meta property="og:title" content="{{p.plaintitle(v)}} - {{SITE_NAME}}">
|
||||
<meta property="og:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb%}{{p.thumb_url}}{% else %}{{SITE_NAME}}/assets/images/{{SITE_NAME}}/site_preview.webp?v=1015{% endif %}">
|
||||
{% if p.url and p.is_video %}
|
||||
<meta property="og:video" content="{{p.realurl(v)}}">
|
||||
{% endif %}
|
||||
<meta property="og:url" content="{{p.permalink}}">
|
||||
<meta property="og:site_name" content="{{request.host}}">
|
||||
|
||||
|
@ -714,7 +713,7 @@
|
|||
<a class="user-name text-decoration-none" href="{{p.author.url}}" data-pop-info='{{p.author.json_popover(v) | tojson}}' onclick='popclick(event)' data-bs-placement="bottom" data-bs-toggle="popover" data-bs-trigger="click" data-content-id="popover" role="button" tabindex="0" style="color: #{{p.author.namecolor}}; font-weight: bold"class="user-name"><img loading="lazy" src="{{p.author.profile_url}}" class="profile-pic-25 mr-2">{% if p.author.is_cakeday %}<img class="party-hat" src="/assets/images/party-hat.webp" data-bs-toggle="tooltip" data-bs-placement="bottom" title="I’ve spent another year rotting my brain with dramaposting, please ridicule me 🤓">{% endif %}<span {% if p.author.patron and not p.distinguish_level %}class="patron" style="background-color:#{{p.author.namecolor}};"{% elif p.distinguish_level %}class="mod"{% endif %}>{{p.author_name}}</span></a>{% if p.author.customtitle %} <bdi style="color: #{{p.author.titlecolor}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}
|
||||
{% endif %}
|
||||
<span data-bs-toggle="tooltip" data-bs-placement="bottom" id="timestamp" onmouseover="timestamp('timestamp','{{p.created_utc}}')"> {{p.age_string}}</span>
|
||||
({% if p.is_image %}image post{% elif p.is_video %}video post{% elif p.domain %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" {% if not v or v.newtabexternal %}target="_blank"{% endif %}>{{p.domain}}</a>{% else %}text post{% endif %})
|
||||
({% if p.is_image %}image post{% elif p.is_video %}video post{% elif p.is_audio %}audio post{% elif p.domain %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" {% if not v or v.newtabexternal %}target="_blank"{% endif %}>{{p.domain}}</a>{% else %}text post{% endif %})
|
||||
|
||||
{% if p.edited_utc %}
|
||||
Edited <span data-bs-toggle="tooltip" data-bs-placement="bottom" onmouseover="timestamp('edited_timestamp','{{p.edited_utc}}')" id="edited_timestamp">{{p.edited_string}}</span>
|
||||
|
@ -748,7 +747,7 @@
|
|||
|
||||
<div id="post-body" class="post-body mt-3">
|
||||
{% if p.realurl(v) %}
|
||||
{% if not p.embed_url and not p.is_image and not p.is_video %}
|
||||
{% if not p.embed_url and not p.is_image and not p.is_video and not p.is_audio %}
|
||||
<a rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}" {% if not v or v.newtabexternal %}target="_blank"{% endif %}>
|
||||
<div class="d-flex d-md-none justify-content-between align-items-center border rounded p-2{% if p.realbody(v) %} mb-3{% endif %}">
|
||||
<span>{{p.domain|truncate(30, True)}}</span>
|
||||
|
@ -787,11 +786,18 @@
|
|||
<div class="row no-gutters">
|
||||
<div class="col">
|
||||
<video controls preload="none">
|
||||
<source src="{{p.realurl(v)}}" type="video/mp4">
|
||||
<source src="{{p.realurl(v)}}">
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
<pre></pre>
|
||||
{% elif p.is_audio %}
|
||||
<div class="row no-gutters">
|
||||
<div class="col">
|
||||
<audio controls preload="none" src="{{p.realurl(v)}}"></audio>
|
||||
</div>
|
||||
</div>
|
||||
<pre></pre>
|
||||
{% endif %}
|
||||
{{p.realbody(v) | safe}}
|
||||
|
||||
|
@ -903,7 +909,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
{% if not p.is_image and not p.is_video %}
|
||||
{% if not p.is_image and not p.is_video and not p.is_audio %}
|
||||
<div class="row no-gutters d-md-none">
|
||||
<div class="col">
|
||||
<a {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="nofollow noopener noreferrer" href="{{p.realurl(v)}}"></a>
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
</a>
|
||||
{% elif p.is_image %}
|
||||
<img role="button" data-bs-toggle="modal" data-bs-target="#expandImageModal" onclick="expandDesktopImage('{{p.realurl(v)}}')" alt="post thumnail" loading="lazy" src="{{p.thumb_url}}" class="post-img">
|
||||
{% elif p.is_video %}
|
||||
{% elif p.is_video or p.is_audio %}
|
||||
<a role="button" onclick="togglevideo({{p.id}})">
|
||||
<img alt="post thumnail" loading="lazy" src="{{p.thumb_url}}" class="post-img">
|
||||
</a>
|
||||
|
@ -190,7 +190,7 @@
|
|||
{% endif %}
|
||||
<span data-bs-toggle="tooltip" data-bs-placement="bottom" onmouseover="timestamp('timestamp-{{p.id}}','{{p.created_utc}}')" id="timestamp-{{p.id}}"> {{p.age_string}}</span>
|
||||
|
||||
({% if p.is_image %}image post{% elif p.is_video %}video post{% elif p.domain %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" {% if v and v.newtab and not g.webview %}target="_blank"{% endif %}>{{p.domain}}</a>{% else %}text post{% endif %})
|
||||
({% if p.is_image %}image post{% elif p.is_video %}video post{% elif p.is_audio %}audio post{% elif p.domain %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" {% if v and v.newtab and not g.webview %}target="_blank"{% endif %}>{{p.domain}}</a>{% else %}text post{% endif %})
|
||||
{% if p.edited_utc %}
|
||||
Edited <span data-bs-toggle="tooltip" data-bs-placement="bottom" id="edited_timestamp-{{p.id}}" onmouseover="timestamp('edited_timestamp-{{p.id}}','{{p.edited_utc}}')">{{p.edited_string}}</span>
|
||||
{% endif %}
|
||||
|
@ -341,9 +341,13 @@
|
|||
{% elif p.is_video %}
|
||||
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-4">
|
||||
<video id="video2-{{p.id}}" controls preload="none">
|
||||
<source src="{{p.realurl(v)}}" type="video/mp4">
|
||||
<source src="{{p.realurl(v)}}">
|
||||
</video>
|
||||
</div>
|
||||
{% elif p.is_audio %}
|
||||
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-4">
|
||||
<audio id="video2-{{p.id}}" controls preload="none" src="{{p.realurl(v)}}"></audio>
|
||||
</div>
|
||||
{% elif p.is_youtube %}
|
||||
<div id="video-{{p.id}}" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-3 mb-4 youtube_embed">
|
||||
{{p.embed_url | safe}}
|
||||
|
|
Loading…
Reference in New Issue