mirror of
https://github.com/Mistake35/Cedar-Django.git
synced 2026-07-18 00:21:14 +10:00
Discord video support and more cleaning up
This commit is contained in:
@@ -812,6 +812,15 @@ class Post(models.Model):
|
||||
except:
|
||||
return False
|
||||
return thing
|
||||
def discord_vid(self):
|
||||
try:
|
||||
thing = re.search('(https?://)?(www\.)?(cdn)?(discordapp)\.(com)/attachments/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/(.+)', self.url).group(8)
|
||||
if thing.endswith(".mp4") or thing.endswith(".webm"):
|
||||
return thing
|
||||
else:
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
def has_line_trun(self):
|
||||
if self.body and len(self.body.splitlines()) > 10:
|
||||
return True
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
<div class="body post-content">
|
||||
{% if post.yt_vid %}
|
||||
<a href="{% url "main:post-view" post.id %}" class="screenshot-container video"><img height="48" src="https://i.ytimg.com/vi/{{ post.yt_vid }}/default.jpg"></a>
|
||||
{% elif post.discord_vid %}
|
||||
<div class="DiscordCDN-container video">
|
||||
<video class="discord-player" src="{{ post.url }}" controls></video>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if post.drawing %}
|
||||
<p class="post-content-memo"><img src="{{ post.drawing }}" class="post-memo"></p>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
|
||||
{% if user.has_freedom %}
|
||||
<input type="text" class="textarea-line url-form" name="url" placeholder="URL/YT video" maxlength="1024">
|
||||
<input type="text" class="textarea-line url-form" name="url" placeholder="URL/YT/Discord video" maxlength="1024">
|
||||
{% file_button %}
|
||||
{% endif %}
|
||||
|
||||
@@ -66,4 +66,4 @@
|
||||
|
||||
{% if not user.is_active %}
|
||||
<p>Your account has been disabled.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
</p>
|
||||
{% if post.yt_vid %}
|
||||
<a href="{% url "main:post-view" post.id %}" class="screenshot-container video"><img height="48" src="https://i.ytimg.com/vi/{{ post.yt_vid }}/default.jpg"></a>
|
||||
{% endif %}
|
||||
{% elif post.discord_vid %}
|
||||
<div class="screenshot-container video"><video src="{{ post.url }}" width="50" height="48"></video></div>
|
||||
{% endif %}
|
||||
{% if post.screenshot %}
|
||||
<a href="{% url "main:post-view" post.id %}" class="screenshot-container still-image"><img src="{{ post.screenshot }}"></a>
|
||||
{% endif %}
|
||||
@@ -61,4 +63,4 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -84,6 +84,11 @@
|
||||
|
||||
{% if post.yt_vid %}
|
||||
<div class="screenshot-container video"><iframe class="youtube-player" type="text/html" width="490" height="276" src="https://www.youtube.com/embed/{{ post.yt_vid }}?rel=0&modestbranding=1&iv_load_policy=3" frameborder="0"></iframe></div>
|
||||
{% elif post.discord_vid %}
|
||||
<div class="DiscordCDN-container video">
|
||||
<video class="discord-player" src="{{ post.url }}" controls></video>
|
||||
</div>
|
||||
<a>Discord embedded video</a>
|
||||
{% elif post.url %}
|
||||
<p class="url-link"><a class="link-confirm" href="{{ post.url }}" target="_blank">{{ post.url }}</a></p>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -157,12 +157,6 @@ def filterchars(str=""):
|
||||
for char in forbid:
|
||||
if char in str:
|
||||
str = str.replace(char, " ")
|
||||
if str.isspace():
|
||||
try:
|
||||
girls = json.load(open(settings.BASE_DIR + '/girls.json'))
|
||||
except:
|
||||
girls = ['None']
|
||||
return choice(girls)
|
||||
return str
|
||||
|
||||
# Check IP for proxy.
|
||||
@@ -173,12 +167,3 @@ def iphub(addr):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# NNID blacklist check
|
||||
def nnid_blacked(nnid):
|
||||
blacklist = json.load(open(settings.nnid_forbiddens))
|
||||
# The NNID server omits dashes and dots from NNIDs, gotta make sure nobody gets through this
|
||||
nnid = nnid.lower().replace('-', '').replace('.', '')
|
||||
if nnid in blacklist:
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -287,9 +287,6 @@ def signup_page(request):
|
||||
else:
|
||||
spamuser = True
|
||||
if request.POST['origin_id']:
|
||||
if settings.nnid_forbiddens:
|
||||
if nnid_blacked(request.POST['origin_id']):
|
||||
return HttpResponseForbidden("You are very funny. Unfortunately, your funniness blah blah blah fuck off.")
|
||||
if User.nnid_in_use(request.POST['origin_id']):
|
||||
return HttpResponseBadRequest("That Nintendo Network ID is already in use, that would cause confusion.")
|
||||
mii = get_mii(request.POST['origin_id'])
|
||||
@@ -408,9 +405,6 @@ def user_view(request, username):
|
||||
return json_response("Your e-mail address is invalid. Input an e-mail address, or input nothing.")
|
||||
if User.nnid_in_use(request.POST.get('origin_id'), request):
|
||||
return json_response("That Nintendo Network ID is already in use, that would cause confusion.")
|
||||
if settings.nnid_forbiddens:
|
||||
if nnid_blacked(request.POST['origin_id']):
|
||||
return json_response("You are very funny. Unfortunately, your funniness blah blah blah fuck off.")
|
||||
if user.has_plain_avatar():
|
||||
user.avatar = request.POST.get('avatar') or ''
|
||||
if request.POST.get('avatar') == '1':
|
||||
|
||||
Reference in New Issue
Block a user