sort tracks better
This commit is contained in:
parent
9cd963f910
commit
6c27ea933b
6
musik.py
6
musik.py
|
@ -35,6 +35,7 @@ class Track:
|
||||||
m = mutagen.mp3.EasyMP3(filepath)
|
m = mutagen.mp3.EasyMP3(filepath)
|
||||||
else:
|
else:
|
||||||
m = mutagen.File(filepath)
|
m = mutagen.File(filepath)
|
||||||
|
self.tracknumber = m.get('tracknumber', [''])[0]
|
||||||
self.title = m.get('title', [''])[0]
|
self.title = m.get('title', [''])[0]
|
||||||
self.artist = m.get('artist', [''])[0]
|
self.artist = m.get('artist', [''])[0]
|
||||||
self.album = m.get('album', [''])[0]
|
self.album = m.get('album', [''])[0]
|
||||||
|
@ -55,6 +56,7 @@ def build_library(root_dir):
|
||||||
filepath = os.path.join(root_dir, dir_name, file)
|
filepath = os.path.join(root_dir, dir_name, file)
|
||||||
track = Track(filepath)
|
track = Track(filepath)
|
||||||
tracks.append(track)
|
tracks.append(track)
|
||||||
|
print("Done")
|
||||||
return tracks
|
return tracks
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,7 +135,9 @@ class Selection(Resource):
|
||||||
found.append(track)
|
found.append(track)
|
||||||
if not found:
|
if not found:
|
||||||
abort(404, message="Album does not exist.")
|
abort(404, message="Album does not exist.")
|
||||||
return [t.title for t in found]
|
found = [t.tracknumber + " - " + t.title for t in found]
|
||||||
|
found.sort()
|
||||||
|
return found
|
||||||
|
|
||||||
elif args.get('artist'):
|
elif args.get('artist'):
|
||||||
found = []
|
found = []
|
||||||
|
|
|
@ -43,7 +43,7 @@ function select_album(select) {
|
||||||
nav_items = JSON.parse(httpRequest.responseText);
|
nav_items = JSON.parse(httpRequest.responseText);
|
||||||
let html_str = '';
|
let html_str = '';
|
||||||
for (let i = 0; i < nav_items.length; i++) {
|
for (let i = 0; i < nav_items.length; i++) {
|
||||||
html_str += '<option value="' + nav_items[i] + '">' + nav_items[i] + '</option>';
|
html_str += '<option value="' + nav_items[i].replace(/\d* - /, '') + '">' + nav_items[i] + '</option>';
|
||||||
}
|
}
|
||||||
document.getElementById('trackList').innerHTML = html_str;
|
document.getElementById('trackList').innerHTML = html_str;
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,6 @@ function select_track(select) {
|
||||||
if (httpRequest.status !== 200) { return; }
|
if (httpRequest.status !== 200) { return; }
|
||||||
|
|
||||||
let track = JSON.parse(httpRequest.responseText);
|
let track = JSON.parse(httpRequest.responseText);
|
||||||
console.log(track);
|
|
||||||
let source = document.getElementById('stream');
|
let source = document.getElementById('stream');
|
||||||
source.src = track.streampath;
|
source.src = track.streampath;
|
||||||
let player = document.getElementById('player');
|
let player = document.getElementById('player');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user