node build fixed
This commit is contained in:
74
seanime-2.9.10/internal/mediastream/attachments.go
Normal file
74
seanime-2.9.10/internal/mediastream/attachments.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package mediastream
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"seanime/internal/events"
|
||||
"seanime/internal/mediastream/videofile"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func (r *Repository) ServeEchoExtractedSubtitles(c echo.Context) error {
|
||||
|
||||
if !r.IsInitialized() {
|
||||
r.wsEventManager.SendEvent(events.MediastreamShutdownStream, "Module not initialized")
|
||||
return errors.New("module not initialized")
|
||||
}
|
||||
|
||||
if !r.TranscoderIsInitialized() {
|
||||
r.wsEventManager.SendEvent(events.MediastreamShutdownStream, "Transcoder not initialized")
|
||||
return errors.New("transcoder not initialized")
|
||||
}
|
||||
|
||||
// Get the parameter group
|
||||
subFilePath := c.Param("*")
|
||||
|
||||
// Get current media
|
||||
mediaContainer, found := r.playbackManager.currentMediaContainer.Get()
|
||||
if !found {
|
||||
return errors.New("no file has been loaded")
|
||||
}
|
||||
|
||||
retPath := videofile.GetFileSubsCacheDir(r.cacheDir, mediaContainer.Hash)
|
||||
|
||||
if retPath == "" {
|
||||
return errors.New("could not find subtitles")
|
||||
}
|
||||
|
||||
r.logger.Trace().Msgf("mediastream: Serving subtitles from %s", retPath)
|
||||
|
||||
return c.File(filepath.Join(retPath, subFilePath))
|
||||
}
|
||||
|
||||
func (r *Repository) ServeEchoExtractedAttachments(c echo.Context) error {
|
||||
if !r.IsInitialized() {
|
||||
r.wsEventManager.SendEvent(events.MediastreamShutdownStream, "Module not initialized")
|
||||
return errors.New("module not initialized")
|
||||
}
|
||||
|
||||
if !r.TranscoderIsInitialized() {
|
||||
r.wsEventManager.SendEvent(events.MediastreamShutdownStream, "Transcoder not initialized")
|
||||
return errors.New("transcoder not initialized")
|
||||
}
|
||||
|
||||
// Get the parameter group
|
||||
subFilePath := c.Param("*")
|
||||
|
||||
// Get current media
|
||||
mediaContainer, found := r.playbackManager.currentMediaContainer.Get()
|
||||
if !found {
|
||||
return errors.New("no file has been loaded")
|
||||
}
|
||||
|
||||
retPath := videofile.GetFileAttCacheDir(r.cacheDir, mediaContainer.Hash)
|
||||
|
||||
if retPath == "" {
|
||||
return errors.New("could not find subtitles")
|
||||
}
|
||||
|
||||
subFilePath, _ = url.PathUnescape(subFilePath)
|
||||
|
||||
return c.File(filepath.Join(retPath, subFilePath))
|
||||
}
|
||||
Reference in New Issue
Block a user