fix: issues
This commit is contained in:
@@ -120,7 +120,7 @@ func (c *Controller) MediaSegment(ctx fiber.Ctx) error {
|
||||
return err
|
||||
}
|
||||
|
||||
filepath := c.svc.GetSegmentPath(ctx.Context(), mediaType, model.Hash, segments[0])
|
||||
filepath := c.svc.GetSegmentPath(ctx.Context(), mediaType, model.TenantID, model.Hash, segments[0])
|
||||
return ctx.SendFile(filepath)
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ func (svc *Service) GetMediaByID(ctx context.Context, tenantId, userId, id int64
|
||||
func (svc *Service) ModelToListItem(ctx context.Context, m *model.Medias) *ListItem {
|
||||
item := &ListItem{
|
||||
ID: m.ID,
|
||||
Poster: fmt.Sprintf("/static/%s/poster.jpg", m.Hash),
|
||||
Poster: fmt.Sprintf("/posters/%d/%s.jpg", m.TenantID, m.Hash),
|
||||
Hash: m.Hash,
|
||||
Title: m.Title,
|
||||
Description: m.Description,
|
||||
@@ -253,7 +253,7 @@ func (svc *Service) Upsert(ctx context.Context, tenantId int64, item media_store
|
||||
// get video m3u8
|
||||
func (svc *Service) GetM3U8(ctx context.Context, tenantId int64, types pg.MediaType, hash string, bought bool) (m3u8.Playlist, error) {
|
||||
log := svc.log.WithField("method", "GetM3U8")
|
||||
indexPath := filepath.Join(svc.storageConfig.Path, hash, types.String(), "index.m3u8")
|
||||
indexPath := filepath.Join(svc.storageConfig.Path, fmt.Sprintf("%d", tenantId), hash, types.String(), "index.m3u8")
|
||||
log.Infof("m3u8 path: %s", indexPath)
|
||||
|
||||
f, err := os.Open(indexPath)
|
||||
@@ -313,8 +313,8 @@ func (svc *Service) GetM3U8(ctx context.Context, tenantId int64, types pg.MediaT
|
||||
}
|
||||
|
||||
// GetSegmentPath
|
||||
func (svc *Service) GetSegmentPath(ctx context.Context, t pg.MediaType, hash string, segment int64) string {
|
||||
return filepath.Join(svc.storageConfig.Path, hash, t.String(), fmt.Sprintf("%d.ts", segment))
|
||||
func (svc *Service) GetSegmentPath(ctx context.Context, t pg.MediaType, tenantId int64, hash string, segment int64) string {
|
||||
return filepath.Join(svc.storageConfig.Path, fmt.Sprintf("%d", tenantId), hash, t.String(), fmt.Sprintf("%d.ts", segment))
|
||||
}
|
||||
|
||||
func (svc *Service) Checkout(ctx context.Context, tenantId, userId, mediaId int64) error {
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"git.ipao.vip/rogeecn/atom"
|
||||
"git.ipao.vip/rogeecn/atom/container"
|
||||
"git.ipao.vip/rogeecn/atom/contracts"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/gofiber/fiber/v3/middleware/favicon"
|
||||
"github.com/gofiber/fiber/v3/middleware/static"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -77,14 +78,22 @@ func Serve(cmd *cobra.Command, args []string) error {
|
||||
engine.Use(mid.WeChatVerify)
|
||||
|
||||
engine.Use([]string{"/t/:tenant", "/t/:tenant/*"}, mid.WeChatAuth, http.Wechat.Render)
|
||||
engine.Get("/posters/:tenant/:hash.jpg", func(c fiber.Ctx) error {
|
||||
tenant := c.Params("tenant")
|
||||
hash := c.Params("hash")
|
||||
|
||||
return c.SendFile(filepath.Join(
|
||||
http.Storage.Path,
|
||||
tenant,
|
||||
"posters",
|
||||
hash+".jpg",
|
||||
))
|
||||
})
|
||||
|
||||
http.Service.Engine.Use(favicon.New(favicon.Config{
|
||||
Data: []byte{},
|
||||
}))
|
||||
|
||||
http.Service.Engine.Use("/static", static.New(http.Storage.Path, static.Config{
|
||||
Browse: http.App.IsDevMode(),
|
||||
}))
|
||||
http.Service.Engine.Use("/assets", static.New(filepath.Join(http.Storage.Asset, "assets"), static.Config{
|
||||
Browse: http.App.IsDevMode(),
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user