Fix: alist and emby path invalid

pull/70/head
zijiren233 1 year ago
parent dd77ec3d7a
commit 27a4868c38

@ -145,8 +145,9 @@ func NewAlistMovieCacheInitFunc(movie *model.Movie) func(ctx context.Context, ar
var (
serverID string
err error
truePath string
)
serverID, movie.Base.VendorInfo.Alist.Path, err = model.GetAlistServerIdFromPath(movie.Base.VendorInfo.Alist.Path)
serverID, truePath, err = model.GetAlistServerIdFromPath(movie.Base.VendorInfo.Alist.Path)
if err != nil {
return nil, err
}
@ -161,7 +162,7 @@ func NewAlistMovieCacheInitFunc(movie *model.Movie) func(ctx context.Context, ar
fg, err := cli.FsGet(ctx, &alist.FsGetReq{
Host: aucd.Host,
Token: aucd.Token,
Path: movie.Base.VendorInfo.Alist.Path,
Path: truePath,
Password: movie.Base.VendorInfo.Alist.Password,
})
if err != nil {
@ -179,7 +180,7 @@ func NewAlistMovieCacheInitFunc(movie *model.Movie) func(ctx context.Context, ar
fo, err := cli.FsOther(ctx, &alist.FsOtherReq{
Host: aucd.Host,
Token: aucd.Token,
Path: movie.Base.VendorInfo.Alist.Path,
Path: truePath,
Password: movie.Base.VendorInfo.Alist.Password,
Method: "video_preview",
})

@ -82,8 +82,9 @@ func NewEmbyMovieCacheInitFunc(movie *model.Movie) func(ctx context.Context, arg
var (
serverID string
err error
truePath string
)
serverID, movie.Base.VendorInfo.Emby.Path, err = model.GetEmbyServerIdFromPath(movie.Base.VendorInfo.Emby.Path)
serverID, truePath, err = model.GetEmbyServerIdFromPath(movie.Base.VendorInfo.Emby.Path)
if err != nil {
return nil, err
}
@ -103,7 +104,7 @@ func NewEmbyMovieCacheInitFunc(movie *model.Movie) func(ctx context.Context, arg
data, err := cli.GetItem(ctx, &emby.GetItemReq{
Host: aucd.Host,
Token: aucd.ApiKey,
ItemId: movie.Base.VendorInfo.Emby.Path,
ItemId: truePath,
})
if err != nil {
return nil, err

@ -29,6 +29,17 @@ type Movie struct {
embyCache atomic.Pointer[cache.EmbyMovieCache]
}
func (m *Movie) ClearCache() {
m.alistCache.Store(nil)
bmc := m.bilibiliCache.Swap(nil)
if bmc != nil {
bmc.NoSharedMovie.Clear()
}
m.embyCache.Store(nil)
}
func (m *Movie) AlistCache() *cache.AlistMovieCache {
c := m.alistCache.Load()
if c == nil {
@ -121,7 +132,10 @@ func (m *Movie) initChannel() error {
}()
case "http", "https":
c := m.compareAndSwapInitChannel()
c.InitHlsPlayer(hls.WithGenTsNameFunc(genTsName))
err := c.InitHlsPlayer(hls.WithGenTsNameFunc(genTsName))
if err != nil {
return err
}
go func() {
for {
if c.Closed() {
@ -233,8 +247,6 @@ func (movie *Movie) validateVendorMovie() error {
default:
return fmt.Errorf("vendor not implement validate")
}
return nil
}
func (m *Movie) Terminate() error {
@ -245,14 +257,11 @@ func (m *Movie) Terminate() error {
return err
}
}
bmc := m.bilibiliCache.Swap(nil)
if bmc != nil {
bmc.NoSharedMovie.Clear()
}
return nil
}
func (m *Movie) Update(movie *model.BaseMovie) error {
m.Movie.Base = *movie
m.ClearCache()
return m.Terminate()
}

Loading…
Cancel
Save