🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Add option for player to report real paths in Subsonic API. Closes #625
Deluan975579ab2650
diff --git a/db/migration/20201128100726_add_real-path_option.go b/db/migration/20201128100726_add_real-path_option.gonew file mode 100644index 000000000..d3c7ec88a--- /dev/null+++ b/db/migration/20201128100726_add_real-path_option.go@@ -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+}diff --git a/model/player.go b/model/player.goindex 3fc855102..36ad3b2eb 100644--- a/model/player.go+++ b/model/player.go@@ -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 []Playerdiff --git a/resources/i18n/pt.json b/resources/i18n/pt.jsonindex d013f9bd7..66dd298fa 100644--- a/resources/i18n/pt.json+++ b/resources/i18n/pt.json@@ -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"}-}\ No newline at end of file+}diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.goindex 768e215d4..6ce14cf47 100644--- a/server/subsonic/helpers.go+++ b/server/subsonic/helpers.go@@ -147,7 +147,12 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Childchild.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.DiscNumberchild.Created = &mf.CreatedAtchild.AlbumId = mf.AlbumIDdiff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 2ac1cb4fa..422b59e13 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -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": {diff --git a/ui/src/player/PlayerEdit.js b/ui/src/player/PlayerEdit.jsindex 0da820204..1c8f8dec7 100644--- a/ui/src/player/PlayerEdit.js+++ b/ui/src/player/PlayerEdit.js@@ -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>