forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-10-09 17:29:49 +02:00
parent b30a8a2c23
commit ab7faaf5b8
2 changed files with 25 additions and 31 deletions

View File

@ -556,38 +556,32 @@ def submit_post(v):
Submission.body == body Submission.body == body
).first() ).first()
if dup: if dup: return redirect(dup.permalink)
return redirect(dup.permalink)
if domain:
domain_obj = get_domain(domain)
if domain_obj:
if domain_obj.reason==4: v.ban(days=30, reason="Digitally malicious content")
elif domain_obj.reason==7: v.ban(reason="Sexualizing minors")
domain_obj = get_domain(domain) if request.headers.get("Authorization"): return {"error":"ToS violation"}, 400
if domain_obj: else: return render_template("submit.html", v=v, error="ToS Violation", title=title, url=url, body=request.values.get("body", "")), 400
if domain_obj.reason==4: elif "twitter.com" in domain:
v.ban(days=30, reason="Digitally malicious content") try: embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}).json()["html"]
elif domain_obj.reason==7: except: embed = None
v.ban(reason="Sexualizing minors") elif "youtu" in domain:
try:
if request.headers.get("Authorization"): return {"error":"ToS violation"}, 400 yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2)
else: return render_template("submit.html", v=v, error="ToS Violation", title=title, url=url, body=request.values.get("body", "")), 400 params = parse_qs(urlparse(url).query)
t = params.get('t', params.get('start', [0]))[0]
if "twitter.com" in domain: if t: embed = f"https://youtube.com/embed/{yt_id}?start={t}"
try: embed = requests.get("https://publish.twitter.com/oembed", params={"url":url, "omit_script":"t"}).json()["html"] else: embed = f"https://youtube.com/embed/{yt_id}"
except: embed = None except: embed = None
elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url:
elif "youtu" in domain: id = url.split("/post/")[1]
try: if "/" in id: id = id.split("/")[0]
yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2) embed = id
params = parse_qs(urlparse(url).query) else: embed = None
t = params.get('t', params.get('start', [0]))[0]
if t: embed = f"https://youtube.com/embed/{yt_id}?start={t}"
else: embed = f"https://youtube.com/embed/{yt_id}"
except: embed = None
elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url:
id = url.split("/post/")[1]
if "/" in id: id = id.split("/")[0]
embed = id
else: embed = None else: embed = None
now = int(time.time()) now = int(time.time())

View File

@ -184,7 +184,7 @@
<a class="nav-item nav-link" rel="nofollow noopener noreferrer" href="https://github.com/Aevann1/Drama"><i class="fab fa-github fa-fw mr-3"></i>Source code</a> <a class="nav-item nav-link" rel="nofollow noopener noreferrer" href="https://github.com/Aevann1/Drama"><i class="fab fa-github fa-fw mr-3"></i>Source code</a>
<a class="nav-item nav-link" rel="nofollow noopener noreferrer" href="https://github.com/Aevann1/Drama"><i class="fab fa-github fa-fw mr-3"></i>Report bugs</a> <a class="nav-item nav-link" rel="nofollow noopener noreferrer" href="https://github.com/Aevann1/Drama"><i class="fab fa-bug fa-fw mr-3"></i>Report bugs</a>
<a class="nav-item nav-link" href="/discord"><i class="fab fa-discord fa-fw mr-3"></i>Discord</a> <a class="nav-item nav-link" href="/discord"><i class="fab fa-discord fa-fw mr-3"></i>Discord</a>
{% if 'pcm' not in request.host %}<a class="nav-item nav-link" rel="nofollow noopener noreferrer" href="{{'GUMROAD_LINK' | app_config}}"><i class="fas fa-dollar-sign fa-fw mr-3"></i>Donate</a>{% endif %} {% if 'pcm' not in request.host %}<a class="nav-item nav-link" rel="nofollow noopener noreferrer" href="{{'GUMROAD_LINK' | app_config}}"><i class="fas fa-dollar-sign fa-fw mr-3"></i>Donate</a>{% endif %}