Support Rumble
parent
70e1904f8c
commit
2626b0587c
|
@ -12,3 +12,8 @@
|
|||
max-width: 550px;
|
||||
width: 550px;
|
||||
}
|
||||
.rumble-player {
|
||||
aspect-ratio: 16/9;
|
||||
max-width: min(70vw,500px) !important;
|
||||
width: 500px;
|
||||
}
|
||||
|
|
|
@ -15,29 +15,47 @@ from files.helpers.config.const import *
|
|||
from files.helpers.lazy import lazy
|
||||
from files.helpers.regex import *
|
||||
from files.helpers.sorting_and_time import *
|
||||
from files.helpers.sanitize import normalize_url, get_youtube_id_and_t
|
||||
|
||||
class Orgy(Base):
|
||||
__tablename__ = "orgies"
|
||||
|
||||
youtube_id = Column(String, primary_key=True)
|
||||
id = Column(Integer, primary_key = True)
|
||||
type = Column(Integer, primary_key = True)
|
||||
data = Column(String)
|
||||
title = Column(String)
|
||||
|
||||
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 __repr__(self):
|
||||
return f"<{self.__class__.__name__}(id={self.youtube_id}, title={self.title})>"
|
||||
return f"<{self.__class__.__name__}(id={self.id}, 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(youtube_id, title):
|
||||
def create_orgy(link, title):
|
||||
assert not get_orgy()
|
||||
assert re.match(yt_id_regex, youtube_id)
|
||||
orgy = Orgy(title=title, youtube_id=youtube_id)
|
||||
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
|
||||
else:
|
||||
assert False
|
||||
|
||||
orgy = Orgy(title=title, id=0, type = orgy_type, data = data)
|
||||
g.db.add(orgy)
|
||||
g.db.flush()
|
||||
g.db.commit()
|
||||
|
|
|
@ -1265,6 +1265,10 @@ GIRL_NAMES = {
|
|||
'Z': ['Zoe', 'Zoey', 'Zaria', 'Zoie']
|
||||
}
|
||||
|
||||
class OrgyTypes:
|
||||
YOUTUBE = 1
|
||||
RUMBLE = 2
|
||||
|
||||
from sqlalchemy import *
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
|
||||
|
|
|
@ -126,6 +126,9 @@ giphy_regex = re.compile('(https:\/\/media\.giphy\.com\/media\/[a-z0-9]+\/giphy)
|
|||
youtube_regex = re.compile('(<p>[^<]*)(https:\/\/youtube\.com\/watch\?[\w\-.#&/=?@%+]{7,})', flags=re.I|re.A)
|
||||
yt_id_regex = re.compile('[\w\-]{5,20}', flags=re.A)
|
||||
|
||||
rumble_regex = re.compile('https://rumble\.com/embed/([a-zA-Z0-9]*)/\?pub=([a-zA-Z0-9]*)',flags=re.I|re.A)
|
||||
bare_youtube_regex = re.compile('https:\/\/youtube\.com\/watch\?([\w\-.#&/=?@%+]{7,})',flags=re.I|re.A)
|
||||
|
||||
link_fix_regex = re.compile("(\[.*?\]\()(?!http|\/)(.*?\))" + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||
|
||||
css_url_regex = re.compile('url\(\s*[\'"]?(.*?)[\'"]?\s*\)', flags=re.I|re.A)
|
||||
|
|
|
@ -300,14 +300,12 @@ def sanitize_settings_text(sanitized:Optional[str], max_length:Optional[int]=Non
|
|||
if max_length: sanitized = sanitized[:max_length]
|
||||
return sanitized
|
||||
|
||||
|
||||
def handle_youtube_links(url):
|
||||
html = None
|
||||
def get_youtube_id_and_t(url):
|
||||
params = parse_qs(urlparse(url).query, keep_blank_values=True)
|
||||
|
||||
id = params.get('v')
|
||||
|
||||
if not id: return None
|
||||
if not id: return (None, None)
|
||||
|
||||
id = id[0]
|
||||
|
||||
|
@ -318,7 +316,14 @@ def handle_youtube_links(url):
|
|||
t = split[1]
|
||||
|
||||
id = id.split('?')[0]
|
||||
|
||||
return (id, t)
|
||||
|
||||
def handle_youtube_links(url):
|
||||
params = parse_qs(urlparse(url).query, keep_blank_values=True)
|
||||
html = None
|
||||
id, t = get_youtube_id_and_t(url)
|
||||
if not id: return None
|
||||
if yt_id_regex.fullmatch(id):
|
||||
if not t:
|
||||
t = params.get('t', params.get('start', [0]))[0]
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
<div class="col text-left d-none d-lg-block pt-3 orgy-info-window-item">
|
||||
<h2>{{orgy.title}}</h1>
|
||||
<div>
|
||||
<lite-youtube videoid="{{orgy.youtube_id}}" params="autoplay=1&modestbranding=1"/>
|
||||
{% 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>
|
||||
{%endif%}
|
||||
</div>
|
||||
{{macros.chat_users_list()}}
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
DROP TABLE orgies; --Don't worry: Orgies should only have between 0 and 1 rows...
|
||||
CREATE TABLE public.orgies (
|
||||
id integer NOT NULL,
|
||||
type integer NOT NULL,
|
||||
data character varying(200) NOT NULL,
|
||||
title character varying(1000) NOT NULL
|
||||
);
|
|
@ -2,5 +2,5 @@ add_header Referrer-Policy "same-origin";
|
|||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
|
||||
add_header X-Frame-Options "deny";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
add_header Content-Security-Policy "default-src 'none'; frame-ancestors 'none'; form-action 'self'; manifest-src 'self'; worker-src 'self'; base-uri 'self'; font-src 'self'; style-src-elem 'self'; style-src-attr 'unsafe-inline'; style-src 'self' 'unsafe-inline'; script-src-elem 'self' challenges.cloudflare.com; script-src-attr 'none'; script-src 'self' challenges.cloudflare.com; media-src 'self' https:; img-src 'self' https: data:; frame-src challenges.cloudflare.com www.youtube-nocookie.com platform.twitter.com; connect-src 'self' tls-use1.fpapi.io api.fpjs.io;";
|
||||
add_header Content-Security-Policy "default-src 'none'; frame-ancestors 'none'; form-action 'self'; manifest-src 'self'; worker-src 'self'; base-uri 'self'; font-src 'self'; style-src-elem 'self'; style-src-attr 'unsafe-inline'; style-src 'self' 'unsafe-inline'; script-src-elem 'self' challenges.cloudflare.com; script-src-attr 'none'; script-src 'self' challenges.cloudflare.com; media-src 'self' https:; img-src 'self' https: data:; frame-src challenges.cloudflare.com www.youtube-nocookie.com platform.twitter.com rumble.com; connect-src 'self' tls-use1.fpapi.io api.fpjs.io;";
|
||||
add_header Cross-Origin-Opener-Policy "same-origin";
|
||||
|
|
|
@ -1133,6 +1133,15 @@ CREATE TABLE public.votes (
|
|||
coins smallint DEFAULT 1 NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Name: orgies, Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
CREATE TABLE public.orgies (
|
||||
id integer NOT NULL,
|
||||
type integer NOT NULL,
|
||||
data character varying(200) NOT NULL,
|
||||
title character varying(1000) NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Name: award_relationships id; Type: DEFAULT; Schema: public; Owner: -
|
||||
|
|
Loading…
Reference in New Issue