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"
"server/log"
mt "server/mimetype"
"server/settings"
"server/torr"
"server/torr/state"
@@ -124,6 +125,11 @@ func getTorrentMeta(path, host string) (ret interface{}) {
Title: "TorrServer",
Date: upnpav.Timestamp{Time: time.Now()},
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
meta := upnpav.Container{Object: rootObj}
@@ -134,13 +140,12 @@ func getTorrentMeta(path, host string) (ret interface{}) {
ID: "%2FTR",
ParentID: "0",
Restricted: 1,
Searchable: 1,
Title: "Torrents",
Class: "object.container.storageFolder",
Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container",
}
//vol := len(torr.ListTorrent())
meta := upnpav.Container{Object: trObj}
vol := len(torr.ListTorrent())
meta := upnpav.Container{Object: trObj, ChildCount: vol}
return meta
}
@@ -165,8 +170,8 @@ func getTorrentMeta(path, host string) (ret interface{}) {
ParentID: "%2FTR",
Restricted: 1,
Title: torr.Title,
Class: "object.container.storageFolder",
Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container",
}
meta := upnpav.Container{Object: obj}
return meta
@@ -180,10 +185,10 @@ func getTorrentMeta(path, host string) (ret interface{}) {
ID: parent + "%2FLD",
ParentID: parent,
Restricted: 1,
Searchable: 1,
Searchable: 0,
Title: "Load Torrents",
Class: "object.container.storageFolder",
Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container",
}
meta := upnpav.Container{Object: obj}
return meta
@@ -199,16 +204,15 @@ func getTorrentMeta(path, host string) (ret interface{}) {
ID: id,
ParentID: parent,
Restricted: 1,
Searchable: 1,
Title: file,
Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container",
Date: upnpav.Timestamp{Time: time.Now()},
}
meta := upnpav.Container{Object: obj}
return meta
}
// for error response
return nil
// nil for error
return
}
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{}) {
mime, err := MimeTypeByPath(file.Path)
mime, err := mt.MimeTypeByPath(file.Path)
if err != nil {
if settings.BTsets.EnableDebug {
log.TLogln("Can't detect mime type", err)