1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-09 11:42:16 +00:00

Apply changes

This commit is contained in:
vithyze 2023-03-05 12:06:10 +00:00
parent 8e2adf8fc8
commit 57ee391916
4 changed files with 11 additions and 11 deletions

View File

@ -318,8 +318,8 @@ class Album(_Model):
class Track(PathMixin, _Model):
id = PrimaryKeyField()
disc = IntegerField()
number = IntegerField()
disc = IntegerField(null=True)
number = IntegerField(null=True)
title = CharField()
year = IntegerField(null=True)
genre = CharField(null=True)
@ -350,7 +350,7 @@ class Track(PathMixin, _Model):
"title": self.title,
"album": self.album.name,
"artist": self.artist.name,
"track": self.number,
"track": self.number or "",
"size": os.path.getsize(self.path) if os.path.isfile(self.path) else -1,
"contentType": self.mimetype,
"suffix": self.suffix(),
@ -358,7 +358,7 @@ class Track(PathMixin, _Model):
"bitRate": self.bitrate,
"path": self.path[len(self.root_folder.path) + 1 :],
"isVideo": False,
"discNumber": self.disc,
"discNumber": self.disc or "",
"created": self.created.isoformat(),
"albumId": str(self.album.id),
"artistId": str(self.artist.id),
@ -421,7 +421,7 @@ class Track(PathMixin, _Model):
return os.path.splitext(self.path)[1][1:].lower()
def sort_key(self):
return f"{self.album.artist.name}{self.album.name}{self.disc:02}{self.number:02}{self.title}".lower()
return f"{self.album.artist.name}{self.album.name}{self.disc:02 or ''}{self.number:02 or ''}{self.title}".lower()
class User(_Model):

View File

@ -25,8 +25,8 @@ CREATE INDEX index_album_artist_id_fk ON album(artist_id);
CREATE TABLE IF NOT EXISTS track (
id CHAR(32) PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
disc INTEGER,
number INTEGER,
title VARCHAR(256) NOT NULL,
year INTEGER,
genre VARCHAR(256),

View File

@ -25,8 +25,8 @@ CREATE INDEX IF NOT EXISTS index_album_artist_id_fk ON album(artist_id);
CREATE TABLE IF NOT EXISTS track (
id UUID PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
disc INTEGER,
number INTEGER,
title CITEXT NOT NULL,
year INTEGER,
genre VARCHAR(256),

View File

@ -26,8 +26,8 @@ CREATE INDEX IF NOT EXISTS index_album_artist_id_fk ON album(artist_id);
CREATE TABLE IF NOT EXISTS track (
id CHAR(36) PRIMARY KEY,
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
disc INTEGER,
number INTEGER,
title VARCHAR(256) NOT NULL COLLATE NOCASE,
year INTEGER,
genre VARCHAR(256),