diff --git a/musik.py b/musik.py index dd241d4..7724668 100755 --- a/musik.py +++ b/musik.py @@ -8,7 +8,7 @@ import random import subprocess from urllib import parse -from flask import Flask, Response, render_template +from flask import Flask, Response, render_template, send_file from werkzeug.utils import secure_filename MUSIC_DIR = "/mnt/music/Music" @@ -32,6 +32,7 @@ def index(): nav_items.sort() nav_items = [item + '/' for item in nav_items] initial_track = "/Accept/Accept - Balls to the Wall (1983) [FLAC] {74321 93214 2}/01 - Balls to the Wall.flac" + initial_cover = "/Accept/Accept - Balls to the Wall (1983) [FLAC] {74321 93214 2}/folder.jpg" cd = "/" return render_template('index.html', **locals()) @@ -84,7 +85,7 @@ def get_dir(directory): @app.route('/get_shuffle') def shuffle(): - """Returns a randomly selected song from the library.""" + """Returns a randomly selected track from the library.""" item = random.choice(os.listdir(MUSIC_DIR)) path = os.path.join(MUSIC_DIR, item) n = 0 @@ -101,5 +102,18 @@ def shuffle(): return path.replace(MUSIC_DIR, '') +@app.route('/album_cover/') +def album_cover(cover): + """View for the raw audio file.""" + path = os.path.join(MUSIC_DIR, cover) + path = os.path.abspath(path) + if not path.startswith(MUSIC_DIR): + return "False" + if not os.path.isfile(path): + return "False" + + return send_file(path) + + if __name__ == "__main__": app.run(host='0.0.0.0', port=5150) diff --git a/static/musik.css b/static/musik.css index 2661960..14a570b 100644 --- a/static/musik.css +++ b/static/musik.css @@ -1,11 +1,20 @@ -#mainContainer { - position: absolute; - top: 0; - right: 0; - height: 100%; - width: 100%; +body { + margin: 0; +} + +img { + max-width:100%; + max-height:100%; +} + +#globalContainer { display: flex; flex-direction: column; + height: 100vh; +} + +#titleContainer { + text-align: center; } #navigationContainer { @@ -15,6 +24,25 @@ border-bottom: 2px solid #ccc; } +#currentDirectory { + padding-left: 0.5em; +} + #navItems { list-style-type: none; } + +#playerContainer { + flex: 0 0 auto; + display: flex; + flex-direction: row; + justify-content: center; +} + +#albumCover { + padding-right: 1em; +} + +#playerControls { + text-align: center; +} diff --git a/templates/index.html b/templates/index.html index 4d7200d..9749730 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,8 +7,8 @@ -
-

Musik

+
+

Musik

-
-

{{ initial_track }}

+
+
+

{{ initial_track }}

-
Shuffle -
+
+ + +
+