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

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

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

Loading…
Cancel
Save