Skip to content

Commit 4c01a1d

Browse files
Version 3.0 is finally here!
2 parents 3380d69 + 576e208 commit 4c01a1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2674
-629
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ body:
4545
4646
Python version : [e.g. Python 3.6]
4747
48-
App version / Branch [e.g. latest, V2.0, master, develop]
48+
App version / Branch : [e.g. latest, V2.0, master, develop]
4949
validations:
5050
required: true
5151
- type: checkboxes

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
blank_issues_enabled: true
1+
blank_issues_enabled: false
22
contact_links:
33
- name: Ask a question
44
about: Join our discord server to ask questions and discuss with maintainers and contributors.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ fabric.properties
232232
.idea/caches/build_file_checksums.ser
233233

234234
assets/
235+
/.vscode
235236
out
236237
.DS_Store
237238
.setup-done-before
@@ -243,3 +244,4 @@ video_creation/data/videos.json
243244
video_creation/data/envvars.txt
244245

245246
config.toml
247+
video_creation/data/videos.json

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ All types of contributions are encouraged and valued. See the [Table of Contents
2828

2929
## I Have a Question
3030

31-
> If you want to ask a question, we assume that you have read the available [Documentation](https://luka-hietala.gitbook.io/documentation-for-the-reddit-bot/).
31+
> If you want to ask a question, we assume that you have read the available [Documentation](https://reddit-video-maker-bot.netlify.app/).
3232
3333
Before you ask a question, it is best to search for existing [Issues](https://github.com/elebumm/RedditVideoMakerBot/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
3434

@@ -144,4 +144,4 @@ When making your PR, follow these guidelines:
144144

145145
### Improving The Documentation
146146

147-
All updates to the documentation should be made in a pull request to [this repo](https://github.com/LukaHietala/reddit-bot-docs)
147+
All updates to the documentation should be made in a pull request to [this repo](https://github.com/LukaHietala/RedditVideoMakerBot-website)

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/playwright
1+
FROM python:3.10.9-slim
22

33
RUN apt update
44
RUN apt install python3-pip -y

GUI.py

Lines changed: 111 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,118 @@
1-
# Import the server module
2-
import http.server
31
import webbrowser
2+
from pathlib import Path
3+
4+
# Used "tomlkit" instead of "toml" because it doesn't change formatting on "dump"
5+
import tomlkit
6+
from flask import (
7+
Flask,
8+
redirect,
9+
render_template,
10+
request,
11+
send_from_directory,
12+
url_for,
13+
)
14+
15+
import utils.gui_utils as gui
416

517
# Set the hostname
618
HOST = "localhost"
719
# Set the port number
820
PORT = 4000
921

10-
# Define class to display the index page of the web server
11-
class PythonServer(http.server.SimpleHTTPRequestHandler):
12-
def do_GET(self):
13-
if self.path == "/GUI":
14-
self.path = "index.html"
15-
return http.server.SimpleHTTPRequestHandler.do_GET(self)
16-
17-
18-
# Declare object of the class
19-
webServer = http.server.HTTPServer((HOST, PORT), PythonServer)
20-
# Print the URL of the webserver, new =2 opens in a new tab
21-
print(f"Server started at http://{HOST}:{PORT}/GUI/")
22-
webbrowser.open(f"http://{HOST}:{PORT}/GUI/", new=2)
23-
print("Website opened in new tab")
24-
print("Press Ctrl+C to quit")
25-
try:
26-
# Run the web server
27-
webServer.serve_forever()
28-
except KeyboardInterrupt:
29-
# Stop the web server
30-
webServer.server_close()
31-
print("The server is stopped.")
32-
exit()
22+
# Configure application
23+
app = Flask(__name__, template_folder="GUI")
24+
25+
# Configure secret key only to use 'flash'
26+
app.secret_key = b'_5#y2L"F4Q8z\n\xec]/'
27+
28+
29+
# Ensure responses aren't cached
30+
@app.after_request
31+
def after_request(response):
32+
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
33+
response.headers["Expires"] = 0
34+
response.headers["Pragma"] = "no-cache"
35+
return response
36+
37+
38+
# Display index.html
39+
@app.route("/")
40+
def index():
41+
return render_template("index.html", file="videos.json")
42+
43+
44+
@app.route("/backgrounds", methods=["GET"])
45+
def backgrounds():
46+
return render_template("backgrounds.html", file="backgrounds.json")
47+
48+
49+
@app.route("/background/add", methods=["POST"])
50+
def background_add():
51+
# Get form values
52+
youtube_uri = request.form.get("youtube_uri").strip()
53+
filename = request.form.get("filename").strip()
54+
citation = request.form.get("citation").strip()
55+
position = request.form.get("position").strip()
56+
57+
gui.add_background(youtube_uri, filename, citation, position)
58+
59+
return redirect(url_for("backgrounds"))
60+
61+
62+
@app.route("/background/delete", methods=["POST"])
63+
def background_delete():
64+
key = request.form.get("background-key")
65+
gui.delete_background(key)
66+
67+
return redirect(url_for("backgrounds"))
68+
69+
70+
@app.route("/settings", methods=["GET", "POST"])
71+
def settings():
72+
config_load = tomlkit.loads(Path("config.toml").read_text())
73+
config = gui.get_config(config_load)
74+
75+
# Get checks for all values
76+
checks = gui.get_checks()
77+
78+
if request.method == "POST":
79+
# Get data from form as dict
80+
data = request.form.to_dict()
81+
82+
# Change settings
83+
config = gui.modify_settings(data, config_load, checks)
84+
85+
return render_template(
86+
"settings.html", file="config.toml", data=config, checks=checks
87+
)
88+
89+
90+
# Make videos.json accessible
91+
@app.route("/videos.json")
92+
def videos_json():
93+
return send_from_directory("video_creation/data", "videos.json")
94+
95+
96+
# Make backgrounds.json accessible
97+
@app.route("/backgrounds.json")
98+
def backgrounds_json():
99+
return send_from_directory("utils", "backgrounds.json")
100+
101+
102+
# Make videos in results folder accessible
103+
@app.route("/results/<path:name>")
104+
def results(name):
105+
return send_from_directory("results", name, as_attachment=True)
106+
107+
108+
# Make voices samples in voices folder accessible
109+
@app.route("/voices/<path:name>")
110+
def voices(name):
111+
return send_from_directory("GUI/voices", name, as_attachment=True)
112+
113+
114+
# Run browser and start the app
115+
if __name__ == "__main__":
116+
webbrowser.open(f"http://{HOST}:{PORT}", new=2)
117+
print("Website opened in new tab. Refresh if it didn't load.")
118+
app.run(port=PORT)

0 commit comments

Comments
 (0)