Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix listing album tracks without track number #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions supysonic/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ def prune(cls):

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)
Expand Down Expand Up @@ -350,15 +350,15 @@ def as_subsonic_child(self, user, prefs):
"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(),
"duration": self.duration,
"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),
Expand Down Expand Up @@ -421,7 +421,7 @@ def suffix(self):
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):
Expand Down
4 changes: 2 additions & 2 deletions supysonic/schema/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions supysonic/schema/postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions supysonic/schema/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down