Skip to content

Commit

Permalink
fix: alist proxy movie
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Jan 26, 2025
1 parent 7c69ae5 commit 3587e27
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cmd/admin/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var AddCmd = &cobra.Command{
Long: `add admin by user id`,
PreRunE: func(cmd *cobra.Command, _ []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/admin/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var RemoveCmd = &cobra.Command{
Long: `remove admin`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/admin/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var ShowCmd = &cobra.Command{
Long: `show admin`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/root/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var AddCmd = &cobra.Command{
Long: `add root by user id`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/root/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var RemoveCmd = &cobra.Command{
Long: `remove root`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/root/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var ShowCmd = &cobra.Command{
Long: `show root`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/setting/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var SetCmd = &cobra.Command{
Long: `set setting`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
bootstrap.InitSetting,
Expand Down
2 changes: 1 addition & 1 deletion cmd/setting/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var ShowCmd = &cobra.Command{
Long: `show setting`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
bootstrap.InitSetting,
Expand Down
2 changes: 1 addition & 1 deletion cmd/user/ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var BanCmd = &cobra.Command{
Long: "ban user with user id",
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/user/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var DeleteCmd = &cobra.Command{
Long: `delete user`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/user/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var SearchCmd = &cobra.Command{
Long: `search user by id or username`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/user/unban.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var UnbanCmd = &cobra.Command{
Long: "unban user with user id",
PreRunE: func(cmd *cobra.Command, args []string) error {
return bootstrap.New(bootstrap.WithContext(cmd.Context())).Add(
bootstrap.InitDiscardLog,
bootstrap.InitStdLog,
bootstrap.InitConfig,
bootstrap.InitDatabase,
).Run()
Expand Down
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ description: A Helm chart for deploying Synctv application with PostgreSQL State

type: application

appVersion: 0.9.3
version: 0.9.3
appVersion: 0.9.4
version: 0.9.4
6 changes: 0 additions & 6 deletions internal/bootstrap/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,3 @@ func InitStdLog(ctx context.Context) error {
setLog(logrus.StandardLogger())
return nil
}

func InitDiscardLog(ctx context.Context) error {
logrus.StandardLogger().SetOutput(io.Discard)
log.SetOutput(io.Discard)
return nil
}
16 changes: 8 additions & 8 deletions server/handlers/movie.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,6 @@ func ChangeCurrentMovie(ctx *gin.Context) {
func ProxyMovie(ctx *gin.Context) {
log := ctx.MustGet("log").(*log.Entry)

if !settings.MovieProxy.Get() {
log.Errorf("movie proxy is not enabled")
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewAPIErrorStringResp("movie proxy is not enabled"))
return
}

room := ctx.MustGet("room").(*op.RoomEntry).Value()
// user := ctx.MustGet("user").(*op.UserEntry).Value()

Expand All @@ -594,11 +588,17 @@ func ProxyMovie(ctx *gin.Context) {
return
}

if !m.Movie.MovieBase.Proxy {
if !settings.MovieProxy.Get() {
log.Errorf("proxy is not enabled")
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewAPIErrorStringResp("proxy is not enabled"))
return
}

if !m.Movie.MovieBase.Proxy {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewAPIErrorStringResp("movie is not proxy"))
return
}

if m.Movie.MovieBase.Live || m.Movie.MovieBase.RtmpSource {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewAPIErrorStringResp("this movie is live or rtmp source, not support use this method proxy"))
return
Expand Down Expand Up @@ -649,7 +649,7 @@ func ServeM3u8(ctx *gin.Context) {
}

if !m.Movie.MovieBase.Proxy {
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewAPIErrorStringResp("proxy is not enabled"))
ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewAPIErrorStringResp("movie is not proxy"))
return
}

Expand Down
2 changes: 1 addition & 1 deletion synctv-web

0 comments on commit 3587e27

Please sign in to comment.