added disc number

This commit is contained in:
iou1name 2019-03-21 08:15:24 -04:00
parent 9152ed1c83
commit 46ced5572d

View File

@ -38,6 +38,7 @@ class Track:
else: else:
m = mutagen.File(filepath) m = mutagen.File(filepath)
self.tracknumber = m.get('tracknumber', [''])[0] self.tracknumber = m.get('tracknumber', [''])[0]
self.discnumber = m.get('discnumber', [''])[0]
self.title = m.get('title', [''])[0] self.title = m.get('title', [''])[0]
if m.get('albumartist'): if m.get('albumartist'):
self.artist = m.get('albumartist', [''])[0] self.artist = m.get('albumartist', [''])[0]
@ -45,6 +46,7 @@ class Track:
self.artist = m.get('artist', [''])[0] self.artist = m.get('artist', [''])[0]
self.album = m.get('album', [''])[0] self.album = m.get('album', [''])[0]
self.date = m.get('date', [''])[0] self.date = m.get('date', [''])[0]
self.genre = m.get('genre', [''])[0]
self.length = str(int(m.info.length) // 60) + ":" self.length = str(int(m.info.length) // 60) + ":"
self.length += str(int(m.info.length) % 60) self.length += str(int(m.info.length) % 60)
self.filepath = filepath self.filepath = filepath
@ -174,7 +176,7 @@ 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.")
found = [t.tracknumber + " - " + t.title for t in found] found = [f"{t.discnumber}.{t.tracknumber} - {t.title}" for t in found]
found.sort() found.sort()
return found return found