mirror of
https://github.com/stashapp/stash.git
synced 2026-02-12 17:39:18 -06:00
Adds ability to configure sort order for DLNA videos (#3645)
This commit is contained in:
@@ -493,6 +493,10 @@ func (r *mutationResolver) ConfigureDlna(ctx context.Context, input ConfigDLNAIn
|
||||
c.Set(config.DLNADefaultIPWhitelist, input.WhitelistedIPs)
|
||||
}
|
||||
|
||||
if input.VideoSortOrder != nil {
|
||||
c.Set(config.DLNAVideoSortOrder, input.VideoSortOrder)
|
||||
}
|
||||
|
||||
currentDLNAEnabled := c.GetDLNADefaultEnabled()
|
||||
if input.Enabled != nil && *input.Enabled != currentDLNAEnabled {
|
||||
c.Set(config.DLNADefaultEnabled, *input.Enabled)
|
||||
|
||||
@@ -202,6 +202,7 @@ func makeConfigDLNAResult() *ConfigDLNAResult {
|
||||
Enabled: config.GetDLNADefaultEnabled(),
|
||||
WhitelistedIPs: config.GetDLNADefaultIPWhitelist(),
|
||||
Interfaces: config.GetDLNAInterfaces(),
|
||||
VideoSortOrder: config.GetVideoSortOrder(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -444,10 +444,15 @@ func (me *contentDirectoryService) getVideos(sceneFilter *models.SceneFilterType
|
||||
var objs []interface{}
|
||||
|
||||
if err := txn.WithReadTxn(context.TODO(), me.txnManager, func(ctx context.Context) error {
|
||||
sort := "title"
|
||||
sort := me.VideoSortOrder
|
||||
direction := models.SortDirectionEnumDesc
|
||||
if sort == "title" {
|
||||
direction = models.SortDirectionEnumAsc
|
||||
}
|
||||
findFilter := &models.FindFilterType{
|
||||
PerPage: &pageSize,
|
||||
Sort: &sort,
|
||||
PerPage: &pageSize,
|
||||
Sort: &sort,
|
||||
Direction: &direction,
|
||||
}
|
||||
|
||||
scenes, total, err := scene.QueryWithCount(ctx, me.repository.SceneFinder, sceneFilter, findFilter)
|
||||
|
||||
@@ -276,6 +276,7 @@ type Server struct {
|
||||
repository Repository
|
||||
sceneServer sceneServer
|
||||
ipWhitelistManager *ipWhitelistManager
|
||||
VideoSortOrder string
|
||||
}
|
||||
|
||||
// UPnP SOAP service.
|
||||
|
||||
@@ -45,6 +45,7 @@ type dmsConfig struct {
|
||||
LogHeaders bool
|
||||
StallEventSubscribe bool
|
||||
NotifyInterval time.Duration
|
||||
VideoSortOrder string
|
||||
}
|
||||
|
||||
type sceneServer interface {
|
||||
@@ -56,6 +57,7 @@ type Config interface {
|
||||
GetDLNAInterfaces() []string
|
||||
GetDLNAServerName() string
|
||||
GetDLNADefaultIPWhitelist() []string
|
||||
GetVideoSortOrder() string
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
@@ -123,6 +125,7 @@ func (s *Service) init() error {
|
||||
FriendlyName: friendlyName,
|
||||
LogHeaders: false,
|
||||
NotifyInterval: 30 * time.Second,
|
||||
VideoSortOrder: s.config.GetVideoSortOrder(),
|
||||
}
|
||||
|
||||
interfaces, err := s.getInterfaces()
|
||||
@@ -164,6 +167,7 @@ func (s *Service) init() error {
|
||||
// },
|
||||
StallEventSubscribe: dmsConfig.StallEventSubscribe,
|
||||
NotifyInterval: dmsConfig.NotifyInterval,
|
||||
VideoSortOrder: dmsConfig.VideoSortOrder,
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -210,6 +210,9 @@ const (
|
||||
DLNADefaultIPWhitelist = "dlna.default_whitelist"
|
||||
DLNAInterfaces = "dlna.interfaces"
|
||||
|
||||
DLNAVideoSortOrder = "dlna.video_sort_order"
|
||||
dlnaVideoSortOrderDefault = "title"
|
||||
|
||||
// Logging options
|
||||
LogFile = "logFile"
|
||||
LogOut = "logOut"
|
||||
@@ -1370,6 +1373,17 @@ func (i *Instance) GetDLNAInterfaces() []string {
|
||||
return i.getStringSlice(DLNAInterfaces)
|
||||
}
|
||||
|
||||
// GetVideoSortOrder returns the sort order to display videos. If
|
||||
// empty, videos will be sorted by titles.
|
||||
func (i *Instance) GetVideoSortOrder() string {
|
||||
ret := i.getString(DLNAVideoSortOrder)
|
||||
if ret == "" {
|
||||
ret = dlnaVideoSortOrderDefault
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
// GetLogFile returns the filename of the file to output logs to.
|
||||
// An empty string means that file logging will be disabled.
|
||||
func (i *Instance) GetLogFile() string {
|
||||
|
||||
Reference in New Issue
Block a user