forked from rDrama/rDrama
add file orgies
parent
60eaa5d282
commit
f0e6814384
|
@ -7,31 +7,49 @@
|
||||||
.orgy-top-container {
|
.orgy-top-container {
|
||||||
flex-flow: column wrap;
|
flex-flow: column wrap;
|
||||||
}
|
}
|
||||||
.orgy-info-window-item {
|
|
||||||
max-height: 20% !important;
|
|
||||||
height: 20% !important;
|
|
||||||
}
|
|
||||||
.orgy-chat-window-item {
|
.orgy-chat-window-item {
|
||||||
max-height: 80% !important;
|
max-height: 80% !important;
|
||||||
height: 80% !important;
|
height: 80% !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media all and (min-width: 900px) {
|
@media all and (min-width: 900px) {
|
||||||
.orgy-top-container {
|
.orgy-chat-window-item {
|
||||||
flex-flow: row nowrap;
|
max-width: max(30vw, calc(100vw - 1080px));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.orgy-chat-window-item {
|
.orgy-chat-window-item {
|
||||||
flex-grow: 2;
|
flex-grow: 2;
|
||||||
width: fit-content;
|
|
||||||
}
|
|
||||||
.orgy-info-window-item {
|
|
||||||
max-width: 550px;
|
|
||||||
width: 550px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.rumble-player {
|
.rumble-player {
|
||||||
aspect-ratio: 16/9;
|
aspect-ratio: 16/9;
|
||||||
max-width: min(70vw,500px) !important;
|
max-width: min(70vw,500px) !important;
|
||||||
width: 500px;
|
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
|
import time
|
||||||
from flask import g
|
from flask import g, abort
|
||||||
|
|
||||||
from sqlalchemy import Column
|
from sqlalchemy import Column
|
||||||
from sqlalchemy.sql.sqltypes import *
|
from sqlalchemy.sql.sqltypes import *
|
||||||
|
|
||||||
from files.classes import Base
|
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):
|
class Orgy(Base):
|
||||||
__tablename__ = "orgies"
|
__tablename__ = "orgies"
|
||||||
|
|
||||||
id = Column(Integer, primary_key = True)
|
type = Column(String, primary_key=True)
|
||||||
type = Column(Integer, primary_key = True)
|
|
||||||
data = Column(String)
|
data = Column(String)
|
||||||
title = Column(String)
|
title = Column(String)
|
||||||
|
created_utc = Column(Integer)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(**kwargs)
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
super().__init__(*args, **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 __repr__(self):
|
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():
|
def get_orgy():
|
||||||
orgy = g.db.query(Orgy).one_or_none()
|
return 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()
|
|
||||||
|
|
|
@ -1948,18 +1948,46 @@ def orgy_control(v):
|
||||||
@app.post("/admin/start_orgy")
|
@app.post("/admin/start_orgy")
|
||||||
@admin_level_required(PERMS['ORGIES'])
|
@admin_level_required(PERMS['ORGIES'])
|
||||||
def start_orgy(v):
|
def start_orgy(v):
|
||||||
link = request.values.get("link")
|
link = request.values.get("link", "").strip()
|
||||||
title = request.values.get("title")
|
title = request.values.get("title", "").strip()
|
||||||
|
|
||||||
assert link
|
if not link:
|
||||||
assert title
|
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!"}
|
return {"message": "Orgy started successfully!"}
|
||||||
|
|
||||||
@app.post("/admin/stop_orgy")
|
@app.post("/admin/stop_orgy")
|
||||||
@admin_level_required(PERMS['ORGIES'])
|
@admin_level_required(PERMS['ORGIES'])
|
||||||
def stop_orgy(v):
|
def stop_orgy(v):
|
||||||
end_orgy()
|
g.db.query(Orgy).delete()
|
||||||
return {"message": "Orgy stopped successfully!"}
|
return {"message": "Orgy stopped successfully!"}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="d-lg-flex border-bottom">
|
<div class="d-lg-flex border-bottom">
|
||||||
<div class="title w-lg-25">
|
<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>
|
||||||
<div class="body w-lg-100">
|
<div class="body w-lg-100">
|
||||||
<input id="link" autocomplete="off" type="text" name="link" class="form-control">
|
<input id="link" autocomplete="off" type="text" name="link" class="form-control">
|
||||||
|
|
|
@ -8,41 +8,41 @@
|
||||||
{% include "modals/emoji.html" %}
|
{% include "modals/emoji.html" %}
|
||||||
{% include "util/macros.html" %}
|
{% include "util/macros.html" %}
|
||||||
{% set vlink = '<a href="/id/' ~ v.id ~ '">' %}
|
{% set vlink = '<a href="/id/' ~ v.id ~ '">' %}
|
||||||
<div class="container pb-4">
|
<div class="orgy-top-container">
|
||||||
|
<div class="col text-left pt-3">
|
||||||
|
<h2>{{orgy.title}}</h1>
|
||||||
|
<div>
|
||||||
|
{% if orgy.type == 'youtube' %}
|
||||||
|
<lite-youtube videoid="{{orgy.data}}" params="autoplay=1&modestbranding=1"/>
|
||||||
|
{% elif orgy.type == 'rumble' %}
|
||||||
|
<iframe class="rumble rumble-player" width="100%" src="{{orgy.data}}" frameborder="0" allowfullscreen></iframe>
|
||||||
|
{% 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>
|
||||||
|
{{macros.chat_users_list()}}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="orgy-top-container">
|
<div class="orgy-chat-window-item">
|
||||||
<div class="col text-left pt-3 orgy-info-window-item">
|
<div id="chat-group-template" class="d-none">
|
||||||
<h2>{{orgy.title}}</h1>
|
{{macros.chat_group_template()}}
|
||||||
<div>
|
|
||||||
{% if orgy.is_youtube() %}
|
|
||||||
<lite-youtube videoid="{{orgy.data}}" params="autoplay=1&modestbranding=1"/>
|
|
||||||
{% elif orgy.is_rumble() %}
|
|
||||||
<iframe class="rumble rumble-player" width="100%" src="{{orgy.data}}" frameborder="0" allowfullscreen></iframe>
|
|
||||||
{% elif orgy.is_twitch() %}
|
|
||||||
<iframe
|
|
||||||
src="https://player.twitch.tv/?channel={{orgy.data}}&parent={{site}}"
|
|
||||||
class="rumble-player"
|
|
||||||
allowfullscreen>
|
|
||||||
</iframe>
|
|
||||||
{%endif%}
|
|
||||||
</div>
|
</div>
|
||||||
<a href="/old_chat" class="btn btn-primary ml-auto" value="Old Chat">Old Chat</a>
|
|
||||||
{{macros.chat_users_list()}}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="orgy-chat-window-item">
|
<div id="chat-line-template" class="d-none">
|
||||||
<div id="chat-group-template" class="d-none">
|
{{macros.chat_line_template()}}
|
||||||
{{macros.chat_group_template()}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="chat-line-template" class="d-none">
|
|
||||||
{{macros.chat_line_template()}}
|
|
||||||
</div>
|
|
||||||
{{macros.chat_users_online()}}
|
|
||||||
{{macros.chat_window(vlink)}}
|
|
||||||
</div>
|
</div>
|
||||||
|
{{macros.chat_users_online()}}
|
||||||
|
{{macros.chat_window(vlink)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -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