From 3587e27026af766093bf11e039334ce477829be1 Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Sun, 26 Jan 2025 14:01:58 +0800 Subject: [PATCH] fix: alist proxy movie --- cmd/admin/add.go | 2 +- cmd/admin/delete.go | 2 +- cmd/admin/show.go | 2 +- cmd/root/add.go | 2 +- cmd/root/delete.go | 2 +- cmd/root/show.go | 2 +- cmd/setting/set.go | 2 +- cmd/setting/show.go | 2 +- cmd/user/ban.go | 2 +- cmd/user/delete.go | 2 +- cmd/user/search.go | 2 +- cmd/user/unban.go | 2 +- helm/Chart.yaml | 4 ++-- internal/bootstrap/log.go | 6 ------ server/handlers/movie.go | 16 ++++++++-------- synctv-web | 2 +- 16 files changed, 23 insertions(+), 29 deletions(-) diff --git a/cmd/admin/add.go b/cmd/admin/add.go index 2e2f2906..2ce4dbbb 100644 --- a/cmd/admin/add.go +++ b/cmd/admin/add.go @@ -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() diff --git a/cmd/admin/delete.go b/cmd/admin/delete.go index 8c889923..e19ddf1a 100644 --- a/cmd/admin/delete.go +++ b/cmd/admin/delete.go @@ -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() diff --git a/cmd/admin/show.go b/cmd/admin/show.go index 2a21b3ac..ed40a99a 100644 --- a/cmd/admin/show.go +++ b/cmd/admin/show.go @@ -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() diff --git a/cmd/root/add.go b/cmd/root/add.go index 9d6146a4..d22bfdd2 100644 --- a/cmd/root/add.go +++ b/cmd/root/add.go @@ -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() diff --git a/cmd/root/delete.go b/cmd/root/delete.go index a97f1210..3bc9b673 100644 --- a/cmd/root/delete.go +++ b/cmd/root/delete.go @@ -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() diff --git a/cmd/root/show.go b/cmd/root/show.go index 91a603a9..4445ab68 100644 --- a/cmd/root/show.go +++ b/cmd/root/show.go @@ -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() diff --git a/cmd/setting/set.go b/cmd/setting/set.go index 4912932c..e586c69f 100644 --- a/cmd/setting/set.go +++ b/cmd/setting/set.go @@ -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, diff --git a/cmd/setting/show.go b/cmd/setting/show.go index bb0bfe10..a689e0ab 100644 --- a/cmd/setting/show.go +++ b/cmd/setting/show.go @@ -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, diff --git a/cmd/user/ban.go b/cmd/user/ban.go index a3d2f35e..a92d3a2f 100644 --- a/cmd/user/ban.go +++ b/cmd/user/ban.go @@ -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() diff --git a/cmd/user/delete.go b/cmd/user/delete.go index 4c2e30f5..a611fc60 100644 --- a/cmd/user/delete.go +++ b/cmd/user/delete.go @@ -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() diff --git a/cmd/user/search.go b/cmd/user/search.go index 216c0b83..bbe83713 100644 --- a/cmd/user/search.go +++ b/cmd/user/search.go @@ -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() diff --git a/cmd/user/unban.go b/cmd/user/unban.go index 3eb20b81..d2319dd4 100644 --- a/cmd/user/unban.go +++ b/cmd/user/unban.go @@ -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() diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 10cca99f..b16d13b4 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -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 diff --git a/internal/bootstrap/log.go b/internal/bootstrap/log.go index 230282db..8518c819 100644 --- a/internal/bootstrap/log.go +++ b/internal/bootstrap/log.go @@ -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 -} diff --git a/server/handlers/movie.go b/server/handlers/movie.go index 4e21beef..40621538 100644 --- a/server/handlers/movie.go +++ b/server/handlers/movie.go @@ -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() @@ -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 @@ -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 } diff --git a/synctv-web b/synctv-web index 280a7b6c..241fb1f0 160000 --- a/synctv-web +++ b/synctv-web @@ -1 +1 @@ -Subproject commit 280a7b6c9f8a0e978796df8714502507e6fdac89 +Subproject commit 241fb1f079e3ecc7e504b73960321bcc8102ae05