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
@@ -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
}
+10 -9
View File
@@ -5,15 +5,16 @@ import (
) )
type Player struct { type Player struct {
ID string `json:"id" orm:"column(id)"` ID string `json:"id" orm:"column(id)"`
Name string `json:"name"` Name string `json:"name"`
Type string `json:"type"` Type string `json:"type"`
UserName string `json:"userName"` UserName string `json:"userName"`
Client string `json:"client"` Client string `json:"client"`
IPAddress string `json:"ipAddress"` IPAddress string `json:"ipAddress"`
LastSeen time.Time `json:"lastSeen"` LastSeen time.Time `json:"lastSeen"`
TranscodingId string `json:"transcodingId"` TranscodingId string `json:"transcodingId"`
MaxBitRate int `json:"maxBitRate"` MaxBitRate int `json:"maxBitRate"`
ReportRealPath bool `json:"reportRealPath"`
} }
type Players []Player type Players []Player
+2 -1
View File
@@ -92,7 +92,8 @@
"maxBitRate": "Bitrate máx", "maxBitRate": "Bitrate máx",
"client": "Cliente", "client": "Cliente",
"userName": "Usuário", "userName": "Usuário",
"lastSeen": "Últ. acesso" "lastSeen": "Últ. acesso",
"reportRealPath": "Use paths reais"
} }
}, },
"transcoding": { "transcoding": {
+6 -1
View File
@@ -147,7 +147,12 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
child.CoverArt = "al-" + mf.AlbumID child.CoverArt = "al-" + mf.AlbumID
} }
child.ContentType = mf.ContentType() 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.DiscNumber = mf.DiscNumber
child.Created = &mf.CreatedAt child.Created = &mf.CreatedAt
child.AlbumId = mf.AlbumID child.AlbumId = mf.AlbumID
+2 -1
View File
@@ -92,7 +92,8 @@
"maxBitRate": "Max. Bit Rate", "maxBitRate": "Max. Bit Rate",
"client": "Client", "client": "Client",
"userName": "Username", "userName": "Username",
"lastSeen": "Last Seen At" "lastSeen": "Last Seen At",
"reportRealPath": "Report Real Path"
} }
}, },
"transcoding": { "transcoding": {
+2
View File
@@ -1,6 +1,7 @@
import React from 'react' import React from 'react'
import { import {
TextInput, TextInput,
BooleanInput,
TextField, TextField,
Edit, Edit,
required, required,
@@ -45,6 +46,7 @@ const PlayerEdit = (props) => (
{ id: 0, name: '-' }, { id: 0, name: '-' },
]} ]}
/> />
<BooleanInput source="reportRealPath" fullWidth />
<TextField source="client" /> <TextField source="client" />
<TextField source="userName" /> <TextField source="userName" />
</SimpleForm> </SimpleForm>