add searchClass o root obj meta

This commit is contained in:
nikk gitanes
2021-09-13 17:14:34 +03:00
parent c27feb668c
commit 9fe6ae8d0f
3 changed files with 20 additions and 16 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/anacrolix/dms/upnpav" "github.com/anacrolix/dms/upnpav"
"server/log" "server/log"
mt "server/mimetype"
"server/settings" "server/settings"
"server/torr" "server/torr"
"server/torr/state" "server/torr/state"
@@ -124,6 +125,11 @@ func getTorrentMeta(path, host string) (ret interface{}) {
Title: "TorrServer", Title: "TorrServer",
Date: upnpav.Timestamp{Time: time.Now()}, Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container", Class: "object.container",
SearchXML: ` <upnp:searchClass includeDerived="1">object.container</upnp:searchClass>
<upnp:searchClass includeDerived="1">object.item.audioItem</upnp:searchClass>
<upnp:searchClass includeDerived="1">object.item.imageItem</upnp:searchClass>
<upnp:searchClass includeDerived="1">object.item.videoItem</upnp:searchClass>
`,
} }
// add Root Object // add Root Object
meta := upnpav.Container{Object: rootObj} meta := upnpav.Container{Object: rootObj}
@@ -134,13 +140,12 @@ func getTorrentMeta(path, host string) (ret interface{}) {
ID: "%2FTR", ID: "%2FTR",
ParentID: "0", ParentID: "0",
Restricted: 1, Restricted: 1,
Searchable: 1,
Title: "Torrents", Title: "Torrents",
Class: "object.container.storageFolder",
Date: upnpav.Timestamp{Time: time.Now()}, Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container",
} }
//vol := len(torr.ListTorrent()) vol := len(torr.ListTorrent())
meta := upnpav.Container{Object: trObj} meta := upnpav.Container{Object: trObj, ChildCount: vol}
return meta return meta
} }
@@ -165,8 +170,8 @@ func getTorrentMeta(path, host string) (ret interface{}) {
ParentID: "%2FTR", ParentID: "%2FTR",
Restricted: 1, Restricted: 1,
Title: torr.Title, Title: torr.Title,
Class: "object.container.storageFolder",
Date: upnpav.Timestamp{Time: time.Now()}, Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container",
} }
meta := upnpav.Container{Object: obj} meta := upnpav.Container{Object: obj}
return meta return meta
@@ -180,10 +185,10 @@ func getTorrentMeta(path, host string) (ret interface{}) {
ID: parent + "%2FLD", ID: parent + "%2FLD",
ParentID: parent, ParentID: parent,
Restricted: 1, Restricted: 1,
Searchable: 1, Searchable: 0,
Title: "Load Torrents", Title: "Load Torrents",
Class: "object.container.storageFolder",
Date: upnpav.Timestamp{Time: time.Now()}, Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container",
} }
meta := upnpav.Container{Object: obj} meta := upnpav.Container{Object: obj}
return meta return meta
@@ -199,16 +204,15 @@ func getTorrentMeta(path, host string) (ret interface{}) {
ID: id, ID: id,
ParentID: parent, ParentID: parent,
Restricted: 1, Restricted: 1,
Searchable: 1,
Title: file, Title: file,
Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container", Class: "object.container",
Date: upnpav.Timestamp{Time: time.Now()},
} }
meta := upnpav.Container{Object: obj} meta := upnpav.Container{Object: obj}
return meta return meta
} }
// for error response // nil for error
return nil return
} }
func loadTorrent(path, host string) (ret []interface{}) { func loadTorrent(path, host string) (ret []interface{}) {
@@ -263,7 +267,7 @@ func getLink(host, path string) string {
func getObjFromTorrent(path, parent, host string, torr *torr.Torrent, file *state.TorrentFileStat) (ret interface{}) { func getObjFromTorrent(path, parent, host string, torr *torr.Torrent, file *state.TorrentFileStat) (ret interface{}) {
mime, err := MimeTypeByPath(file.Path) mime, err := mt.MimeTypeByPath(file.Path)
if err != nil { if err != nil {
if settings.BTsets.EnableDebug { if settings.BTsets.EnableDebug {
log.TLogln("Can't detect mime type", err) log.TLogln("Can't detect mime type", err)

View File

@@ -3,7 +3,7 @@ module server
go 1.17 go 1.17
replace ( replace (
github.com/anacrolix/dms v1.2.2 => github.com/tsynik/dms v0.0.0-20210911171915-d3d89ee99163 github.com/anacrolix/dms v1.2.2 => github.com/tsynik/dms v0.0.0-20210913075730-e41ecd88369c
github.com/anacrolix/torrent v1.31.0 => github.com/tsynik/torrent v1.2.7-0.20210907192509-2141ede9aa09 github.com/anacrolix/torrent v1.31.0 => github.com/tsynik/torrent v1.2.7-0.20210907192509-2141ede9aa09
) )
@@ -20,6 +20,7 @@ require (
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
go.etcd.io/bbolt v1.3.6 go.etcd.io/bbolt v1.3.6
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
) )
@@ -66,7 +67,6 @@ require (
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect
golang.org/x/text v0.3.6 // indirect golang.org/x/text v0.3.6 // indirect
google.golang.org/protobuf v1.27.1 // indirect google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect

View File

@@ -678,8 +678,8 @@ github.com/tinylib/msgp v1.1.1/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDW
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tsynik/dms v0.0.0-20210911171915-d3d89ee99163 h1:qBZPOad8wOmvFe6rIx1d0U7VpymFalvbM5kjHeEx8Gs= github.com/tsynik/dms v0.0.0-20210913075730-e41ecd88369c h1:4yU1p5MmRu+233Hs2OhR8Kx9gOWw20KR2AY1py5pLvA=
github.com/tsynik/dms v0.0.0-20210911171915-d3d89ee99163/go.mod h1:oWW4QbQ9YGl+FJ1X8xcrUYVObfA/KdipoeBuTC4ltG8= github.com/tsynik/dms v0.0.0-20210913075730-e41ecd88369c/go.mod h1:oWW4QbQ9YGl+FJ1X8xcrUYVObfA/KdipoeBuTC4ltG8=
github.com/tsynik/torrent v1.2.7-0.20210907192509-2141ede9aa09 h1:GHhNKxddZiYrWeiXqMQiPKcSIXKF+o/w1wrqHOgOFrk= github.com/tsynik/torrent v1.2.7-0.20210907192509-2141ede9aa09 h1:GHhNKxddZiYrWeiXqMQiPKcSIXKF+o/w1wrqHOgOFrk=
github.com/tsynik/torrent v1.2.7-0.20210907192509-2141ede9aa09/go.mod h1:E9gvoHzc58EtTudJbzZ2Ho7SKDCYk84734hB9ztBJS4= github.com/tsynik/torrent v1.2.7-0.20210907192509-2141ede9aa09/go.mod h1:E9gvoHzc58EtTudJbzZ2Ho7SKDCYk84734hB9ztBJS4=
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q=