mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
rework torrents meta response
This commit is contained in:
@@ -2,6 +2,7 @@ package dlna
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
@@ -134,9 +135,9 @@ func onBrowseMeta(path string, rootObjectPath string, host, userAgent string) (r
|
|||||||
ret = upnpav.Container{Object: rootObj, ChildCount: 1}
|
ret = upnpav.Container{Object: rootObj, ChildCount: 1}
|
||||||
return
|
return
|
||||||
} else if path == "/TR" {
|
} else if path == "/TR" {
|
||||||
// Torrents Object Meta
|
// TR Object Meta
|
||||||
trObj := upnpav.Object{
|
trObj := upnpav.Object{
|
||||||
ID: "%2FR",
|
ID: "%2FTR",
|
||||||
ParentID: "0",
|
ParentID: "0",
|
||||||
Restricted: 1,
|
Restricted: 1,
|
||||||
Searchable: 1,
|
Searchable: 1,
|
||||||
@@ -147,11 +148,11 @@ func onBrowseMeta(path string, rootObjectPath string, host, userAgent string) (r
|
|||||||
vol := len(torr.ListTorrent())
|
vol := len(torr.ListTorrent())
|
||||||
ret = upnpav.Container{Object: trObj, ChildCount: vol}
|
ret = upnpav.Container{Object: trObj, ChildCount: vol}
|
||||||
return
|
return
|
||||||
} else if isHashPath(path) {
|
|
||||||
ret = getTorrentMeta(path, host)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// err = fmt.Errorf("not implemented")
|
ret = getTorrentMeta(path, host)
|
||||||
|
if ret == nil {
|
||||||
|
err = fmt.Errorf("meta not found")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,18 +128,48 @@ func getTorrentMeta(path, host string) (ret interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Meta object
|
// Meta object
|
||||||
obj := upnpav.Object{
|
if isHashPath(path) {
|
||||||
ID: "%2F" + torr.TorrentSpec.InfoHash.HexString(),
|
// hash object meta
|
||||||
ParentID: "%2FTR",
|
obj := upnpav.Object{
|
||||||
Restricted: 1,
|
ID: "%2F" + torr.TorrentSpec.InfoHash.HexString(),
|
||||||
Title: torr.Title,
|
ParentID: "%2FTR",
|
||||||
Class: "object.container.storageFolder",
|
Restricted: 1,
|
||||||
Date: upnpav.Timestamp{Time: time.Now()},
|
Title: torr.Title,
|
||||||
|
Date: upnpav.Timestamp{Time: time.Now()},
|
||||||
|
}
|
||||||
|
meta := upnpav.Container{Object: obj, ChildCount: 1}
|
||||||
|
return meta
|
||||||
|
} else if filepath.Base(path) == "LD" {
|
||||||
|
parent := url.PathEscape(filepath.Dir(path))
|
||||||
|
// LD object meta
|
||||||
|
obj := upnpav.Object{
|
||||||
|
ID: parent + "%2FLD",
|
||||||
|
ParentID: parent,
|
||||||
|
Restricted: 1,
|
||||||
|
Searchable: 1,
|
||||||
|
Title: "Load Torrents",
|
||||||
|
Date: upnpav.Timestamp{Time: time.Now()},
|
||||||
|
}
|
||||||
|
meta := upnpav.Container{Object: obj, ChildCount: 1}
|
||||||
|
return meta
|
||||||
|
} else {
|
||||||
|
file := filepath.Base(path)
|
||||||
|
id := url.PathEscape(path)
|
||||||
|
parent := url.PathEscape(filepath.Dir(path))
|
||||||
|
// file object meta
|
||||||
|
obj := upnpav.Object{
|
||||||
|
ID: id,
|
||||||
|
ParentID: parent,
|
||||||
|
Restricted: 1,
|
||||||
|
Searchable: 1,
|
||||||
|
Title: file,
|
||||||
|
Date: upnpav.Timestamp{Time: time.Now()},
|
||||||
|
}
|
||||||
|
meta := upnpav.Container{Object: obj, ChildCount: 1}
|
||||||
|
return meta
|
||||||
}
|
}
|
||||||
|
|
||||||
meta := upnpav.Container{Object: obj, ChildCount: 1}
|
return nil
|
||||||
|
|
||||||
return meta
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadTorrent(path, host string) (ret []interface{}) {
|
func loadTorrent(path, host string) (ret []interface{}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user