WebHost: Add youtube livestreaming and autogenerated multistream link

This commit is contained in:
Fabian Dill
2020-07-25 22:40:24 +02:00
parent aacd5b4063
commit 5cd5223ae0
5 changed files with 35 additions and 7 deletions

View File

@@ -2,7 +2,6 @@
So unless you're Berserker you need to include license information."""
import os
import threading
from pony.flask import Pony
from flask import Flask, request, redirect, url_for, render_template, Response, session, abort
@@ -24,6 +23,9 @@ def allowed_file(filename):
app = Flask(__name__)
Pony(app)
app.jinja_env.filters['any'] = any
app.jinja_env.filters['all'] = all
app.config["SELFHOST"] = True
app.config["SELFLAUNCH"] = True
app.config["DEBUG"] = False

View File

@@ -26,6 +26,11 @@ class CustomClientMessageProcessor(ClientMessageProcessor):
self.ctx.save()
self.output(f"Registered Twitch Stream https://www.twitch.tv/{user}")
return True
elif platform.lower().startswith("y"): # youtube
self.ctx.video[self.client.team, self.client.slot] = "Youtube", user
self.ctx.save()
self.output(f"Registered Youtube Stream for {user}")
return True
return False

View File

@@ -8,8 +8,16 @@
{% endblock %}
{% block body %}
<div id="tracker-wrapper" data-tracker="{{ room.tracker }}">
<input placeholder="Search" id="search" />
<div id="tracker-header-bar">
<input placeholder="Search" id="search" />
{% if video %}<span><a target="_blank" href="https://multistream.me/
{%- for teamslot, (platform, link) in video.items()-%}
{%- if platform == "Twitch" -%}t{%- else -%}yt{%- endif -%}:{{ link }}/">Multistream</a></span>
{% endfor %}
{% endif %}
</div>
{% for team, players in inventory.items() %}
<div class="table-wrapper">
<table class="table unique-item-table">
@@ -33,10 +41,17 @@
<tr>
<td>{{ loop.index }}</td>
{% if (team, loop.index) in video %}
{% if video[(team, loop.index)][0] == "Twitch" %}
<td>
<a target="_blank" href="https://www.twitch.tv/{{ video[(team, loop.index)][1] }}">
{{ player_names[(team, loop.index)] }}
▶️</a></td>
{% elif video[(team, loop.index)][0] == "Youtube" %}
<td>
<a target="_blank" href="youtube.com/c/{{ video[(team, loop.index)][1] }}/live">
{{ player_names[(team, loop.index)] }}
▶️</a></td>
{% endif %}
{% else %}
<td>{{ player_names[(team, loop.index)] }}</td>
{% endif %}