forked from rDrama/rDrama
add file orgies
parent
60eaa5d282
commit
f0e6814384
|
@ -7,31 +7,49 @@
|
|||
.orgy-top-container {
|
||||
flex-flow: column wrap;
|
||||
}
|
||||
.orgy-info-window-item {
|
||||
max-height: 20% !important;
|
||||
height: 20% !important;
|
||||
}
|
||||
.orgy-chat-window-item {
|
||||
max-height: 80% !important;
|
||||
height: 80% !important;
|
||||
}
|
||||
}
|
||||
@media all and (min-width: 900px) {
|
||||
.orgy-top-container {
|
||||
flex-flow: row nowrap;
|
||||
.orgy-chat-window-item {
|
||||
max-width: max(30vw, calc(100vw - 1080px));
|
||||
}
|
||||
}
|
||||
|
||||
.orgy-chat-window-item {
|
||||
flex-grow: 2;
|
||||
width: fit-content;
|
||||
}
|
||||
.orgy-info-window-item {
|
||||
max-width: 550px;
|
||||
width: 550px;
|
||||
}
|
||||
|
||||
.rumble-player {
|
||||
aspect-ratio: 16/9;
|
||||
max-width: min(70vw,500px) !important;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#orgy-file-container {
|
||||
position: relative;
|
||||
width: -webkit-fill-available;
|
||||
max-width: 1080px !important;
|
||||
z-index: 1000000004;
|
||||
}
|
||||
@media all and (max-width: 900px) {
|
||||
#orgy-file-container {
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
#orgy-file-container > video {
|
||||
max-height: initial !important;
|
||||
}
|
||||
|
||||
#cursormarsey, #cursormarsey-heart {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body > .container {
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
const orgy_file = document.getElementById('orgy-file');
|
||||
|
||||
addEventListener("load", () => {
|
||||
orgy_file.play()
|
||||
});
|
||||
document.addEventListener('click', () => {
|
||||
if (orgy_file.paused) orgy_file.play();
|
||||
}, {once : true});
|
||||
|
||||
function add_playing_listener() {
|
||||
orgy_file.addEventListener('playing', () => {
|
||||
const now = Date.now() / 1000;
|
||||
const created_utc = orgy_file.dataset.created_utc
|
||||
orgy_file.currentTime = now - created_utc
|
||||
}, {once : true});
|
||||
}
|
||||
|
||||
add_playing_listener()
|
||||
|
||||
orgy_file.addEventListener('pause', () => {
|
||||
add_playing_listener()
|
||||
})
|
|
@ -1,60 +1,25 @@
|
|||
import time
|
||||
from flask import g
|
||||
from flask import g, abort
|
||||
|
||||
from sqlalchemy import Column
|
||||
from sqlalchemy.sql.sqltypes import *
|
||||
|
||||
from files.classes import Base
|
||||
from files.helpers.config.const import *
|
||||
from files.helpers.regex import *
|
||||
from files.helpers.sanitize import normalize_url, get_youtube_id_and_t
|
||||
|
||||
class Orgy(Base):
|
||||
__tablename__ = "orgies"
|
||||
|
||||
id = Column(Integer, primary_key = True)
|
||||
type = Column(Integer, primary_key = True)
|
||||
type = Column(String, primary_key=True)
|
||||
data = Column(String)
|
||||
title = Column(String)
|
||||
created_utc = Column(Integer)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def is_youtube(self):
|
||||
return self.type == OrgyTypes.YOUTUBE
|
||||
def is_rumble(self):
|
||||
return self.type == OrgyTypes.RUMBLE
|
||||
def is_twitch(self):
|
||||
return self.type == OrgyTypes.TWITCH
|
||||
def __init__(self, *args, **kwargs):
|
||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<{self.__class__.__name__}(id={self.id}, type={self.type}, data={self.data} title={self.title})>"
|
||||
|
||||
return f"<{self.__class__.__name__}(type={self.type}, data={self.data} title={self.title})>"
|
||||
|
||||
def get_orgy():
|
||||
orgy = g.db.query(Orgy).one_or_none()
|
||||
return orgy
|
||||
|
||||
def create_orgy(link, title):
|
||||
assert not get_orgy()
|
||||
normalized_link = normalize_url(link)
|
||||
data = None
|
||||
orgy_type = -1
|
||||
if re.match(bare_youtube_regex, normalized_link):
|
||||
orgy_type = OrgyTypes.YOUTUBE
|
||||
data, _ = get_youtube_id_and_t(normalized_link)
|
||||
elif re.match(rumble_regex, normalized_link):
|
||||
orgy_type = OrgyTypes.RUMBLE
|
||||
data = normalized_link
|
||||
elif re.match(twitch_regex, normalized_link):
|
||||
orgy_type = OrgyTypes.TWITCH
|
||||
data = re.search(twitch_regex, normalized_link).group(3)
|
||||
else:
|
||||
assert False
|
||||
|
||||
orgy = Orgy(title=title, id=0, type = orgy_type, data = data)
|
||||
g.db.add(orgy)
|
||||
|
||||
def end_orgy():
|
||||
assert get_orgy()
|
||||
g.db.query(Orgy).delete()
|
||||
return g.db.query(Orgy).one_or_none()
|
||||
|
|
|
@ -1948,18 +1948,46 @@ def orgy_control(v):
|
|||
@app.post("/admin/start_orgy")
|
||||
@admin_level_required(PERMS['ORGIES'])
|
||||
def start_orgy(v):
|
||||
link = request.values.get("link")
|
||||
title = request.values.get("title")
|
||||
link = request.values.get("link", "").strip()
|
||||
title = request.values.get("title", "").strip()
|
||||
|
||||
assert link
|
||||
assert title
|
||||
if not link:
|
||||
abort(400, "A link is required!")
|
||||
|
||||
create_orgy(link, title)
|
||||
if not title:
|
||||
abort(400, "A title is required!")
|
||||
|
||||
if get_orgy():
|
||||
abort(400, "An orgy is already in progress")
|
||||
|
||||
normalized_link = normalize_url(link)
|
||||
|
||||
if re.match(bare_youtube_regex, normalized_link):
|
||||
orgy_type = 'youtube'
|
||||
data, _ = get_youtube_id_and_t(normalized_link)
|
||||
elif re.match(rumble_regex, normalized_link):
|
||||
orgy_type = 'rumble'
|
||||
data = normalized_link
|
||||
elif re.match(twitch_regex, normalized_link):
|
||||
orgy_type = 'twitch'
|
||||
data = re.search(twitch_regex, normalized_link).group(3)
|
||||
elif normalized_link.endswith('.mp4'):
|
||||
orgy_type = 'file'
|
||||
data = normalized_link
|
||||
else:
|
||||
abort(400)
|
||||
|
||||
orgy = Orgy(
|
||||
title=title,
|
||||
type=orgy_type,
|
||||
data=data
|
||||
)
|
||||
g.db.add(orgy)
|
||||
|
||||
return {"message": "Orgy started successfully!"}
|
||||
|
||||
@app.post("/admin/stop_orgy")
|
||||
@admin_level_required(PERMS['ORGIES'])
|
||||
def stop_orgy(v):
|
||||
end_orgy()
|
||||
g.db.query(Orgy).delete()
|
||||
return {"message": "Orgy stopped successfully!"}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
</div>
|
||||
<div class="d-lg-flex border-bottom">
|
||||
<div class="title w-lg-25">
|
||||
<label for="link">Livestream link (youtube, twitch, rumble)</label>
|
||||
<label for="link">Livestream link (youtube, twitch, rumble, mp4 file)</label>
|
||||
</div>
|
||||
<div class="body w-lg-100">
|
||||
<input id="link" autocomplete="off" type="text" name="link" class="form-control">
|
||||
|
|
|
@ -8,25 +8,27 @@
|
|||
{% include "modals/emoji.html" %}
|
||||
{% include "util/macros.html" %}
|
||||
{% set vlink = '<a href="/id/' ~ v.id ~ '">' %}
|
||||
<div class="container pb-4">
|
||||
|
||||
<div class="orgy-top-container">
|
||||
<div class="col text-left pt-3 orgy-info-window-item">
|
||||
<div class="col text-left pt-3">
|
||||
<h2>{{orgy.title}}</h1>
|
||||
<div>
|
||||
{% if orgy.is_youtube() %}
|
||||
{% if orgy.type == 'youtube' %}
|
||||
<lite-youtube videoid="{{orgy.data}}" params="autoplay=1&modestbranding=1"/>
|
||||
{% elif orgy.is_rumble() %}
|
||||
{% elif orgy.type == 'rumble' %}
|
||||
<iframe class="rumble rumble-player" width="100%" src="{{orgy.data}}" frameborder="0" allowfullscreen></iframe>
|
||||
{% elif orgy.is_twitch() %}
|
||||
{% elif orgy.type == 'twitch' %}
|
||||
<iframe
|
||||
src="https://player.twitch.tv/?channel={{orgy.data}}&parent={{site}}"
|
||||
class="rumble-player"
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
{% elif orgy.type == 'file' %}
|
||||
<p id="orgy-file-container" class="resizable">
|
||||
<video id="orgy-file" data-created_utc="{{orgy.created_utc}}" controls preload="none" src="{{orgy.data}}"></video>
|
||||
</p>
|
||||
<script defer src="{{'js/orgy_file.js' | asset}}"></script>
|
||||
{% endif %}
|
||||
</div>
|
||||
<a href="/old_chat" class="btn btn-primary ml-auto" value="Old Chat">Old Chat</a>
|
||||
{{macros.chat_users_list()}}
|
||||
</div>
|
||||
|
||||
|
@ -42,8 +44,6 @@
|
|||
{{macros.chat_users_online()}}
|
||||
{{macros.chat_window(vlink)}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input id="vid" hidden value="{{v.id}}">
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
drop table public.orgies;
|
||||
CREATE TABLE public.orgies (
|
||||
type character varying(8) primary key,
|
||||
data character varying(200) NOT NULL,
|
||||
title character varying(1000) NOT NULL,
|
||||
created_utc int not null
|
||||
);
|
Loading…
Reference in New Issue