mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
refactor dlna mimetypes
This commit is contained in:
@@ -102,13 +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 {
|
||||||
if utils.GetMimeType(f.Path) != "*/*" {
|
|
||||||
obj := getObjFromTorrent(path, parent, host, tor, f)
|
obj := getObjFromTorrent(path, parent, host, tor, f)
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
ret = append(ret, obj)
|
ret = append(ret, obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,12 +122,19 @@ 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{}) {
|
||||||
|
// only playable files
|
||||||
|
if utils.GetMimeType(file.Path) == "*/*" {
|
||||||
|
return
|
||||||
|
}
|
||||||
mime, err := dms.MimeTypeByPath(file.Path)
|
mime, err := dms.MimeTypeByPath(file.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//return // this always err
|
//return // this always err
|
||||||
|
if utils.GetMimeType(file.Path) == "video/*" {
|
||||||
mime = "video/mpeg"
|
mime = "video/mpeg"
|
||||||
|
} else {
|
||||||
|
mime = "audio/mpeg"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//mime := utils.GetMimeType(file.Path)
|
|
||||||
|
|
||||||
obj := upnpav.Object{
|
obj := upnpav.Object{
|
||||||
ID: parent + "%2F" + file.Path,
|
ID: parent + "%2F" + file.Path,
|
||||||
|
|||||||
Reference in New Issue
Block a user