Skip to content

Commit 7fcbe0c

Browse files
committed
beginning flask implementation
1 parent 73d7c92 commit 7fcbe0c

File tree

13 files changed

+445
-8
lines changed

13 files changed

+445
-8
lines changed

poetry.lock

+173-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ PlexAPI = "^4.15.7"
1212
requests = "^2.31.0"
1313
rtoml = "^0.10.0"
1414
schedule = "^1.2.1"
15+
flask = "^3.0.2"
1516

1617

1718
[build-system]

setup.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# Ensure the script is executed from the correct directory
4+
# This script should be run from the root of your project structure
5+
6+
# Creating necessary directories if they don't already exist
7+
mkdir -p static/css
8+
mkdir -p static/js
9+
mkdir -p static/img
10+
mkdir -p templates
11+
12+
# Creating placeholder files for Flask
13+
# Base HTML template
14+
cat > templates/base.html.j2 << EOF
15+
<!DOCTYPE html>
16+
<html lang="en">
17+
<head>
18+
<meta charset="UTF-8">
19+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
20+
<title>Spotiplex</title>
21+
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
22+
</head>
23+
<body>
24+
{% block content %}
25+
{% endblock %}
26+
</body>
27+
</html>
28+
EOF
29+
30+
# Home page HTML template
31+
cat > templates/index.html.j2 << EOF
32+
{% extends "base.html.j2" %}
33+
34+
{% block content %}
35+
<h1>Welcome to Spotiplex</h1>
36+
{% endblock %}
37+
EOF
38+
39+
# Placeholder CSS
40+
cat > static/css/style.css << EOF
41+
body {
42+
font-family: Arial, sans-serif;
43+
}
44+
EOF
45+
46+
# Placeholder main.py (if not already present in spotiplex)
47+
if [ ! -f spotiplex/main.py ]; then
48+
cat > spotiplex/main.py << EOF
49+
from flask import Flask, render_template
50+
51+
app = Flask(__name__)
52+
53+
@app.route('/')
54+
def home():
55+
return render_template('index.html.j2')
56+
57+
if __name__ == "__main__":
58+
app.run(debug=True)
59+
EOF
60+
fi
61+
62+
echo "Flask app structure is set up. You can now run the app using 'flask run' or 'python -m flask run'."

spotiplex/__init__.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from flask import Flask, render_template
2+
from .web_ui import functions
3+
4+
app = Flask(__name__)
5+
6+
7+
@app.route("/")
8+
def home():
9+
web_functions = functions()
10+
data = web_functions.get_dashboard_data()
11+
return render_template("index.html.j2", data=data)
12+
13+
14+
@app.route("/settings")
15+
def settings():
16+
return render_template("settings.html.j2")
17+
18+
19+
@app.route("/playlists")
20+
def playlists():
21+
return render_template("playlists.html.j2")
22+
23+
24+
# @app.route('')
25+
26+
if __name__ == "__main__":
27+
app.run(debug=True)

spotiplex/code.png

192 KB
Loading

spotiplex/lidarr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from confighandler import read_config
2+
from .confighandler import read_config
33
import requests
44
# test
55

spotiplex/main.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from plex import PlexService
2-
from spotify import SpotifyService
3-
from lidarr import LidarrAPI as lapi
4-
from confighandler import read_config, write_config
1+
from .plex import PlexService
2+
from .spotify import SpotifyService
3+
from .lidarr import LidarrAPI as lapi
4+
from .confighandler import read_config, write_config
55
import concurrent.futures
66
from concurrent.futures import ThreadPoolExecutor
77
import schedule
@@ -64,6 +64,7 @@ def __init__(self):
6464
self.worker_count = int(self.config.get("worker_count"))
6565
self.replace_existing = self.config.get("replace_existing")
6666
self.seconds_interval = int(self.config.get("seconds_interval"))
67+
6768
if self.lidarr_sync == "true":
6869
self.sync_lists = self.lidarr_api.get_lidarr_playlists()
6970
else:

spotiplex/plex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import requests
22
import urllib3
33
from plexapi.server import PlexServer
4-
from confighandler import read_config
4+
from .confighandler import read_config
55

66

77
class PlexService:

spotiplex/spotify.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import spotipy
22
from spotipy.oauth2 import SpotifyClientCredentials
33
from datetime import date
4-
from confighandler import read_config
4+
from .confighandler import read_config
55

66

77
class SpotifyService:

0 commit comments

Comments
 (0)