diff --git a/config/config.go b/config/config.go index 1a7a701..41e61c3 100755 --- a/config/config.go +++ b/config/config.go @@ -10,6 +10,7 @@ type Config struct { Host string `validate:"required,min=1,max=120"` AppName string + BaseUrl string Project string ProjectDocumentation string @@ -74,6 +75,7 @@ type Config struct { type PublicConfig struct { AppName string + BaseUrl string Project string EncodingEnabled bool UploadEnabled bool @@ -93,6 +95,7 @@ type PublicConfig struct { func (c Config) PublicConfig() PublicConfig { return PublicConfig{ AppName: c.AppName, + BaseUrl: c.BaseUrl, Project: c.Project, EncodingEnabled: *c.EncodingEnabled, UploadEnabled: *c.UploadEnabled, diff --git a/configdb/configdb.go b/configdb/configdb.go index dcd3639..7976169 100644 --- a/configdb/configdb.go +++ b/configdb/configdb.go @@ -18,6 +18,7 @@ func Setup() { } config.ENV.AppName = getEnvDb(&setting.AppName, "VideoCMS") + config.ENV.BaseUrl = getEnvDb(&setting.BaseUrl, "http://127.0.0.1:3000") config.ENV.Project = getEnvDb(&setting.Project, "https://github.com/notfound") config.ENV.ProjectDocumentation = getEnvDb(&setting.ProjectDocumentation, "https://github.com/notfound") diff --git a/controllers/DownloadVideoController.go b/controllers/DownloadVideoController.go index bade6d4..4df4f9d 100644 --- a/controllers/DownloadVideoController.go +++ b/controllers/DownloadVideoController.go @@ -20,7 +20,7 @@ func DownloadVideoController(c echo.Context) error { type Request struct { UUID string `validate:"required,uuid_rfc4122" param:"UUID"` QUALITY string `validate:"required,min=1,max=10" param:"QUALITY"` - Stream *bool `validate:"omitempty,boolean" query:"stream"` + Stream *bool `validate:"omitempty,boolean" param:"STREAM"` } var requestValidation Request if status, err := helpers.Validate(c, &requestValidation); err != nil { diff --git a/controllers/PlayerController.go b/controllers/PlayerController.go index e1fa6ce..927c6b1 100755 --- a/controllers/PlayerController.go +++ b/controllers/PlayerController.go @@ -67,7 +67,7 @@ func PlayerController(c echo.Context) error { "height": strconv.Itoa(int(qualiItem.Height)), "width": strconv.Itoa(int(qualiItem.Width)), }) - streamUrl = fmt.Sprintf("%s/%s/%s/download/video.mkv?stream=1&jwt=%s", config.ENV.FolderVideoQualitysPub, dbLink.UUID, qualiItem.Name, tkn) + streamUrl = fmt.Sprintf("%s/%s/%s/%s/1/stream/video.mp4", config.ENV.FolderVideoQualitysPub, dbLink.UUID, qualiItem.Name, tkn) streamUrlHeight = strconv.Itoa(int(qualiItem.Height)) streamUrlWidth = strconv.Itoa(int(qualiItem.Width)) } @@ -159,5 +159,6 @@ func PlayerController(c echo.Context) error { "Folder": config.ENV.FolderVideoQualitysPub, "JWT": tkn, "AppName": config.ENV.AppName, + "BaseUrl": config.ENV.BaseUrl, }) } diff --git a/controllers/UpdateSettingsController.go b/controllers/UpdateSettingsController.go index b1bb420..c9bdc9b 100755 --- a/controllers/UpdateSettingsController.go +++ b/controllers/UpdateSettingsController.go @@ -26,6 +26,7 @@ func UpdateSettings(c echo.Context) error { var setting models.Setting setting.ID = validation.ID setting.AppName = validation.AppName + setting.BaseUrl = validation.BaseUrl setting.Project = validation.Project setting.ProjectDocumentation = validation.ProjectDocumentation setting.ProjectDownload = validation.ProjectDownload diff --git a/middlewares/JwtStream.go b/middlewares/JwtStream.go index 73255fc..fee3a9a 100755 --- a/middlewares/JwtStream.go +++ b/middlewares/JwtStream.go @@ -16,7 +16,10 @@ func JwtStream() echo.MiddlewareFunc { } tknStr := c.QueryParam("jwt") if tknStr == "" { - return c.String(http.StatusBadRequest, "UUID parameter match issue") + tknStr = c.Param("JWT") + if tknStr == "" { + return c.String(http.StatusBadRequest, "UUID parameter match issue") + } } token, claims, err := auth.VerifyJWTStream(tknStr) if err != nil { diff --git a/models/Setting.go b/models/Setting.go index a7eab78..3549407 100644 --- a/models/Setting.go +++ b/models/Setting.go @@ -8,6 +8,7 @@ type SettingValidation struct { type Setting struct { Model AppName string `validate:"required,min=1,max=120" gorm:"size:120;"` + BaseUrl string `validate:"required,min=1,max=255" gorm:"size:255;"` Project string `validate:"required,min=1,max=512" gorm:"size:512;"` ProjectDocumentation string `validate:"required,min=1,max=512" gorm:"size:512;"` diff --git a/routes/web.go b/routes/web.go index 00815f7..efc9ac1 100755 --- a/routes/web.go +++ b/routes/web.go @@ -18,6 +18,7 @@ func Web() { videoData.GET("/:UUID/:SUBUUID/subtitle/:FILE", controllers.GetSubtitleData, middlewares.JwtStream()) videoData.GET("/:UUID/:AUDIOUUID/stream/master.m3u8", controllers.GetM3u8Data, middlewares.JwtStream()) videoData.GET("/:UUID/:QUALITY/download/video.mkv", controllers.DownloadVideoController, middlewares.JwtStream()) + videoData.GET("/:UUID/:QUALITY/:JWT/:STREAM/stream/video.mp4", controllers.DownloadVideoController, middlewares.JwtStream()) // no jwt stream videoData.GET("/:UUID/:QUALITY/:FILE", controllers.GetVideoData) videoData.GET("/:UUID/:AUDIOUUID/audio/:FILE", controllers.GetAudioData) diff --git a/views/player.html b/views/player.html index 67ae88a..94b0bdd 100755 --- a/views/player.html +++ b/views/player.html @@ -17,8 +17,8 @@ - - + +