mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
move meta objects to getTorrentMeta
This commit is contained in:
@@ -11,10 +11,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/anacrolix/dms/dlna/dms"
|
"github.com/anacrolix/dms/dlna/dms"
|
||||||
"github.com/anacrolix/dms/upnpav"
|
|
||||||
|
|
||||||
"server/log"
|
"server/log"
|
||||||
"server/torr"
|
|
||||||
"server/web/pages/template"
|
"server/web/pages/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -129,34 +127,6 @@ func onBrowse(path, rootObjectPath, host, userAgent string) (ret []interface{},
|
|||||||
}
|
}
|
||||||
|
|
||||||
func onBrowseMeta(path string, rootObjectPath string, host, userAgent string) (ret interface{}, err error) {
|
func onBrowseMeta(path string, rootObjectPath string, host, userAgent string) (ret interface{}, err error) {
|
||||||
if path == "/" {
|
|
||||||
rootObj := upnpav.Object{
|
|
||||||
ID: "0",
|
|
||||||
ParentID: "-1",
|
|
||||||
Restricted: 1,
|
|
||||||
Searchable: 1,
|
|
||||||
Title: "TorrServer",
|
|
||||||
Date: upnpav.Timestamp{Time: time.Now()},
|
|
||||||
Class: "object.container.storageFolder",
|
|
||||||
}
|
|
||||||
// add Root Object
|
|
||||||
ret = upnpav.Container{Object: rootObj, ChildCount: 1}
|
|
||||||
return
|
|
||||||
} else if path == "/TR" {
|
|
||||||
// TR Object Meta
|
|
||||||
trObj := upnpav.Object{
|
|
||||||
ID: "%2FTR",
|
|
||||||
ParentID: "0",
|
|
||||||
Restricted: 1,
|
|
||||||
Searchable: 1,
|
|
||||||
Title: "Torrents",
|
|
||||||
Date: upnpav.Timestamp{Time: time.Now()},
|
|
||||||
Class: "object.container.storageFolder",
|
|
||||||
}
|
|
||||||
vol := len(torr.ListTorrent())
|
|
||||||
ret = upnpav.Container{Object: trObj, ChildCount: vol}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ret = getTorrentMeta(path, host)
|
ret = getTorrentMeta(path, host)
|
||||||
if ret == nil {
|
if ret == nil {
|
||||||
err = fmt.Errorf("meta not found")
|
err = fmt.Errorf("meta not found")
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func getTorrents() (ret []interface{}) {
|
|||||||
Class: "object.container.storageFolder",
|
Class: "object.container.storageFolder",
|
||||||
Date: upnpav.Timestamp{Time: time.Now()},
|
Date: upnpav.Timestamp{Time: time.Now()},
|
||||||
}
|
}
|
||||||
cnt := upnpav.Container{Object: obj, ChildCount: 1}
|
cnt := upnpav.Container{Object: obj, ChildCount: 0}
|
||||||
ret = append(ret, cnt)
|
ret = append(ret, cnt)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -129,7 +129,34 @@ func getTorrentMeta(path, host string) (ret interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Meta object
|
// Meta object
|
||||||
if isHashPath(path) {
|
if path == "/" {
|
||||||
|
// root object meta
|
||||||
|
rootObj := upnpav.Object{
|
||||||
|
ID: "0",
|
||||||
|
ParentID: "-1",
|
||||||
|
Restricted: 1,
|
||||||
|
Searchable: 1,
|
||||||
|
Title: "TorrServer",
|
||||||
|
Date: upnpav.Timestamp{Time: time.Now()},
|
||||||
|
Class: "object.container.storageFolder",
|
||||||
|
}
|
||||||
|
meta := upnpav.Container{Object: rootObj, ChildCount: 1}
|
||||||
|
return meta
|
||||||
|
} else if path == "/TR" {
|
||||||
|
// TR Object Meta
|
||||||
|
trObj := upnpav.Object{
|
||||||
|
ID: "%2FTR",
|
||||||
|
ParentID: "0",
|
||||||
|
Restricted: 1,
|
||||||
|
Searchable: 1,
|
||||||
|
Title: "Torrents",
|
||||||
|
Date: upnpav.Timestamp{Time: time.Now()},
|
||||||
|
Class: "object.container.storageFolder",
|
||||||
|
}
|
||||||
|
vol := len(torrs)
|
||||||
|
meta := upnpav.Container{Object: trObj, ChildCount: vol}
|
||||||
|
return meta
|
||||||
|
} else if isHashPath(path) {
|
||||||
// hash object meta
|
// hash object meta
|
||||||
obj := upnpav.Object{
|
obj := upnpav.Object{
|
||||||
ID: "%2F" + torr.TorrentSpec.InfoHash.HexString(),
|
ID: "%2F" + torr.TorrentSpec.InfoHash.HexString(),
|
||||||
|
|||||||
Reference in New Issue
Block a user