From 02e98b46b0ad7b3a3189ac8bf677dbe4fa3eb108 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 24 May 2022 18:28:12 +0200 Subject: [PATCH] is_audio --- files/classes/submission.py | 8 +++++++- files/templates/formatting.html | 2 +- files/templates/submission.html | 20 +++++++++++++------- files/templates/submission_listing.html | 10 +++++++--- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index d5434b5ad..26fdef7a2 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -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): diff --git a/files/templates/formatting.html b/files/templates/formatting.html index eb0702393..46cae36fb 100644 --- a/files/templates/formatting.html +++ b/files/templates/formatting.html @@ -79,7 +79,7 @@ Text 2 Video Files https://files.catbox.moe/v4om92.mp4 - + Emojis diff --git a/files/templates/submission.html b/files/templates/submission.html index 83b864e62..724aff572 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -569,6 +569,8 @@ {% if p.is_video %} +{% elif p.is_audio %} + {% endif %} @@ -592,9 +594,6 @@ {% if p.author %}{% endif %} -{% if p.url and p.is_video %} - -{% endif %} @@ -714,7 +713,7 @@ {% if p.author.is_cakeday %}{% endif %}{{p.author_name}}{% if p.author.customtitle %}  {{p.author.customtitle | safe}}{% endif %} {% endif %}  {{p.age_string}} - ({% if p.is_image %}image post{% elif p.is_video %}video post{% elif p.domain %}{{p.domain}}{% 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 %}{{p.domain}}{% else %}text post{% endif %}) {% if p.edited_utc %}   Edited {{p.edited_string}} @@ -748,7 +747,7 @@
{% 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 %}
{{p.domain|truncate(30, True)}} @@ -787,11 +786,18 @@

+							{% elif p.is_audio %}
+								
+
+ +
+
+

 							{% endif %}
 							{{p.realbody(v) | safe}}
 
@@ -903,7 +909,7 @@
 
 		
- {% 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 %}
diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 7c4fa2d15..b6785efcc 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -118,7 +118,7 @@ {% elif p.is_image %} post thumnail - {% elif p.is_video %} + {% elif p.is_video or p.is_audio %} post thumnail @@ -190,7 +190,7 @@ {% endif %}  {{p.age_string}}   - ({% if p.is_image %}image post{% elif p.is_video %}video post{% elif p.domain %}{{p.domain}}{% 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 %}{{p.domain}}{% else %}text post{% endif %}) {% if p.edited_utc %}   Edited {{p.edited_string}} {% endif %} @@ -341,9 +341,13 @@ {% elif p.is_video %}
+ {% elif p.is_audio %} +
+ +
{% elif p.is_youtube %}
{{p.embed_url | safe}}