mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
update meta for samsung tvs
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 == "/" {
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user