Add option for player to report real paths in Subsonic API. Closes #625

This commit is contained in:
Deluan 2020-11-28 10:24:55 -05:00
parent 7becc18da9
commit 975579ab26
6 changed files with 46 additions and 13 deletions

View File

@ -0,0 +1,23 @@
package migration
import (
"database/sql"
"github.com/pressly/goose"
)
func init() {
goose.AddMigration(Up20201128100726, Down20201128100726)
}
func Up20201128100726(tx *sql.Tx) error {
_, err := tx.Exec(`
alter table player
add report_real_path bool default FALSE not null;
`)
return err
}
func Down20201128100726(tx *sql.Tx) error {
return nil
}

View File

@ -5,15 +5,16 @@ import (
)
type Player struct {
ID string `json:"id" orm:"column(id)"`
Name string `json:"name"`
Type string `json:"type"`
UserName string `json:"userName"`
Client string `json:"client"`
IPAddress string `json:"ipAddress"`
LastSeen time.Time `json:"lastSeen"`
TranscodingId string `json:"transcodingId"`
MaxBitRate int `json:"maxBitRate"`
ID string `json:"id" orm:"column(id)"`
Name string `json:"name"`
Type string `json:"type"`
UserName string `json:"userName"`
Client string `json:"client"`
IPAddress string `json:"ipAddress"`
LastSeen time.Time `json:"lastSeen"`
TranscodingId string `json:"transcodingId"`
MaxBitRate int `json:"maxBitRate"`
ReportRealPath bool `json:"reportRealPath"`
}
type Players []Player

View File

@ -92,7 +92,8 @@
"maxBitRate": "Bitrate máx",
"client": "Cliente",
"userName": "Usuário",
"lastSeen": "Últ. acesso"
"lastSeen": "Últ. acesso",
"reportRealPath": "Use paths reais"
}
},
"transcoding": {
@ -323,4 +324,4 @@
"serverUptime": "Uptime do servidor",
"serverDown": "DESCONECTADO"
}
}
}

View File

@ -147,7 +147,12 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
child.CoverArt = "al-" + mf.AlbumID
}
child.ContentType = mf.ContentType()
child.Path = fmt.Sprintf("%s/%s/%s.%s", realArtistName(mf), mf.Album, mf.Title, mf.Suffix)
player, ok := request.PlayerFrom(ctx)
if ok && player.ReportRealPath {
child.Path = mf.Path
} else {
child.Path = fmt.Sprintf("%s/%s/%s.%s", realArtistName(mf), mf.Album, mf.Title, mf.Suffix)
}
child.DiscNumber = mf.DiscNumber
child.Created = &mf.CreatedAt
child.AlbumId = mf.AlbumID

View File

@ -92,7 +92,8 @@
"maxBitRate": "Max. Bit Rate",
"client": "Client",
"userName": "Username",
"lastSeen": "Last Seen At"
"lastSeen": "Last Seen At",
"reportRealPath": "Report Real Path"
}
},
"transcoding": {

View File

@ -1,6 +1,7 @@
import React from 'react'
import {
TextInput,
BooleanInput,
TextField,
Edit,
required,
@ -45,6 +46,7 @@ const PlayerEdit = (props) => (
{ id: 0, name: '-' },
]}
/>
<BooleanInput source="reportRealPath" fullWidth />
<TextField source="client" />
<TextField source="userName" />
</SimpleForm>