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/settings"
|
||||||
"server/torr"
|
"server/torr"
|
||||||
"server/torr/state"
|
"server/torr/state"
|
||||||
|
"server/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getTorrents() (ret []interface{}) {
|
func getTorrents() (ret []interface{}) {
|
||||||
@@ -49,9 +50,9 @@ func getTorrent(path, host string) (ret []interface{}) {
|
|||||||
if torr == nil {
|
if torr == nil {
|
||||||
return 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 torrent not loaded, get button for load
|
||||||
if torr.Files() == nil {
|
if torr.Files() == nil {
|
||||||
obj := upnpav.Object{
|
obj := upnpav.Object{
|
||||||
@@ -101,9 +102,11 @@ func loadTorrent(path, host string) (ret []interface{}) {
|
|||||||
parent := "%2F" + tor.TorrentSpec.InfoHash.HexString()
|
parent := "%2F" + tor.TorrentSpec.InfoHash.HexString()
|
||||||
files := tor.Status().FileStats
|
files := tor.Status().FileStats
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
obj := getObjFromTorrent(path, parent, host, tor, f)
|
if utils.GetMimeType(f.Path) != "*/*" {
|
||||||
if obj != nil {
|
obj := getObjFromTorrent(path, parent, host, tor, f)
|
||||||
ret = append(ret, obj)
|
if obj != nil {
|
||||||
|
ret = append(ret, obj)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
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{}) {
|
func getObjFromTorrent(path, parent, host string, torr *torr.Torrent, file *state.TorrentFileStat) (ret interface{}) {
|
||||||
mime, err := dms.MimeTypeByPath(file.Path)
|
mime, err := dms.MimeTypeByPath(file.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
//return // this always err
|
||||||
|
mime = "video/mpeg"
|
||||||
}
|
}
|
||||||
|
//mime := utils.GetMimeType(file.Path)
|
||||||
|
|
||||||
obj := upnpav.Object{
|
obj := upnpav.Object{
|
||||||
ID: parent + "%2" + file.Path,
|
ID: parent + "%2F" + file.Path,
|
||||||
Restricted: 1,
|
Restricted: 1,
|
||||||
ParentID: parent,
|
ParentID: parent,
|
||||||
Class: "object.item." + mime.Type() + "Item",
|
Class: "object.item." + mime.Type() + "Item",
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ func GetTorrent(hashHex string) *Torrent {
|
|||||||
go func() {
|
go func() {
|
||||||
lockApi.Lock()
|
lockApi.Lock()
|
||||||
defer lockApi.Unlock()
|
defer lockApi.Unlock()
|
||||||
log.TLogln("Add torrent")
|
log.TLogln("New torrent", tor.Hash())
|
||||||
tr, _ := NewTorrent(tor.TorrentSpec, bts)
|
tr, _ := NewTorrent(tor.TorrentSpec, bts)
|
||||||
if tr != nil {
|
if tr != nil {
|
||||||
tr.Title = tor.Title
|
tr.Title = tor.Title
|
||||||
|
|||||||
Reference in New Issue
Block a user