Fix: ali cache nil pointer

pull/79/head v0.4.1
zijiren233 2 years ago
parent bdab999f95
commit a252d16bf4

@ -169,6 +169,9 @@ func (m *movies) GetMovieByID(id string) (*Movie, error) {
}
func (m *movies) getMovieByID(id string) (*Movie, error) {
if id == "" {
return nil, errors.New("movie id is nil")
}
m.init()
for e := m.list.Front(); e != nil; e = e.Next() {
if e.Value.Movie.ID == id {

@ -181,6 +181,9 @@ func (r *Room) Current() *Current {
}
func (r *Room) CurrentMovie() (*Movie, error) {
if r.current.current.Movie.ID == "" {
return nil, errors.New("no current movie")
}
return r.GetMovieByID(r.current.current.Movie.ID)
}

@ -87,7 +87,7 @@ func genCurrentRespWithCurrent(ctx context.Context, user *op.User, room *op.Room
}
opMovie, err := room.GetMovieByID(current.Movie.ID)
if err != nil {
return nil, err
return nil, fmt.Errorf("get current movie error: %w", err)
}
var movie = opMovie.Movie
if movie.Base.VendorInfo.Vendor != "" {
@ -1042,7 +1042,7 @@ func genVendorMovie(ctx context.Context, user *op.User, opMovie *op.Movie) (*dbM
return nil, err
}
if len(data.Ali.M3U8ListFile) != 0 {
if data.Ali != nil {
rawPath, err := url.JoinPath("/api/movie/proxy", movie.RoomID, movie.ID)
if err != nil {
return nil, err

Loading…
Cancel
Save