mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
dirty fix for dlna list
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"server/settings"
|
||||
"server/torr"
|
||||
"server/torr/state"
|
||||
"server/utils"
|
||||
)
|
||||
|
||||
func getTorrents() (ret []interface{}) {
|
||||
@@ -49,9 +50,9 @@ func getTorrent(path, host string) (ret []interface{}) {
|
||||
if torr == nil {
|
||||
return nil
|
||||
}
|
||||
parent := "%2F" + torr.TorrentSpec.InfoHash.HexString()
|
||||
// get content from torrent
|
||||
|
||||
// get content from torrent
|
||||
parent := "%2F" + torr.TorrentSpec.InfoHash.HexString()
|
||||
// if torrent not loaded, get button for load
|
||||
if torr.Files() == nil {
|
||||
obj := upnpav.Object{
|
||||
@@ -101,11 +102,13 @@ func loadTorrent(path, host string) (ret []interface{}) {
|
||||
parent := "%2F" + tor.TorrentSpec.InfoHash.HexString()
|
||||
files := tor.Status().FileStats
|
||||
for _, f := range files {
|
||||
if utils.GetMimeType(f.Path) != "*/*" {
|
||||
obj := getObjFromTorrent(path, parent, host, tor, f)
|
||||
if obj != nil {
|
||||
ret = append(ret, obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -123,11 +126,13 @@ func getLink(host, path string) string {
|
||||
func getObjFromTorrent(path, parent, host string, torr *torr.Torrent, file *state.TorrentFileStat) (ret interface{}) {
|
||||
mime, err := dms.MimeTypeByPath(file.Path)
|
||||
if err != nil {
|
||||
return
|
||||
//return // this always err
|
||||
mime = "video/mpeg"
|
||||
}
|
||||
//mime := utils.GetMimeType(file.Path)
|
||||
|
||||
obj := upnpav.Object{
|
||||
ID: parent + "%2" + file.Path,
|
||||
ID: parent + "%2F" + file.Path,
|
||||
Restricted: 1,
|
||||
ParentID: parent,
|
||||
Class: "object.item." + mime.Type() + "Item",
|
||||
|
||||
@@ -101,7 +101,7 @@ func GetTorrent(hashHex string) *Torrent {
|
||||
go func() {
|
||||
lockApi.Lock()
|
||||
defer lockApi.Unlock()
|
||||
log.TLogln("Add torrent")
|
||||
log.TLogln("New torrent", tor.Hash())
|
||||
tr, _ := NewTorrent(tor.TorrentSpec, bts)
|
||||
if tr != nil {
|
||||
tr.Title = tor.Title
|
||||
|
||||
Reference in New Issue
Block a user