commit
4c01a1d83f
@ -1,4 +1,4 @@
|
|||||||
blank_issues_enabled: true
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: Ask a question
|
- name: Ask a question
|
||||||
about: Join our discord server to ask questions and discuss with maintainers and contributors.
|
about: Join our discord server to ask questions and discuss with maintainers and contributors.
|
||||||
|
@ -1,32 +1,118 @@
|
|||||||
# Import the server module
|
|
||||||
import http.server
|
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Used "tomlkit" instead of "toml" because it doesn't change formatting on "dump"
|
||||||
|
import tomlkit
|
||||||
|
from flask import (
|
||||||
|
Flask,
|
||||||
|
redirect,
|
||||||
|
render_template,
|
||||||
|
request,
|
||||||
|
send_from_directory,
|
||||||
|
url_for,
|
||||||
|
)
|
||||||
|
|
||||||
|
import utils.gui_utils as gui
|
||||||
|
|
||||||
# Set the hostname
|
# Set the hostname
|
||||||
HOST = "localhost"
|
HOST = "localhost"
|
||||||
# Set the port number
|
# Set the port number
|
||||||
PORT = 4000
|
PORT = 4000
|
||||||
|
|
||||||
# Define class to display the index page of the web server
|
# Configure application
|
||||||
class PythonServer(http.server.SimpleHTTPRequestHandler):
|
app = Flask(__name__, template_folder="GUI")
|
||||||
def do_GET(self):
|
|
||||||
if self.path == "/GUI":
|
# Configure secret key only to use 'flash'
|
||||||
self.path = "index.html"
|
app.secret_key = b'_5#y2L"F4Q8z\n\xec]/'
|
||||||
return http.server.SimpleHTTPRequestHandler.do_GET(self)
|
|
||||||
|
|
||||||
|
# Ensure responses aren't cached
|
||||||
# Declare object of the class
|
@app.after_request
|
||||||
webServer = http.server.HTTPServer((HOST, PORT), PythonServer)
|
def after_request(response):
|
||||||
# Print the URL of the webserver, new =2 opens in a new tab
|
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
|
||||||
print(f"Server started at http://{HOST}:{PORT}/GUI/")
|
response.headers["Expires"] = 0
|
||||||
webbrowser.open(f"http://{HOST}:{PORT}/GUI/", new=2)
|
response.headers["Pragma"] = "no-cache"
|
||||||
print("Website opened in new tab")
|
return response
|
||||||
print("Press Ctrl+C to quit")
|
|
||||||
try:
|
|
||||||
# Run the web server
|
# Display index.html
|
||||||
webServer.serve_forever()
|
@app.route("/")
|
||||||
except KeyboardInterrupt:
|
def index():
|
||||||
# Stop the web server
|
return render_template("index.html", file="videos.json")
|
||||||
webServer.server_close()
|
|
||||||
print("The server is stopped.")
|
|
||||||
exit()
|
@app.route("/backgrounds", methods=["GET"])
|
||||||
|
def backgrounds():
|
||||||
|
return render_template("backgrounds.html", file="backgrounds.json")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/background/add", methods=["POST"])
|
||||||
|
def background_add():
|
||||||
|
# Get form values
|
||||||
|
youtube_uri = request.form.get("youtube_uri").strip()
|
||||||
|
filename = request.form.get("filename").strip()
|
||||||
|
citation = request.form.get("citation").strip()
|
||||||
|
position = request.form.get("position").strip()
|
||||||
|
|
||||||
|
gui.add_background(youtube_uri, filename, citation, position)
|
||||||
|
|
||||||
|
return redirect(url_for("backgrounds"))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/background/delete", methods=["POST"])
|
||||||
|
def background_delete():
|
||||||
|
key = request.form.get("background-key")
|
||||||
|
gui.delete_background(key)
|
||||||
|
|
||||||
|
return redirect(url_for("backgrounds"))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/settings", methods=["GET", "POST"])
|
||||||
|
def settings():
|
||||||
|
config_load = tomlkit.loads(Path("config.toml").read_text())
|
||||||
|
config = gui.get_config(config_load)
|
||||||
|
|
||||||
|
# Get checks for all values
|
||||||
|
checks = gui.get_checks()
|
||||||
|
|
||||||
|
if request.method == "POST":
|
||||||
|
# Get data from form as dict
|
||||||
|
data = request.form.to_dict()
|
||||||
|
|
||||||
|
# Change settings
|
||||||
|
config = gui.modify_settings(data, config_load, checks)
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"settings.html", file="config.toml", data=config, checks=checks
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Make videos.json accessible
|
||||||
|
@app.route("/videos.json")
|
||||||
|
def videos_json():
|
||||||
|
return send_from_directory("video_creation/data", "videos.json")
|
||||||
|
|
||||||
|
|
||||||
|
# Make backgrounds.json accessible
|
||||||
|
@app.route("/backgrounds.json")
|
||||||
|
def backgrounds_json():
|
||||||
|
return send_from_directory("utils", "backgrounds.json")
|
||||||
|
|
||||||
|
|
||||||
|
# Make videos in results folder accessible
|
||||||
|
@app.route("/results/<path:name>")
|
||||||
|
def results(name):
|
||||||
|
return send_from_directory("results", name, as_attachment=True)
|
||||||
|
|
||||||
|
|
||||||
|
# Make voices samples in voices folder accessible
|
||||||
|
@app.route("/voices/<path:name>")
|
||||||
|
def voices(name):
|
||||||
|
return send_from_directory("GUI/voices", name, as_attachment=True)
|
||||||
|
|
||||||
|
|
||||||
|
# Run browser and start the app
|
||||||
|
if __name__ == "__main__":
|
||||||
|
webbrowser.open(f"http://{HOST}:{PORT}", new=2)
|
||||||
|
print("Website opened in new tab. Refresh if it didn't load.")
|
||||||
|
app.run(port=PORT)
|
||||||
|
@ -0,0 +1,263 @@
|
|||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<!-- Delete Background Modal -->
|
||||||
|
<div class="modal fade" id="deleteBtnModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Delete background</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Are you sure you want to delete this background?
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<form action="background/delete" method="post">
|
||||||
|
<input type="hidden" id="background-key" name="background-key" value="">
|
||||||
|
<button type="submit" class="btn btn-danger">Delete</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Add Background Modal -->
|
||||||
|
<div class="modal fade" id="backgroundAddModal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Add background video</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<!-- Add video form -->
|
||||||
|
<form id="addBgForm" action="background/add" method="post" novalidate>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-4 col-form-label" for="youtube_uri">YouTube URI</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-youtube"></i>
|
||||||
|
</div>
|
||||||
|
<input name="youtube_uri" placeholder="https://www.youtube.com/watch?v=..." type="text"
|
||||||
|
class="form-control">
|
||||||
|
</div>
|
||||||
|
<span id="feedbackYT" class="form-text feedback-invalid"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="filename" class="col-4 col-form-label">Filename</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-file-earmark"></i>
|
||||||
|
</div>
|
||||||
|
<input name="filename" placeholder="Example: cool-background" type="text"
|
||||||
|
class="form-control">
|
||||||
|
</div>
|
||||||
|
<span id="feedbackFilename" class="form-text feedback-invalid"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="citation" class="col-4 col-form-label">Credits (owner of the video)</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-person-circle"></i>
|
||||||
|
</div>
|
||||||
|
<input name="citation" placeholder="YouTube Channel" type="text" class="form-control">
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted">Include the channel name of the
|
||||||
|
owner of the background video you are adding.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="position" class="col-4 col-form-label">Position of screenshots</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-arrows-fullscreen"></i>
|
||||||
|
</div>
|
||||||
|
<input name="position" placeholder="Example: center" type="text" class="form-control">
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted">Advanced option (you can leave it
|
||||||
|
empty). Valid options are "center" and decimal numbers</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<button name="submit" type="submit" class="btn btn-success">Add background</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<div class="album py-2 bg-light">
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<div class="row justify-content-between mt-2">
|
||||||
|
<div class="col-12 col-md-3 mb-3">
|
||||||
|
<input type="text" class="form-control searchFilter" placeholder="Search backgrounds"
|
||||||
|
onkeyup="searchFilter()">
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-md-2 mb-3">
|
||||||
|
<button type="button" class="btn btn-primary form-control" data-toggle="modal"
|
||||||
|
data-target="#backgroundAddModal">
|
||||||
|
Add background video
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3" id="backgrounds">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var keys = [];
|
||||||
|
var youtube_urls = [];
|
||||||
|
|
||||||
|
// Show background videos
|
||||||
|
$(document).ready(function () {
|
||||||
|
$.getJSON("backgrounds.json",
|
||||||
|
function (data) {
|
||||||
|
delete data["__comment"];
|
||||||
|
var background = '';
|
||||||
|
$.each(data, function (key, value) {
|
||||||
|
// Add YT urls and keys (for validation)
|
||||||
|
keys.push(key);
|
||||||
|
youtube_urls.push(value[0]);
|
||||||
|
|
||||||
|
background += '<div class="col">';
|
||||||
|
background += '<div class="card shadow-sm">';
|
||||||
|
background += '<iframe class="bd-placeholder-img card-img-top" width="100%" height="225" src="https://www.youtube-nocookie.com/embed/' + value[0].split("?v=")[1] + '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
|
||||||
|
background += '<div class="card-body">';
|
||||||
|
background += '<p class="card-text">' + value[2] + ' • ' + key + '</p>';
|
||||||
|
background += '<div class="d-flex justify-content-between align-items-center">';
|
||||||
|
background += '<div class="btn-group">';
|
||||||
|
background += '<button type="button" class="btn btn-outline-danger" data-toggle="modal" data-target="#deleteBtnModal" data-background-key="' + key + '">Delete</button>';
|
||||||
|
background += '</div>';
|
||||||
|
background += '</div>';
|
||||||
|
background += '</div>';
|
||||||
|
background += '</div>';
|
||||||
|
background += '</div>';
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#backgrounds').append(background);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add background key when deleting
|
||||||
|
$('#deleteBtnModal').on('show.bs.modal', function (event) {
|
||||||
|
var button = $(event.relatedTarget);
|
||||||
|
var key = button.data('background-key');
|
||||||
|
|
||||||
|
$('#background-key').prop('value', key);
|
||||||
|
});
|
||||||
|
|
||||||
|
var searchFilter = () => {
|
||||||
|
const input = document.querySelector(".searchFilter");
|
||||||
|
const cards = document.getElementsByClassName("col");
|
||||||
|
console.log(cards[1])
|
||||||
|
let filter = input.value
|
||||||
|
for (let i = 0; i < cards.length; i++) {
|
||||||
|
let title = cards[i].querySelector(".card-text");
|
||||||
|
if (title.innerText.toLowerCase().indexOf(filter.toLowerCase()) > -1) {
|
||||||
|
cards[i].classList.remove("d-none")
|
||||||
|
} else {
|
||||||
|
cards[i].classList.add("d-none")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate form
|
||||||
|
$("#addBgForm").submit(function (event) {
|
||||||
|
$("#addBgForm input").each(function () {
|
||||||
|
if (!(validate($(this)))) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#addBgForm input[type="text"]').on("keyup", function () {
|
||||||
|
validate($(this));
|
||||||
|
});
|
||||||
|
|
||||||
|
function validate(object) {
|
||||||
|
let bool = check(object.prop("name"), object.prop("value"));
|
||||||
|
|
||||||
|
// Change class
|
||||||
|
if (bool) {
|
||||||
|
object.removeClass("is-invalid");
|
||||||
|
object.addClass("is-valid");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
object.removeClass("is-valid");
|
||||||
|
object.addClass("is-invalid");
|
||||||
|
}
|
||||||
|
|
||||||
|
return bool;
|
||||||
|
|
||||||
|
// Check values (return true/false)
|
||||||
|
function check(name, value) {
|
||||||
|
if (name == "youtube_uri") {
|
||||||
|
// URI validation
|
||||||
|
let regex = /(?:\/|%3D|v=|vi=)([0-9A-z-_]{11})(?:[%#?&]|$)/;
|
||||||
|
if (!(regex.test(value))) {
|
||||||
|
$("#feedbackYT").html("Invalid URI");
|
||||||
|
$("#feedbackYT").show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if this background already exists
|
||||||
|
if (youtube_urls.includes(value)) {
|
||||||
|
$("#feedbackYT").html("This background is already added");
|
||||||
|
$("#feedbackYT").show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#feedbackYT").hide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == "filename") {
|
||||||
|
// Check if key is already taken
|
||||||
|
if (keys.includes(value)) {
|
||||||
|
$("#feedbackFilename").html("This filename is already taken");
|
||||||
|
$("#feedbackFilename").show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let regex = /^([a-zA-Z0-9\s_-]{1,100})$/;
|
||||||
|
if (!(regex.test(value))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == "citation") {
|
||||||
|
if (value.trim()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == "position") {
|
||||||
|
if (!(value == "center" || value.length == 0 || value % 1 == 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -0,0 +1,142 @@
|
|||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta http-equiv="cache-control" content="no-cache" />
|
||||||
|
<title>RedditVideoMakerBot</title>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css"
|
||||||
|
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||||
|
<link href="https://getbootstrap.com/docs/5.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.bd-placeholder-img {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
text-anchor: middle;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feedback-invalid {
|
||||||
|
color: #dc3545;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.bd-placeholder-img-lg {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bi {
|
||||||
|
vertical-align: -.125em;
|
||||||
|
fill: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
margin-top: -1px;
|
||||||
|
overflow-x: auto;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tooltip {
|
||||||
|
background-color: #333;
|
||||||
|
color: white;
|
||||||
|
padding: 5px 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip-inner {
|
||||||
|
max-width: 500px !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.3/dist/umd/popper.min.js"
|
||||||
|
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/js/bootstrap.min.js"
|
||||||
|
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.10/clipboard.min.js"></script>
|
||||||
|
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.js"></script>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
{% if get_flashed_messages() %}
|
||||||
|
{% for category, message in get_flashed_messages(with_categories=true) %}
|
||||||
|
|
||||||
|
{% if category == "error" %}
|
||||||
|
<div class="alert alert-danger mb-0 text-center" role="alert">
|
||||||
|
{{ message }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
<div class="alert alert-success mb-0 text-center" role="alert">
|
||||||
|
{{ message }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
|
<div class="container">
|
||||||
|
<a href="/" class="navbar-brand d-flex align-items-center">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" stroke="currentColor"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" class="me-2"
|
||||||
|
viewBox="0 0 24 24">
|
||||||
|
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" />
|
||||||
|
<circle cx="12" cy="13" r="4" />
|
||||||
|
</svg>
|
||||||
|
<strong>RedditVideoMakerBot</strong>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse">
|
||||||
|
<ul class="navbar-nav mr-auto">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="backgrounds">Background Manager</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="settings">Settings</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!-- Future feature
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item">
|
||||||
|
<button class="btn btn-outline-success mr-auto mt-2 mt-lg-0">Create new short</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{% block main %}{% endblock %}
|
||||||
|
|
||||||
|
<footer class="text-muted py-5">
|
||||||
|
<div class="container">
|
||||||
|
<p class="float-end mb-1">
|
||||||
|
<a href="#">Back to top</a>
|
||||||
|
</p>
|
||||||
|
<p class="mb-1"><a href="https://getbootstrap.com/docs/5.2/examples/album/" target="_blank">Album</a>
|
||||||
|
Example
|
||||||
|
Theme by © Bootstrap. <a
|
||||||
|
href="https://github.com/elebumm/RedditVideoMakerBot/blob/master/README.md#developers-and-maintainers"
|
||||||
|
target="_blank">Developers and Maintainers</a></p>
|
||||||
|
<p class="mb-0">If your data is not refreshing, try to hard reload(Ctrl + F5) and visit your local
|
||||||
|
<strong>{{ file }}</strong> file.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -0,0 +1,621 @@
|
|||||||
|
{% extends "layout.html" %}
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<br>
|
||||||
|
<div class="container">
|
||||||
|
<form id="settingsForm" action="/settings" method="post" novalidate>
|
||||||
|
|
||||||
|
<!-- Reddit Credentials -->
|
||||||
|
<p class="h4">Reddit Credentials</p>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="client_id" class="col-4">Client ID</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-person"></i>
|
||||||
|
</div>
|
||||||
|
<input name="client_id" value="{{ data.client_id }}" placeholder="Your Reddit app's client ID"
|
||||||
|
type="text" class="form-control" data-toggle="tooltip"
|
||||||
|
data-original-title='Text under "personal use script" on www.reddit.com/prefs/apps'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="client_secret" class="col-4">Client Secret</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-key-fill"></i>
|
||||||
|
</div>
|
||||||
|
<input name="client_secret" value="{{ data.client_secret }}"
|
||||||
|
placeholder="Your Reddit app's client secret" type="text" class="form-control"
|
||||||
|
data-toggle="tooltip" data-original-title='"Secret" on www.reddit.com/prefs/apps'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="username" class="col-4">Reddit Username</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-person-fill"></i>
|
||||||
|
</div>
|
||||||
|
<input name="username" value="{{ data.username }}" placeholder="Your Reddit account's username"
|
||||||
|
type="text" class="form-control">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="password" class="col-4">Reddit Password</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-lock-fill"></i>
|
||||||
|
</div>
|
||||||
|
<input name="password" value="{{ data.password }}" placeholder="Your Reddit account's password"
|
||||||
|
type="password" class="form-control">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label class="col-4">Do you have Reddit 2FA enabled?</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input name="2fa" class="form-check-input" type="checkbox" value="True" data-toggle="tooltip"
|
||||||
|
data-original-title='Check it if you have enabled 2FA on your Reddit account'>
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted"><a
|
||||||
|
href="https://reddit-video-maker-bot.netlify.app/docs/configuring#setting-up-the-api"
|
||||||
|
target="_blank">Need help? Click here to open step-by-step guide.</a></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Reddit Thread -->
|
||||||
|
<p class="h4">Reddit Thread</p>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label class="col-4">Random Thread</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input name="random" class="form-check-input" type="checkbox" value="True" data-toggle="tooltip"
|
||||||
|
data-original-title='If disabled, it will ask you for a thread link, instead of picking random one'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="subreddit" class="col-4">Subreddit</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-reddit"></i>
|
||||||
|
</div>
|
||||||
|
<input value="{{ data.subreddit }}" name="subreddit" type="text" class="form-control"
|
||||||
|
placeholder="Subreddit to pull posts from (e.g. AskReddit)" data-toggle="tooltip"
|
||||||
|
data-original-title='You can have multiple subreddits,
|
||||||
|
add "+" between them (e.g. AskReddit+Redditdev)'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="post_id" class="col-4">Post ID</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-file-text"></i>
|
||||||
|
</div>
|
||||||
|
<input value="{{ data.post_id }}" name="post_id" type="text" class="form-control"
|
||||||
|
placeholder="Used if you want to use a specific post (e.g. urdtfx)">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="max_comment_length" class="col-4">Max Comment Length</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input name="max_comment_length" type="range" class="form-range" min="10" max="10000" step="1"
|
||||||
|
value="{{ data.max_comment_length }}" data-toggle="tooltip"
|
||||||
|
data-original-title="{{ data.max_comment_length }}">
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted">Max number of characters a comment can have.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="post_lang" class="col-4">Post Language</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-translate"></i>
|
||||||
|
</div>
|
||||||
|
<input value="{{ data.post_lang }}" name="post_lang" type="text" class="form-control"
|
||||||
|
placeholder="The language you would like to translate to">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="min_comments" class="col-4">Minimum Comments</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input name="min_comments" type="range" class="form-range" min="15" max="1000" step="1"
|
||||||
|
value="{{ data.min_comments }}" data-toggle="tooltip"
|
||||||
|
data-original-title="{{ data.min_comments }}">
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted">The minimum number of comments a post should have to be
|
||||||
|
included.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- General Settings -->
|
||||||
|
<p class="h4">General Settings</p>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label class="col-4">Allow NSFW</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input name="allow_nsfw" class="form-check-input" type="checkbox" value="True"
|
||||||
|
data-toggle="tooltip" data-original-title='If checked NSFW posts will be allowed'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="theme" class="col-4">Reddit Theme</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<select name="theme" class="form-select" data-toggle="tooltip"
|
||||||
|
data-original-title='Sets the theme of Reddit screenshots'>
|
||||||
|
<option value="dark">Dark</option>
|
||||||
|
<option value="light">Light</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="times_to_run" class="col-4">Times To Run</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input name="times_to_run" type="range" class="form-range" min="1" max="1000" step="1"
|
||||||
|
value="{{ data.times_to_run }}" data-toggle="tooltip"
|
||||||
|
data-original-title="{{ data.times_to_run }}">
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted">Used if you want to create multiple videos.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="opacity" class="col-4">Opacity Of Comments</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input name="opacity" type="range" class="form-range" min="0" max="1" step="0.05"
|
||||||
|
value="{{ data.opacity }}" data-toggle="tooltip" data-original-title="{{ data.opacity }}">
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted">Sets the opacity of the comments when overlayed over the
|
||||||
|
background.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="transition" class="col-4">Transition</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input name="transition" type="range" class="form-range" min="0" max="2" step="0.05"
|
||||||
|
value="{{ data.transition }}" data-toggle="tooltip"
|
||||||
|
data-original-title="{{ data.transition }}">
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted">Sets the transition time (in seconds) between the
|
||||||
|
comments. Set to 0 if you want to disable it.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="background_choice" class="col-4">Background Choice</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<select name="background_choice" class="form-select" data-toggle="tooltip"
|
||||||
|
data-original-title='Sets the background of the video'>
|
||||||
|
<option value=" ">Random Video</option>
|
||||||
|
{% for background in checks["background_choice"]["options"][1:] %}
|
||||||
|
<option value="{{background}}">{{background}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<span class="form-text text-muted"><a href="/backgrounds" target="_blank">See all available
|
||||||
|
backgrounds</a></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="background_thumbnail" class="col-4">Background Thumbnail</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input name="background_thumbnail" class="form-check-input" type="checkbox" value="True"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
data-original-title='If checked a thumbnail will be added to the video (put a thumbnail.png file in the assets/backgrounds directory for it to be used.)'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="background_thumbnail_font_family" class="col-4">Background Thumbnail Font Family (.ttf)</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<input name="background_thumbnail_font_family" type="text" class="form-control"
|
||||||
|
placeholder="arial" value="{{ data.background_thumbnail_font_family }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="background_thumbnail_font_size" class="col-4">Background Thumbnail Font Size (px)</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<input name="background_thumbnail_font_size" type="number" class="form-control"
|
||||||
|
placeholder="96" value="{{ data.background_thumbnail_font_size }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- need to create a color picker -->
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="background_thumbnail_font_color" class="col-4">Background Thumbnail Font Color (rgb)</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<input name="background_thumbnail_font_color" type="text" class="form-control"
|
||||||
|
placeholder="255,255,255" value="{{ data.background_thumbnail_font_color }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- TTS Settings -->
|
||||||
|
<p class="h4">TTS Settings</p>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="voice_choice" class="col-4">TTS Voice Choice</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<select name="voice_choice" class="form-select" data-toggle="tooltip"
|
||||||
|
data-original-title='The voice platform used for TTS generation'>
|
||||||
|
<option value="streamlabspolly">Streamlabspolly</option>
|
||||||
|
<option value="tiktok">TikTok</option>
|
||||||
|
<option value="googletranslate">Google Translate</option>
|
||||||
|
<option value="awspolly">AWS Polly</option>
|
||||||
|
<option value="pyttsx">Python TTS (pyttsx)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="aws_polly_voice" class="col-4">AWS Polly Voice</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group voices">
|
||||||
|
<select name="aws_polly_voice" class="form-select" data-toggle="tooltip"
|
||||||
|
data-original-title='The voice used for AWS Polly'>
|
||||||
|
<option value="Brian">Brian</option>
|
||||||
|
<option value="Emma">Emma</option>
|
||||||
|
<option value="Russell">Russell</option>
|
||||||
|
<option value="Joey">Joey</option>
|
||||||
|
<option value="Matthew">Matthew</option>
|
||||||
|
<option value="Joanna">Joanna</option>
|
||||||
|
<option value="Kimberly">Kimberly</option>
|
||||||
|
<option value="Amy">Amy</option>
|
||||||
|
<option value="Geraint">Geraint</option>
|
||||||
|
<option value="Nicole">Nicole</option>
|
||||||
|
<option value="Justin">Justin</option>
|
||||||
|
<option value="Ivy">Ivy</option>
|
||||||
|
<option value="Kendra">Kendra</option>
|
||||||
|
<option value="Salli">Salli</option>
|
||||||
|
<option value="Raveena">Raveena</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-primary"><i id="awspolly_icon"
|
||||||
|
class="bi-volume-up-fill"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="streamlabs_polly_voice" class="col-4">Streamlabs Polly Voice</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group voices">
|
||||||
|
<select id="streamlabs_polly_voice" name="streamlabs_polly_voice" class="form-select"
|
||||||
|
data-toggle="tooltip" data-original-title='The voice used for Streamlabs Polly'>
|
||||||
|
<option value="Brian">Brian</option>
|
||||||
|
<option value="Emma">Emma</option>
|
||||||
|
<option value="Russell">Russell</option>
|
||||||
|
<option value="Joey">Joey</option>
|
||||||
|
<option value="Matthew">Matthew</option>
|
||||||
|
<option value="Joanna">Joanna</option>
|
||||||
|
<option value="Kimberly">Kimberly</option>
|
||||||
|
<option value="Amy">Amy</option>
|
||||||
|
<option value="Geraint">Geraint</option>
|
||||||
|
<option value="Nicole">Nicole</option>
|
||||||
|
<option value="Justin">Justin</option>
|
||||||
|
<option value="Ivy">Ivy</option>
|
||||||
|
<option value="Kendra">Kendra</option>
|
||||||
|
<option value="Salli">Salli</option>
|
||||||
|
<option value="Raveena">Raveena</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-primary"><i id="streamlabs_icon"
|
||||||
|
class="bi bi-volume-up-fill"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="tiktok_voice" class="col-4">TikTok Voice</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group voices">
|
||||||
|
<select name="tiktok_voice" class="form-select" data-toggle="tooltip"
|
||||||
|
data-original-title='The voice used for TikTok TTS'>
|
||||||
|
<option disabled value="">-----Disney Voices-----</option>
|
||||||
|
<option value="en_us_ghostface">Ghost Face</option>
|
||||||
|
<option value="en_us_chewbacca">Chewbacca</option>
|
||||||
|
<option value="en_us_c3po">C3PO</option>
|
||||||
|
<option value="en_us_stitch">Stitch</option>
|
||||||
|
<option value="en_us_stormtrooper">Stormtrooper</option>
|
||||||
|
<option value="en_us_rocket">Rocket</option>
|
||||||
|
<option disabled value="">-----English Voices-----</option>
|
||||||
|
<option value="en_au_001">English AU - Female</option>
|
||||||
|
<option value="en_au_002">English AU - Male</option>
|
||||||
|
<option value="en_uk_001">English UK - Male 1</option>
|
||||||
|
<option value="en_uk_003">English UK - Male 2</option>
|
||||||
|
<option value="en_us_001">English US - Female (Int. 1)</option>
|
||||||
|
<option value="en_us_002">English US - Female (Int. 2)</option>
|
||||||
|
<option value="en_us_006">English US - Male 1</option>
|
||||||
|
<option value="en_us_007">English US - Male 2</option>
|
||||||
|
<option value="en_us_009">English US - Male 3</option>
|
||||||
|
<option value="en_us_010">English US - Male 4</option>
|
||||||
|
<option disabled value="">-----European Voices-----</option>
|
||||||
|
<option value="fr_001">French - Male 1</option>
|
||||||
|
<option value="fr_002">French - Male 2</option>
|
||||||
|
<option value="de_001">German - Female</option>
|
||||||
|
<option value="de_002">German - Male</option>
|
||||||
|
<option value="es_002">Spanish - Male</option>
|
||||||
|
<option disabled value="">-----American Voices-----</option>
|
||||||
|
<option value="es_mx_002">Spanish MX - Male</option>
|
||||||
|
<option value="br_001">Portuguese BR - Female 1</option>
|
||||||
|
<option value="br_003">Portuguese BR - Female 2</option>
|
||||||
|
<option value="br_004">Portuguese BR - Female 3</option>
|
||||||
|
<option value="br_005">Portuguese BR - Male</option>
|
||||||
|
<option disabled value="">-----Asian Voices-----</option>
|
||||||
|
<option value="id_001">Indonesian - Female</option>
|
||||||
|
<option value="jp_001">Japanese - Female 1</option>
|
||||||
|
<option value="jp_003">Japanese - Female 2</option>
|
||||||
|
<option value="jp_005">Japanese - Female 3</option>
|
||||||
|
<option value="jp_006">Japanese - Male</option>
|
||||||
|
<option value="kr_002">Korean - Male 1</option>
|
||||||
|
<option value="kr_003">Korean - Female</option>
|
||||||
|
<option value="kr_004">Korean - Male 2</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-primary"><i id="tiktok_icon"
|
||||||
|
class="bi-volume-up-fill"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="tiktok_sessionid" class="col-4">TikTok SessionId</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-mic-fill"></i>
|
||||||
|
</div>
|
||||||
|
<input value="{{ data.tiktok_sessionid }}" name="tiktok_sessionid" type="text" class="form-control"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
data-original-title="TikTok sessionid needed for the TTS API request. Check documentation if you don't know how to obtain it.">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="python_voice" class="col-4">Python Voice</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-mic-fill"></i>
|
||||||
|
</div>
|
||||||
|
<input value="{{ data.python_voice }}" name="python_voice" type="text" class="form-control"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
data-original-title='The index of the system TTS voices (can be downloaded externally, run ptt.py to find value, start from zero)'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="py_voice_num" class="col-4">Py Voice Number</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<i class="bi bi-headset"></i>
|
||||||
|
</div>
|
||||||
|
<input value="{{ data.py_voice_num }}" name="py_voice_num" type="text" class="form-control"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
data-original-title='The number of system voices (2 are pre-installed in Windows)'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<label for="silence_duration" class="col-4">Silence Duration</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input name="silence_duration" type="range" class="form-range" min="0" max="5" step="0.05"
|
||||||
|
value="{{ data.silence_duration }}" data-toggle="tooltip"
|
||||||
|
data-original-title="{{ data.silence_duration }}">
|
||||||
|
</div>
|
||||||
|
<span class="form-text text-muted">Time in seconds between TTS comments.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col text-center">
|
||||||
|
<br>
|
||||||
|
<button id="defaultSettingsBtn" type="button" class="btn btn-secondary">Default
|
||||||
|
Settings</button>
|
||||||
|
<button id="submitButton" type="submit" class="btn btn-success">Save
|
||||||
|
Changes</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<audio src=""></audio>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Test voices buttons
|
||||||
|
var playing = false;
|
||||||
|
|
||||||
|
$(".voices button").click(function () {
|
||||||
|
var icon = $(this).find("i");
|
||||||
|
var audio = $("audio");
|
||||||
|
|
||||||
|
if (playing) {
|
||||||
|
playing.toggleClass("bi-volume-up-fill bi-stop-fill");
|
||||||
|
|
||||||
|
// Clicked the same button - stop audio
|
||||||
|
if (playing.prop("id") == icon.prop("id")) {
|
||||||
|
audio[0].pause();
|
||||||
|
playing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
icon.toggleClass("bi-volume-up-fill bi-stop-fill");
|
||||||
|
let path = "voices/" + $(this).closest(".voices").find("select").prop("value").toLowerCase() + ".mp3";
|
||||||
|
|
||||||
|
audio.prop("src", path);
|
||||||
|
audio[0].play();
|
||||||
|
playing = icon;
|
||||||
|
|
||||||
|
audio[0].onended = function () {
|
||||||
|
icon.toggleClass("bi-volume-up-fill bi-stop-fill");
|
||||||
|
playing = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Wait for DOM to load
|
||||||
|
$(document).ready(function () {
|
||||||
|
// Add tooltips
|
||||||
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
$('[data-toggle="tooltip"]').on('click', function () {
|
||||||
|
$(this).tooltip('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update slider tooltip
|
||||||
|
$(".form-range").on("input", function () {
|
||||||
|
$(this).attr("value", $(this).val());
|
||||||
|
$(this).attr("data-original-title", $(this).val());
|
||||||
|
$(this).tooltip("show");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get current config
|
||||||
|
var data = JSON.parse('{{data | tojson}}');
|
||||||
|
|
||||||
|
// Set current checkboxes
|
||||||
|
$('.form-check-input').each(function () {
|
||||||
|
$(this).prop("checked", data[$(this).prop("name")]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set current select options
|
||||||
|
$('.form-select').each(function () {
|
||||||
|
$(this).prop("value", data[$(this).prop("name")]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Submit "False" when checkbox isn't ticked
|
||||||
|
$('#settingsForm').submit(function () {
|
||||||
|
$('.form-check-input').each(function () {
|
||||||
|
if (!($(this).is(':checked'))) {
|
||||||
|
$(this).prop("value", "False");
|
||||||
|
$(this).prop("checked", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Get validation values
|
||||||
|
let validateChecks = JSON.parse('{{checks | tojson}}');
|
||||||
|
|
||||||
|
// Set default values
|
||||||
|
$("#defaultSettingsBtn").click(function (event) {
|
||||||
|
$("#settingsForm input, #settingsForm select").each(function () {
|
||||||
|
let check = validateChecks[$(this).prop("name")];
|
||||||
|
|
||||||
|
if (check["default"]) {
|
||||||
|
$(this).prop("value", check["default"]);
|
||||||
|
|
||||||
|
// Update tooltip value for input[type="range"]
|
||||||
|
if ($(this).prop("type") == "range") {
|
||||||
|
$(this).attr("data-original-title", check["default"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Validate form
|
||||||
|
$('#settingsForm').submit(function (event) {
|
||||||
|
$("#settingsForm input, #settingsForm select").each(function () {
|
||||||
|
if (!(validate($(this)))) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
$("html, body").animate({
|
||||||
|
scrollTop: $(this).offset().top
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#settingsForm input").on("keyup", function () {
|
||||||
|
validate($(this));
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#settingsForm select").on("change", function () {
|
||||||
|
validate($(this));
|
||||||
|
});
|
||||||
|
|
||||||
|
function validate(object) {
|
||||||
|
let bool = check(object.prop("name"), object.prop("value"));
|
||||||
|
|
||||||
|
// Change class
|
||||||
|
if (bool) {
|
||||||
|
object.removeClass("is-invalid");
|
||||||
|
object.addClass("is-valid");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
object.removeClass("is-valid");
|
||||||
|
object.addClass("is-invalid");
|
||||||
|
}
|
||||||
|
|
||||||
|
return bool;
|
||||||
|
|
||||||
|
// Check values (return true/false)
|
||||||
|
function check(name, value) {
|
||||||
|
let check = validateChecks[name];
|
||||||
|
|
||||||
|
// If value is empty - check if it's optional
|
||||||
|
if (value.length == 0) {
|
||||||
|
if (check["optional"] == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
object.prop("value", check["default"]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if value is too short
|
||||||
|
if (check["nmin"]) {
|
||||||
|
if (check["type"] == "int" || check["type"] == "float") {
|
||||||
|
if (value < check["nmin"]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (value.length < check["nmin"]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if value is too long
|
||||||
|
if (check["nmax"]) {
|
||||||
|
if (check["type"] == "int" || check["type"] == "float") {
|
||||||
|
if (value > check["nmax"]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (value.length > check["nmax"]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if value matches regex
|
||||||
|
if (check["regex"]) {
|
||||||
|
let regex = new RegExp(check["regex"]);
|
||||||
|
if (!(regex.test(value))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endblock %}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,45 +0,0 @@
|
|||||||
# Supported Background. Can add/remove background video here....
|
|
||||||
# <key>-<value> : key -> used as keyword for TOML file. value -> background configuration
|
|
||||||
# Format (value):
|
|
||||||
# 1. Youtube URI
|
|
||||||
# 2. filename
|
|
||||||
# 3. Citation (owner of the video)
|
|
||||||
# 4. Position of image clips in the background. See moviepy reference for more information. (https://zulko.github.io/moviepy/ref/VideoClip/VideoClip.html#moviepy.video.VideoClip.VideoClip.set_position)
|
|
||||||
background_options = {
|
|
||||||
"motor-gta": ( # Motor-GTA Racing
|
|
||||||
"https://www.youtube.com/watch?v=vw5L4xCPy9Q",
|
|
||||||
"bike-parkour-gta.mp4",
|
|
||||||
"Achy Gaming",
|
|
||||||
lambda t: ("center", 480 + t),
|
|
||||||
),
|
|
||||||
"rocket-league": ( # Rocket League
|
|
||||||
"https://www.youtube.com/watch?v=2X9QGY__0II",
|
|
||||||
"rocket_league.mp4",
|
|
||||||
"Orbital Gameplay",
|
|
||||||
lambda t: ("center", 200 + t),
|
|
||||||
),
|
|
||||||
"minecraft": ( # Minecraft parkour
|
|
||||||
"https://www.youtube.com/watch?v=n_Dv4JMiwK8",
|
|
||||||
"parkour.mp4",
|
|
||||||
"bbswitzer",
|
|
||||||
"center",
|
|
||||||
),
|
|
||||||
"gta": ( # GTA Stunt Race
|
|
||||||
"https://www.youtube.com/watch?v=qGa9kWREOnE",
|
|
||||||
"gta-stunt-race.mp4",
|
|
||||||
"Achy Gaming",
|
|
||||||
lambda t: ("center", 480 + t),
|
|
||||||
),
|
|
||||||
"csgo-surf": ( # CSGO Surf
|
|
||||||
"https://www.youtube.com/watch?v=E-8JlyO59Io",
|
|
||||||
"csgo-surf.mp4",
|
|
||||||
"Aki",
|
|
||||||
"center",
|
|
||||||
),
|
|
||||||
"cluster-truck": ( # Cluster Truck Gameplay
|
|
||||||
"https://www.youtube.com/watch?v=uVKxtdMgJVU",
|
|
||||||
"cluster_truck.mp4",
|
|
||||||
"No Copyright Gameplay",
|
|
||||||
lambda t: ("center", 480 + t),
|
|
||||||
),
|
|
||||||
}
|
|
@ -0,0 +1,63 @@
|
|||||||
|
{
|
||||||
|
"__comment": "Supported Backgrounds. Can add/remove background video here...",
|
||||||
|
"motor-gta": [
|
||||||
|
"https://www.youtube.com/watch?v=vw5L4xCPy9Q",
|
||||||
|
"bike-parkour-gta.mp4",
|
||||||
|
"Achy Gaming",
|
||||||
|
480
|
||||||
|
],
|
||||||
|
"rocket-league": [
|
||||||
|
"https://www.youtube.com/watch?v=2X9QGY__0II",
|
||||||
|
"rocket_league.mp4",
|
||||||
|
"Orbital Gameplay",
|
||||||
|
200
|
||||||
|
],
|
||||||
|
"minecraft": [
|
||||||
|
"https://www.youtube.com/watch?v=n_Dv4JMiwK8",
|
||||||
|
"parkour.mp4",
|
||||||
|
"bbswitzer",
|
||||||
|
"center"
|
||||||
|
],
|
||||||
|
"gta": [
|
||||||
|
"https://www.youtube.com/watch?v=qGa9kWREOnE",
|
||||||
|
"gta-stunt-race.mp4",
|
||||||
|
"Achy Gaming",
|
||||||
|
480
|
||||||
|
],
|
||||||
|
"csgo-surf": [
|
||||||
|
"https://www.youtube.com/watch?v=E-8JlyO59Io",
|
||||||
|
"csgo-surf.mp4",
|
||||||
|
"Aki",
|
||||||
|
"center"
|
||||||
|
],
|
||||||
|
"cluster-truck": [
|
||||||
|
"https://www.youtube.com/watch?v=uVKxtdMgJVU",
|
||||||
|
"cluster_truck.mp4",
|
||||||
|
"No Copyright Gameplay",
|
||||||
|
480
|
||||||
|
],
|
||||||
|
"minecraft-2": [
|
||||||
|
"https://www.youtube.com/watch?v=Pt5_GSKIWQM",
|
||||||
|
"minecraft-2.mp4",
|
||||||
|
"Itslpsn",
|
||||||
|
"center"
|
||||||
|
],
|
||||||
|
"multiversus": [
|
||||||
|
"https://www.youtube.com/watch?v=66oK1Mktz6g",
|
||||||
|
"multiversus.mp4",
|
||||||
|
"MKIceAndFire",
|
||||||
|
"center"
|
||||||
|
],
|
||||||
|
"fall-guys": [
|
||||||
|
"https://www.youtube.com/watch?v=oGSsgACIc6Q",
|
||||||
|
"fall-guys.mp4",
|
||||||
|
"Throneful",
|
||||||
|
"center"
|
||||||
|
],
|
||||||
|
"steep": [
|
||||||
|
"https://www.youtube.com/watch?v=EnGiQrWBrko",
|
||||||
|
"steep.mp4",
|
||||||
|
"joel",
|
||||||
|
"center"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,226 @@
|
|||||||
|
import json
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import toml
|
||||||
|
import tomlkit
|
||||||
|
from flask import flash
|
||||||
|
|
||||||
|
|
||||||
|
# Get validation checks from template
|
||||||
|
def get_checks():
|
||||||
|
template = toml.load("utils/.config.template.toml")
|
||||||
|
checks = {}
|
||||||
|
|
||||||
|
def unpack_checks(obj: dict):
|
||||||
|
for key in obj.keys():
|
||||||
|
if "optional" in obj[key].keys():
|
||||||
|
checks[key] = obj[key]
|
||||||
|
else:
|
||||||
|
unpack_checks(obj[key])
|
||||||
|
|
||||||
|
unpack_checks(template)
|
||||||
|
|
||||||
|
return checks
|
||||||
|
|
||||||
|
|
||||||
|
# Get current config (from config.toml) as dict
|
||||||
|
def get_config(obj: dict, done={}):
|
||||||
|
for key in obj.keys():
|
||||||
|
if not isinstance(obj[key], dict):
|
||||||
|
done[key] = obj[key]
|
||||||
|
else:
|
||||||
|
get_config(obj[key], done)
|
||||||
|
|
||||||
|
return done
|
||||||
|
|
||||||
|
|
||||||
|
# Checks if value is valid
|
||||||
|
def check(value, checks):
|
||||||
|
incorrect = False
|
||||||
|
|
||||||
|
if value == "False":
|
||||||
|
value = ""
|
||||||
|
|
||||||
|
if not incorrect and "type" in checks:
|
||||||
|
try:
|
||||||
|
value = eval(checks["type"])(value)
|
||||||
|
except Exception:
|
||||||
|
incorrect = True
|
||||||
|
|
||||||
|
if (
|
||||||
|
not incorrect and "options" in checks and value not in checks["options"]
|
||||||
|
): # FAILSTATE Value is not one of the options
|
||||||
|
incorrect = True
|
||||||
|
if (
|
||||||
|
not incorrect
|
||||||
|
and "regex" in checks
|
||||||
|
and (
|
||||||
|
(isinstance(value, str) and re.match(checks["regex"], value) is None)
|
||||||
|
or not isinstance(value, str)
|
||||||
|
)
|
||||||
|
): # FAILSTATE Value doesn't match regex, or has regex but is not a string.
|
||||||
|
incorrect = True
|
||||||
|
|
||||||
|
if (
|
||||||
|
not incorrect
|
||||||
|
and not hasattr(value, "__iter__")
|
||||||
|
and (
|
||||||
|
("nmin" in checks and checks["nmin"] is not None and value < checks["nmin"])
|
||||||
|
or (
|
||||||
|
"nmax" in checks
|
||||||
|
and checks["nmax"] is not None
|
||||||
|
and value > checks["nmax"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
):
|
||||||
|
incorrect = True
|
||||||
|
|
||||||
|
if (
|
||||||
|
not incorrect
|
||||||
|
and hasattr(value, "__iter__")
|
||||||
|
and (
|
||||||
|
(
|
||||||
|
"nmin" in checks
|
||||||
|
and checks["nmin"] is not None
|
||||||
|
and len(value) < checks["nmin"]
|
||||||
|
)
|
||||||
|
or (
|
||||||
|
"nmax" in checks
|
||||||
|
and checks["nmax"] is not None
|
||||||
|
and len(value) > checks["nmax"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
):
|
||||||
|
incorrect = True
|
||||||
|
|
||||||
|
if incorrect:
|
||||||
|
return "Error"
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
# Modify settings (after form is submitted)
|
||||||
|
def modify_settings(data: dict, config_load, checks: dict):
|
||||||
|
# Modify config settings
|
||||||
|
def modify_config(obj: dict, name: str, value: any):
|
||||||
|
for key in obj.keys():
|
||||||
|
if name == key:
|
||||||
|
obj[key] = value
|
||||||
|
elif not isinstance(obj[key], dict):
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
modify_config(obj[key], name, value)
|
||||||
|
|
||||||
|
# Remove empty/incorrect key-value pairs
|
||||||
|
data = {key: value for key, value in data.items() if value and key in checks.keys()}
|
||||||
|
|
||||||
|
# Validate values
|
||||||
|
for name in data.keys():
|
||||||
|
value = check(data[name], checks[name])
|
||||||
|
|
||||||
|
# Value is invalid
|
||||||
|
if value == "Error":
|
||||||
|
flash("Some values were incorrect and didn't save!", "error")
|
||||||
|
else:
|
||||||
|
# Value is valid
|
||||||
|
modify_config(config_load, name, value)
|
||||||
|
|
||||||
|
# Save changes in config.toml
|
||||||
|
with Path("config.toml").open("w") as toml_file:
|
||||||
|
toml_file.write(tomlkit.dumps(config_load))
|
||||||
|
|
||||||
|
flash("Settings saved!")
|
||||||
|
|
||||||
|
return get_config(config_load)
|
||||||
|
|
||||||
|
|
||||||
|
# Delete background video
|
||||||
|
def delete_background(key):
|
||||||
|
# Read backgrounds.json
|
||||||
|
with open("utils/backgrounds.json", "r", encoding="utf-8") as backgrounds:
|
||||||
|
data = json.load(backgrounds)
|
||||||
|
|
||||||
|
# Remove background from backgrounds.json
|
||||||
|
with open("utils/backgrounds.json", "w", encoding="utf-8") as backgrounds:
|
||||||
|
if data.pop(key, None):
|
||||||
|
json.dump(data, backgrounds, ensure_ascii=False, indent=4)
|
||||||
|
else:
|
||||||
|
flash("Couldn't find this background. Try refreshing the page.", "error")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Remove background video from ".config.template.toml"
|
||||||
|
config = tomlkit.loads(Path("utils/.config.template.toml").read_text())
|
||||||
|
config["settings"]["background"]["background_choice"]["options"].remove(key)
|
||||||
|
|
||||||
|
with Path("utils/.config.template.toml").open("w") as toml_file:
|
||||||
|
toml_file.write(tomlkit.dumps(config))
|
||||||
|
|
||||||
|
flash(f'Successfully removed "{key}" background!')
|
||||||
|
|
||||||
|
|
||||||
|
# Add background video
|
||||||
|
def add_background(youtube_uri, filename, citation, position):
|
||||||
|
# Validate YouTube URI
|
||||||
|
regex = re.compile(r"(?:\/|%3D|v=|vi=)([0-9A-z\-_]{11})(?:[%#?&]|$)").search(
|
||||||
|
youtube_uri
|
||||||
|
)
|
||||||
|
|
||||||
|
if not regex:
|
||||||
|
flash("YouTube URI is invalid!", "error")
|
||||||
|
return
|
||||||
|
|
||||||
|
youtube_uri = f"https://www.youtube.com/watch?v={regex.group(1)}"
|
||||||
|
|
||||||
|
# Check if position is valid
|
||||||
|
if position == "" or position == "center":
|
||||||
|
position = "center"
|
||||||
|
|
||||||
|
elif position.isdecimal():
|
||||||
|
position = int(position)
|
||||||
|
|
||||||
|
else:
|
||||||
|
flash('Position is invalid! It can be "center" or decimal number.', "error")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Sanitize filename
|
||||||
|
regex = re.compile(r"^([a-zA-Z0-9\s_-]{1,100})$").match(filename)
|
||||||
|
|
||||||
|
if not regex:
|
||||||
|
flash("Filename is invalid!", "error")
|
||||||
|
return
|
||||||
|
|
||||||
|
filename = filename.replace(" ", "_")
|
||||||
|
|
||||||
|
# Check if background doesn't already exist
|
||||||
|
with open("utils/backgrounds.json", "r", encoding="utf-8") as backgrounds:
|
||||||
|
data = json.load(backgrounds)
|
||||||
|
|
||||||
|
# Check if key isn't already taken
|
||||||
|
if filename in list(data.keys()):
|
||||||
|
flash("Background video with this name already exist!", "error")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Check if the YouTube URI isn't already used under different name
|
||||||
|
if youtube_uri in [data[i][0] for i in list(data.keys())]:
|
||||||
|
flash("Background video with this YouTube URI is already added!", "error")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Add background video to json file
|
||||||
|
with open("utils/backgrounds.json", "r+", encoding="utf-8") as backgrounds:
|
||||||
|
data = json.load(backgrounds)
|
||||||
|
|
||||||
|
data[filename] = [youtube_uri, filename + ".mp4", citation, position]
|
||||||
|
backgrounds.seek(0)
|
||||||
|
json.dump(data, backgrounds, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
|
# Add background video to ".config.template.toml"
|
||||||
|
config = tomlkit.loads(Path("utils/.config.template.toml").read_text())
|
||||||
|
config["settings"]["background"]["background_choice"]["options"].append(filename)
|
||||||
|
|
||||||
|
with Path("utils/.config.template.toml").open("w") as toml_file:
|
||||||
|
toml_file.write(tomlkit.dumps(config))
|
||||||
|
|
||||||
|
flash(f'Added "{citation}-{filename}.mp4" as a new background video!')
|
||||||
|
|
||||||
|
return
|
@ -1,10 +1,12 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from utils.console import print_substep
|
from utils.console import print_substep
|
||||||
|
|
||||||
|
|
||||||
def id(reddit_obj: dict):
|
def id(reddit_obj: dict):
|
||||||
"""
|
"""
|
||||||
This function takes a reddit object and returns the post id
|
This function takes a reddit object and returns the post id
|
||||||
"""
|
"""
|
||||||
id = re.sub(r"[^\w\s-]", "", reddit_obj["thread_id"])
|
id = re.sub(r"[^\w\s-]", "", reddit_obj["thread_id"])
|
||||||
print_substep(f"Thread ID is {id}", style="bold blue")
|
print_substep(f"Thread ID is {id}", style="bold blue")
|
||||||
return id
|
return id
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
import re
|
||||||
|
import textwrap
|
||||||
|
import os
|
||||||
|
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
from rich.progress import track
|
||||||
|
from TTS.engine_wrapper import process_text
|
||||||
|
|
||||||
|
def draw_multiple_line_text(image, text, font, text_color, padding, wrap=50):
|
||||||
|
"""
|
||||||
|
Draw multiline text over given image
|
||||||
|
"""
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
Fontperm = font.getsize(text)
|
||||||
|
image_width, image_height = image.size
|
||||||
|
lines = textwrap.wrap(text, width=wrap)
|
||||||
|
y = (image_height / 2) - (
|
||||||
|
((Fontperm[1] + (len(lines) * padding) / len(lines)) * len(lines)) / 2
|
||||||
|
)
|
||||||
|
for line in lines:
|
||||||
|
line_width, line_height = font.getsize(line)
|
||||||
|
draw.text(((image_width - line_width) / 2, y), line, font=font, fill=text_color)
|
||||||
|
y += line_height + padding
|
||||||
|
|
||||||
|
|
||||||
|
# theme=bgcolor,reddit_obj=reddit_object,txtclr=txtcolor
|
||||||
|
def imagemaker(theme, reddit_obj: dict, txtclr, padding=5):
|
||||||
|
"""
|
||||||
|
Render Images for video
|
||||||
|
"""
|
||||||
|
title = process_text(reddit_obj["thread_title"], False) #TODO if second argument cause any error
|
||||||
|
texts = reddit_obj["thread_post"]
|
||||||
|
id = re.sub(r"[^\w\s-]", "", reddit_obj["thread_id"])
|
||||||
|
|
||||||
|
tfont = ImageFont.truetype(os.path.join("fonts", "Roboto-Bold.ttf"), 27) # for title
|
||||||
|
font = ImageFont.truetype(
|
||||||
|
os.path.join("fonts", "Roboto-Regular.ttf"), 20
|
||||||
|
) # for despcription|comments
|
||||||
|
size = (500, 176)
|
||||||
|
|
||||||
|
image = Image.new("RGBA", size, theme)
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
|
||||||
|
# for title
|
||||||
|
if len(title) > 40:
|
||||||
|
draw_multiple_line_text(image, title, tfont, txtclr, padding, wrap=30)
|
||||||
|
else:
|
||||||
|
|
||||||
|
Fontperm = tfont.getsize(title)
|
||||||
|
draw.text(
|
||||||
|
((image.size[0] - Fontperm[0]) / 2, (image.size[1] - Fontperm[1]) / 2),
|
||||||
|
font=tfont,
|
||||||
|
text=title,
|
||||||
|
) # (image.size[1]/2)-(Fontperm[1]/2)
|
||||||
|
|
||||||
|
image.save(f"assets/temp/{id}/png/title.png")
|
||||||
|
|
||||||
|
# for comment|description
|
||||||
|
|
||||||
|
for idx, text in track(enumerate(texts), "Rendering Image"):#, total=len(texts)):
|
||||||
|
|
||||||
|
image = Image.new("RGBA", size, theme)
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
text = process_text(text,False)
|
||||||
|
if len(text) > 50:
|
||||||
|
draw_multiple_line_text(image, text, font, txtclr, padding)
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
Fontperm = font.getsize(text)
|
||||||
|
draw.text(
|
||||||
|
((image.size[0] - Fontperm[0]) / 2, (image.size[1] - Fontperm[1]) / 2),
|
||||||
|
font=font,
|
||||||
|
text=text,
|
||||||
|
) # (image.size[1]/2)-(Fontperm[1]/2)
|
||||||
|
image.save(f"assets/temp/{id}/png/img{idx}.png")
|
@ -0,0 +1,29 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
import spacy
|
||||||
|
|
||||||
|
from utils.console import print_step
|
||||||
|
from utils.voice import sanitize_text
|
||||||
|
|
||||||
|
|
||||||
|
# working good
|
||||||
|
def posttextparser(obj):
|
||||||
|
text = re.sub("\n", "", obj)
|
||||||
|
|
||||||
|
try:
|
||||||
|
nlp = spacy.load('en_core_web_sm')
|
||||||
|
except OSError:
|
||||||
|
print_step("The spacy model can't load. You need to install it with \npython -m spacy download en")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
doc = nlp(text)
|
||||||
|
|
||||||
|
newtext: list = []
|
||||||
|
|
||||||
|
# to check for space str
|
||||||
|
for line in doc.sents:
|
||||||
|
if sanitize_text(line.text):
|
||||||
|
newtext.append(line.text)
|
||||||
|
# print(line)
|
||||||
|
|
||||||
|
return newtext
|
@ -0,0 +1,37 @@
|
|||||||
|
from PIL import ImageDraw, ImageFont
|
||||||
|
|
||||||
|
|
||||||
|
def create_thumbnail(thumbnail, font_family, font_size, font_color, width, height, title):
|
||||||
|
|
||||||
|
font = ImageFont.truetype(font_family + ".ttf", font_size)
|
||||||
|
Xaxis = width - (width * 0.2) # 20% of the width
|
||||||
|
sizeLetterXaxis = font_size * 0.5 # 50% of the font size
|
||||||
|
XaxisLetterQty = round(Xaxis / sizeLetterXaxis) # Quantity of letters that can fit in the X axis
|
||||||
|
MarginYaxis = (height * 0.12) # 12% of the height
|
||||||
|
MarginXaxis = (width * 0.05) # 5% of the width
|
||||||
|
# 1.1 rem
|
||||||
|
LineHeight = font_size * 1.1
|
||||||
|
# rgb = "255,255,255" transform to list
|
||||||
|
rgb = font_color.split(",")
|
||||||
|
rgb = (int(rgb[0]), int(rgb[1]), int(rgb[2]))
|
||||||
|
|
||||||
|
arrayTitle = []
|
||||||
|
for word in title.split():
|
||||||
|
if len(arrayTitle) == 0:
|
||||||
|
# colocar a primeira palavra no arrayTitl# put the first word in the arrayTitle
|
||||||
|
arrayTitle.append(word)
|
||||||
|
else:
|
||||||
|
# if the size of arrayTitle is less than qtLetters
|
||||||
|
if len(arrayTitle[-1]) + len(word) < XaxisLetterQty:
|
||||||
|
arrayTitle[-1] = arrayTitle[-1] + " " + word
|
||||||
|
else:
|
||||||
|
arrayTitle.append(word)
|
||||||
|
|
||||||
|
draw = ImageDraw.Draw(thumbnail)
|
||||||
|
# loop for put the title in the thumbnail
|
||||||
|
for i in range(0, len(arrayTitle)):
|
||||||
|
# 1.1 rem
|
||||||
|
draw.text((MarginXaxis, MarginYaxis + (LineHeight * i)),
|
||||||
|
arrayTitle[i], rgb, font=font)
|
||||||
|
|
||||||
|
return thumbnail
|
@ -1 +1 @@
|
|||||||
[]
|
[]
|
||||||
|
Loading…
Reference in new issue