dsffsd
This commit is contained in:
parent
43e04814c7
commit
5884d71a5c
9 changed files with 8 additions and 96 deletions
|
@ -20,8 +20,7 @@ services:
|
|||
- DISCORD_CLIENT_ID=3435tdfsdudebussylmaoxxt43
|
||||
- DISCORD_CLIENT_SECRET=3435tdfsdudebussylmaoxxt43
|
||||
- DISCORD_BOT_TOKEN=3435tdfsdudebussylmaoxxt43
|
||||
- IMGUR_KEY=3435tdfsdudebussylmaoxxt43
|
||||
- IBB_KEY=3435tdfsdudebussylmaoxxt43
|
||||
- CATBOX_KEY=3435tdfsdudebussylmaoxxt43
|
||||
#- HCAPTCHA_SITEKEY=3435tdfsdudebussylmaoxxt43
|
||||
- HCAPTCHA_SECRET=3435tdfsdudebussylmaoxxt43
|
||||
- YOUTUBE_KEY=3435tdfsdudebussylmaoxxt43
|
||||
|
|
3
env
3
env
|
@ -10,8 +10,7 @@ export DISCORD_SERVER_ID="3435tdfsdudebussylmaoxxt43"
|
|||
export DISCORD_CLIENT_ID="3435tdfsdudebussylmaoxxt43"
|
||||
export DISCORD_CLIENT_SECRET="3435tdfsdudebussylmaoxxt43"
|
||||
export DISCORD_BOT_TOKEN="3435tdfsdudebussylmaoxxt43"
|
||||
export IMGUR_KEY="3435tdfsdudebussylmaoxxt43"
|
||||
export IBB_KEY="3435tdfsdudebussylmaoxxt43"
|
||||
export CATBOX_KEY="3435tdfsdudebussylmaoxxt43"
|
||||
export HCAPTCHA_SECRET="3435tdfsdudebussylmaoxxt43"
|
||||
export YOUTUBE_KEY="3435tdfsdudebussylmaoxxt43"
|
||||
export PUSHER_KEY="3435tdfsdudebussylmaoxxt43"
|
||||
|
|
|
@ -26,7 +26,6 @@ class Submission(Base):
|
|||
is_banned = Column(Boolean, default=False)
|
||||
removed_by = Column(Integer)
|
||||
bannedfor = Column(Boolean)
|
||||
processing = Column(Boolean, default=False)
|
||||
views = Column(Integer, default=0)
|
||||
deleted_utc = Column(Integer, default=0)
|
||||
distinguish_level = Column(Integer, default=0)
|
||||
|
|
|
@ -6,8 +6,6 @@ from flask import g
|
|||
from werkzeug.utils import secure_filename
|
||||
from webptools import gifwebp
|
||||
|
||||
IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
|
||||
IBB_KEY = environ.get("IBB_KEY", "").strip()
|
||||
CATBOX_KEY = environ.get("CATBOX_KEY", "").strip()
|
||||
|
||||
def upload_ibb(file=None, resize=False):
|
||||
|
@ -49,26 +47,9 @@ class UploadException(Exception):
|
|||
|
||||
def upload_video(file):
|
||||
|
||||
file_path = path.join("temp", secure_filename(file.filename))
|
||||
file.save(file_path)
|
||||
file.save("video.mp4")
|
||||
|
||||
headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}
|
||||
with open(file_path, 'rb') as f:
|
||||
try:
|
||||
r = requests.post('https://api.imgur.com/3/upload', headers=headers, files={"video": f})
|
||||
with open("video.mp4", 'rb') as f:
|
||||
req = requests.post('https://catbox.moe/user/api.php', data={'userhash':CATBOX_KEY, 'reqtype':'fileupload'}, files={'fileToUpload':f})
|
||||
|
||||
r.raise_for_status()
|
||||
|
||||
resp = r.json()['data']
|
||||
except requests.HTTPError as e:
|
||||
raise UploadException("Invalid video. Make sure it's 1 minute long or shorter.")
|
||||
except:
|
||||
raise UploadException("Error, please try again later.")
|
||||
finally:
|
||||
remove(file_path)
|
||||
|
||||
link = resp['link']
|
||||
img = Image(text=link, deletehash=resp['deletehash'])
|
||||
g.db.add(img)
|
||||
|
||||
return link
|
||||
return req.text
|
||||
|
|
|
@ -18,7 +18,6 @@ from files.__main__ import app, cache, limiter
|
|||
from .front import frontlist
|
||||
from files.helpers.discord import add_role
|
||||
|
||||
IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
|
||||
SITE_NAME = environ.get("SITE_NAME", "").strip()
|
||||
|
||||
|
||||
|
|
|
@ -169,11 +169,6 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
|
||||
posts = posts.filter_by(is_banned=False, stickied=None, private=False, deleted_utc = 0)
|
||||
|
||||
if v:
|
||||
posts = posts.filter(or_(Submission.processing == False, Submission.author_id == v.id))
|
||||
else:
|
||||
posts = posts.filter_by(processing=False)
|
||||
|
||||
if v and v.admin_level == 0:
|
||||
blocking = [x[0] for x in g.db.query(
|
||||
UserBlock.target_id).filter_by(
|
||||
|
|
|
@ -384,43 +384,6 @@ def filter_title(title):
|
|||
return title
|
||||
|
||||
|
||||
IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
|
||||
|
||||
|
||||
def check_processing_thread(v, post, link):
|
||||
|
||||
image_id = link.split('/')[-1].rstrip('.mp4')
|
||||
headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}
|
||||
|
||||
while True:
|
||||
# break on error to prevent zombie threads
|
||||
try:
|
||||
time.sleep(15)
|
||||
|
||||
req = requests.get(f"https://api.imgur.com/3/image/{image_id}", headers=headers)
|
||||
|
||||
status = req.json()['data']['processing']['status']
|
||||
if status == 'completed':
|
||||
post.processing = False
|
||||
g.db.add(post)
|
||||
|
||||
send_notification(
|
||||
NOTIFICATIONS_ACCOUNT,
|
||||
v,
|
||||
f"Your video has finished processing and your [post](/post/{post.id}) is now live."
|
||||
)
|
||||
|
||||
g.db.commit()
|
||||
break
|
||||
# just in case
|
||||
elif status == 'failed':
|
||||
print(f"video upload for post {post.id} failed")
|
||||
break
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
print("retard. aborting thread")
|
||||
break
|
||||
|
||||
|
||||
def thumbnail_thread(pid):
|
||||
|
||||
|
@ -870,29 +833,8 @@ def submit_post(v):
|
|||
body=request.values.get("body", "")
|
||||
), 403
|
||||
|
||||
if file.content_type.startswith('image/'):
|
||||
new_post.url = upload_ibb(file=file)
|
||||
else:
|
||||
try:
|
||||
post_url = upload_video(file)
|
||||
if not post_url.endswith('.mp4'):
|
||||
post_url += 'mp4'
|
||||
new_post.url = post_url
|
||||
new_post.processing = True
|
||||
gevent.spawn(check_processing_thread, v.id, new_post, post_url)
|
||||
except UploadException as e:
|
||||
if request.headers.get("Authorization"):
|
||||
return {
|
||||
"error": str(e),
|
||||
}, 400
|
||||
else:
|
||||
return render_template(
|
||||
"submit.html",
|
||||
v=v,
|
||||
error=str(e),
|
||||
title=title,
|
||||
body=request.values.get("body", "")
|
||||
), 400
|
||||
if file.content_type.startswith('image/'): new_post.url = upload_ibb(file=file)
|
||||
elif file.content_type.startswith('video/'): new_post.post_url = upload_video(file)
|
||||
|
||||
g.db.add(new_post)
|
||||
|
||||
|
|
|
@ -267,7 +267,6 @@
|
|||
{% if p.is_bot %} <i class="fad fa-robot text-info" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Bot"></i>{% endif %}
|
||||
{% if p.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span>{% endif %}
|
||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
|
||||
{% if p.processing %}<span class="badge border-warning border-1 text-small-extra">uploading...</span>{% endif %}
|
||||
{% if p.active_flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px; font-size:10px;" onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags}} Reports</a>{% endif %}
|
||||
{% if p.author.verified %}<i class="fas fa-badge-check align-middle ml-1" style="color:#1DA1F2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{p.author.verified}}"></i>
|
||||
{% endif %}
|
||||
|
|
|
@ -137,7 +137,6 @@
|
|||
{% if p.is_blocking %}<i class="fas fa-user-minus text-warning" data-bs-toggle="tooltip" data-bs-placement="bottom" title="You're blocking this user, but you can see this post because {{'it\'s pinned' if p.stickied else 'you\'re an admin'}}."></i>{% endif %}
|
||||
{% if p.is_blocked %}<i class="fas fa-user-minus text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="This user is blocking you."></i>{% endif %}
|
||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">Draft</span>{% endif %}
|
||||
{% if p.processing %}<span class="badge border-warning border-1 text-small-extra">uploading...</span>{% endif %}
|
||||
{% if p.active_flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px; font-size:10px;" onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{p.active_flags}} Reports</a>{% endif %}
|
||||
{% if p.author.verified %}<i class="fas fa-badge-check align-middle ml-1" style="color:#1DA1F2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{p.author.verified}}"></i>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue