update meta for samsung tvs

This commit is contained in:
nikk gitanes
2021-09-11 20:29:07 +03:00
parent 1a1c32ec25
commit 0fb9c74798
3 changed files with 49 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/anacrolix/dms/upnpav"
"server/log"
"server/torr"
"server/web/pages/template"
)
@@ -121,7 +122,6 @@ func onBrowse(path, rootObjectPath, host, userAgent string) (ret []interface{},
func onBrowseMeta(path string, rootObjectPath string, host, userAgent string) (ret interface{}, err error) {
if path == "/" {
// Root Object Meta
rootObj := upnpav.Object{
ID: "0",
ParentID: "-1",
@@ -134,8 +134,25 @@ func onBrowseMeta(path string, rootObjectPath string, host, userAgent string) (r
// add Root Object
ret = upnpav.Container{Object: rootObj, ChildCount: 1}
return
} else if path == "/TR" {
// Torrents Object Meta
trObj := upnpav.Object{
ID: "%2FR",
ParentID: "0",
Restricted: 1,
Searchable: 1,
Title: "Torrents",
Date: upnpav.Timestamp{Time: time.Now()},
Class: "object.container.storageFolder",
}
err = fmt.Errorf("not implemented")
vol := len(torr.ListTorrent())
ret = upnpav.Container{Object: trObj, ChildCount: vol}
return
} else if isHashPath(path) {
ret = getTorrentMeta(path, host)
return
}
// err = fmt.Errorf("not implemented")
return
}

View File

@@ -113,6 +113,35 @@ func getTorrent(path, host string) (ret []interface{}) {
return
}
func getTorrentMeta(path, host string) (ret interface{}) {
// find torrent without load
torrs := torr.ListTorrent()
var torr *torr.Torrent
for _, t := range torrs {
if strings.Contains(path, t.TorrentSpec.InfoHash.HexString()) {
torr = t
break
}
}
if torr == nil {
return nil
}
// Meta object
obj := upnpav.Object{
ID: "%2F" + torr.TorrentSpec.InfoHash.HexString(),
ParentID: "%2FTR",
Restricted: 1,
Title: torr.Title,
Class: "object.container.storageFolder",
Date: upnpav.Timestamp{Time: time.Now()},
}
meta := upnpav.Container{Object: obj, ChildCount: 1}
return meta
}
func loadTorrent(path, host string) (ret []interface{}) {
hash := filepath.Base(filepath.Dir(path))
if hash == "/" {

View File

@@ -3,7 +3,7 @@ module server
go 1.17
replace (
github.com/anacrolix/dms v1.2.2 => github.com/tsynik/dms v0.0.0-20210909053938-38af4173d4ac
github.com/anacrolix/dms v1.2.2 => github.com/tsynik/dms v0.0.0-20210911171915-d3d89ee99163
github.com/anacrolix/torrent v1.31.0 => github.com/tsynik/torrent v1.2.7-0.20210907192509-2141ede9aa09
)