mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-19 03:26:37 +03:00
Date now set
This commit is contained in:
parent
0ffb8a9091
commit
1b74a2b37f
@ -84,7 +84,7 @@ func (cds *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, is
|
|||||||
URL: (&url.URL{
|
URL: (&url.URL{
|
||||||
Scheme: "http",
|
Scheme: "http",
|
||||||
Host: host,
|
Host: host,
|
||||||
Path: path.Join(resPath, cdsObject.Path),
|
Path: path.Join(resourcePath, cdsObject.Path),
|
||||||
}).String(),
|
}).String(),
|
||||||
ProtocolInfo: fmt.Sprintf("http-get:*:%s:%s", mimeType, dlna.ContentFeatures{
|
ProtocolInfo: fmt.Sprintf("http-get:*:%s:%s", mimeType, dlna.ContentFeatures{
|
||||||
SupportRange: true,
|
SupportRange: true,
|
||||||
@ -119,7 +119,7 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
|||||||
return cds.doFiles(ret, o.Path, host)
|
return cds.doFiles(ret, o.Path, host)
|
||||||
} else if matchResults, err := artistRegex.Groups(o.Path); err == nil {
|
} else if matchResults, err := artistRegex.Groups(o.Path); err == nil {
|
||||||
if matchResults["ArtistAlbumTrack"] != "" {
|
if matchResults["ArtistAlbumTrack"] != "" {
|
||||||
//TODO
|
//This is never hit as the URL is direct to the resourcePath
|
||||||
log.Debug("Artist Get a track ")
|
log.Debug("Artist Get a track ")
|
||||||
} else if matchResults["ArtistAlbum"] != "" {
|
} else if matchResults["ArtistAlbum"] != "" {
|
||||||
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": matchResults["ArtistAlbum"]}})
|
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": matchResults["ArtistAlbum"]}})
|
||||||
@ -148,6 +148,7 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
|||||||
} else if matchResults, err := albumRegex.Groups(o.Path); err == nil {
|
} else if matchResults, err := albumRegex.Groups(o.Path); err == nil {
|
||||||
if matchResults["AlbumTrack"] != "" {
|
if matchResults["AlbumTrack"] != "" {
|
||||||
log.Debug("TODO AlbumTrack MATCH")
|
log.Debug("TODO AlbumTrack MATCH")
|
||||||
|
//This is never hit as the URL is direct to the resourcePath
|
||||||
} else if matchResults["AlbumTitle"] != "" {
|
} else if matchResults["AlbumTitle"] != "" {
|
||||||
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": matchResults["AlbumTitle"]}})
|
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": matchResults["AlbumTitle"]}})
|
||||||
return cds.doMediaFiles(tracks, o.Path, ret, host)
|
return cds.doMediaFiles(tracks, o.Path, ret, host)
|
||||||
@ -279,10 +280,12 @@ func (cds *contentDirectoryService) doMediaFiles(tracks model.MediaFiles, basePa
|
|||||||
Title: title,
|
Title: title,
|
||||||
}
|
}
|
||||||
|
|
||||||
var mimeType = "audio/mp3" //TODO
|
//TODO figure out how this fits with transcoding etc
|
||||||
|
var mimeType = "audio/mp3"
|
||||||
obj.Class = "object.item.audioItem.musicTrack"
|
obj.Class = "object.item.audioItem.musicTrack"
|
||||||
obj.Date = upnpav.Timestamp{Time:time.Now()} //TODO
|
|
||||||
|
trackDate, _ := time.Parse(time.DateOnly, track.Date)
|
||||||
|
obj.Date = upnpav.Timestamp{Time:trackDate}
|
||||||
obj.Artist = artist
|
obj.Artist = artist
|
||||||
obj.Album = album
|
obj.Album = album
|
||||||
obj.Genre = genre
|
obj.Genre = genre
|
||||||
@ -293,11 +296,14 @@ func (cds *contentDirectoryService) doMediaFiles(tracks model.MediaFiles, basePa
|
|||||||
Res: make([]upnpav.Resource, 0, 1),
|
Res: make([]upnpav.Resource, 0, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO replace this with a streaming path
|
||||||
|
directFileAccessPath := path.Join(resourcePath, strings.TrimPrefix(track.Path, conf.Server.MusicFolder))
|
||||||
|
|
||||||
item.Res = append(item.Res, upnpav.Resource{
|
item.Res = append(item.Res, upnpav.Resource{
|
||||||
URL: (&url.URL{
|
URL: (&url.URL{
|
||||||
Scheme: "http",
|
Scheme: "http",
|
||||||
Host: host,
|
Host: host,
|
||||||
Path: child.Path,
|
Path: directFileAccessPath,
|
||||||
}).String(),
|
}).String(),
|
||||||
ProtocolInfo: fmt.Sprintf("http-get:*:%s:%s", mimeType, dlna.ContentFeatures{
|
ProtocolInfo: fmt.Sprintf("http-get:*:%s:%s", mimeType, dlna.ContentFeatures{
|
||||||
SupportRange: false,
|
SupportRange: false,
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
serverField = "Linux/3.4 DLNADOC/1.50 UPnP/1.0 DMS/1.0"
|
serverField = "Linux/3.4 DLNADOC/1.50 UPnP/1.0 DMS/1.0"
|
||||||
rootDescPath = "/rootDesc.xml"
|
rootDescPath = "/rootDesc.xml"
|
||||||
resPath = "/r/"
|
resourcePath = "/r/"
|
||||||
serviceControlURL = "/ctl"
|
serviceControlURL = "/ctl"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ func New(ds model.DataStore, broker events.Broker) *DLNAServer {
|
|||||||
|
|
||||||
//setup dedicated HTTP server for UPNP
|
//setup dedicated HTTP server for UPNP
|
||||||
r := http.NewServeMux()
|
r := http.NewServeMux()
|
||||||
r.Handle(resPath, http.StripPrefix(resPath, http.HandlerFunc(s.ssdp.resourceHandler)))
|
r.Handle(resourcePath, http.StripPrefix(resourcePath, http.HandlerFunc(s.ssdp.resourceHandler)))
|
||||||
|
|
||||||
r.Handle("/static/", http.FileServer(http.FS(staticContent)))
|
r.Handle("/static/", http.FileServer(http.FS(staticContent)))
|
||||||
r.HandleFunc(rootDescPath, s.ssdp.rootDescHandler)
|
r.HandleFunc(rootDescPath, s.ssdp.rootDescHandler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user