Add TrackNumber to "fake" generated filenames. Fixes #1912
This commit is contained in:
@@ -157,7 +157,7 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
|
||||
if ok && player.ReportRealPath {
|
||||
child.Path = mf.Path
|
||||
} else {
|
||||
child.Path = fmt.Sprintf("%s/%s/%s.%s", mapSlashToDash(mf.AlbumArtist), mapSlashToDash(mf.Album), mapSlashToDash(mf.Title), mf.Suffix)
|
||||
child.Path = fakePath(mf)
|
||||
}
|
||||
child.DiscNumber = mf.DiscNumber
|
||||
child.Created = &mf.CreatedAt
|
||||
@@ -182,6 +182,14 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
|
||||
return child
|
||||
}
|
||||
|
||||
func fakePath(mf model.MediaFile) string {
|
||||
filename := mapSlashToDash(mf.Title)
|
||||
if mf.TrackNumber != 0 {
|
||||
filename = fmt.Sprintf("%02d - %s", mf.TrackNumber, filename)
|
||||
}
|
||||
return fmt.Sprintf("%s/%s/%s.%s", mapSlashToDash(mf.AlbumArtist), mapSlashToDash(mf.Album), filename, mf.Suffix)
|
||||
}
|
||||
|
||||
func mapSlashToDash(target string) string {
|
||||
return strings.ReplaceAll(target, "/", "_")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user