diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..55f5727 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +## +## ---------------------------------------------------------------------------- +## Docker +## ---------------------------------------------------------------------------- +## + +docker-start-chaturbate-dvr: ## Start docker Chaturbate DVR + docker-compose -f docker-compose.yml up -d + +docker-stop-chaturbate-dvr: ## Stop docker Chaturbate DVR + docker-compose -f docker-compose.yml down + +docker-restart-chaturbate-dvr: ## Restart project Chaturbate DVR + docker-compose -f docker-compose.yml restart + +docker-start-chaturbate-dvr-web: ## Start docker Chaturbate DVR WEB + docker-compose -f docker-compose-web.yml up -d + +docker-stop-chaturbate-dvr-web: ## Stop docker Chaturbate DVR WEB + docker-compose -f docker-compose-web.yml down + +docker-restart-chaturbate-dvr-web: ## Restart project Chaturbate DVR WEB + docker-compose -f docker-compose-web.yml restart + +.PHONY: docker-start-chaturbate-dvr docker-stop-chaturbate-dvr docker-restart-chaturbate-dvr docker-start-chaturbate-dvr-web docker-stop-chaturbate-dvr-web docker-restart-chaturbate-dvr-web + +## +## ---------------------------------------------------------------------------- +## Compile +## ---------------------------------------------------------------------------- +## + +64bit-windows-macos-linux: ## Compile all arch amd64 + GOOS=windows GOARCH=amd64 go build -o bin/windows/chatubrate-dvr.exe && \ + GOOS=darwin GOARCH=amd64 go build -o bin/darwin/chatubrate-dvr && \ + GOOS=linux GOARCH=amd64 go build -o bin/linux/chatubrate-dvr + +arm64-windows-macos-linux: ## Compile all arch arm64 + GOOS=windows GOARCH=arm64 go build -o bin/arm64/windows/chatubrate-dvr.exe && \ + GOOS=darwin GOARCH=arm64 go build -o bin/arm64/darwin/chatubrate-dvr && \ + GOOS=linux GOARCH=arm64 go build -o bin/arm64/linux/chatubrate-dvr + +compile-all: ## Compile all + GOOS=windows GOARCH=amd64 go build -o bin/windows/chatubrate-dvr.exe && \ + GOOS=darwin GOARCH=amd64 go build -o bin/darwin/chatubrate-dvr && \ + GOOS=linux GOARCH=amd64 go build -o bin/linux/chatubrate-dvr && \ + GOOS=windows GOARCH=arm64 go build -o bin/arm64/windows/chatubrate-dvr.exe && \ + GOOS=darwin GOARCH=arm64 go build -o bin/arm64/darwin/chatubrate-dvr && \ + GOOS=linux GOARCH=arm64 go build -o bin/arm64/linux/chatubrate-dvr + +.PHONY: 64bit-windows-macos-linux arm64-windows-macos-linux + +## +## ---------------------------------------------------------------------------- +## Help +## ---------------------------------------------------------------------------- +## + +.DEFAULT_GOAL := help +.PHONY: help +help: ## Show this help + @egrep -h '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' \ + | sed -e 's/\[32m##/[33m/' \ No newline at end of file diff --git a/README.md b/README.md index b0460bb..3fc407a 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ COMMANDS: GLOBAL OPTIONS: --username value, -u value channel username to record. + --gui-username value, --gui-u value username for auth web. + --gui-password value, --gui-p value password for auth web. --framerate value, -f value preferred framerate. (default: 30) --resolution value, -r value preferred resolution (default: 1080) --resolution-fallback value, --rf value fallback to 'up' (larger) or 'down' (smaller) resolution if preferred resolution is not available (default: "down") diff --git a/bin/arm64/darwin/chatubrate-dvr b/bin/arm64/darwin/chatubrate-dvr old mode 100644 new mode 100755 index 924fe02..e944fc9 Binary files a/bin/arm64/darwin/chatubrate-dvr and b/bin/arm64/darwin/chatubrate-dvr differ diff --git a/bin/arm64/linux/chatubrate-dvr b/bin/arm64/linux/chatubrate-dvr old mode 100644 new mode 100755 index 56745e4..63cbb22 Binary files a/bin/arm64/linux/chatubrate-dvr and b/bin/arm64/linux/chatubrate-dvr differ diff --git a/bin/arm64/windows/chatubrate-dvr.exe b/bin/arm64/windows/chatubrate-dvr.exe old mode 100644 new mode 100755 index 5299c43..189999d Binary files a/bin/arm64/windows/chatubrate-dvr.exe and b/bin/arm64/windows/chatubrate-dvr.exe differ diff --git a/bin/darwin/chatubrate-dvr b/bin/darwin/chatubrate-dvr old mode 100644 new mode 100755 index 191f6c1..ed951ca Binary files a/bin/darwin/chatubrate-dvr and b/bin/darwin/chatubrate-dvr differ diff --git a/bin/linux/chatubrate-dvr b/bin/linux/chatubrate-dvr old mode 100644 new mode 100755 index a231b5e..78204d3 Binary files a/bin/linux/chatubrate-dvr and b/bin/linux/chatubrate-dvr differ diff --git a/bin/windows/chatubrate-dvr.exe b/bin/windows/chatubrate-dvr.exe old mode 100644 new mode 100755 index 5e0a86d..e7e8800 Binary files a/bin/windows/chatubrate-dvr.exe and b/bin/windows/chatubrate-dvr.exe differ diff --git a/docker-compose-web.yml b/docker-compose-web.yml new file mode 100644 index 0000000..63f334b --- /dev/null +++ b/docker-compose-web.yml @@ -0,0 +1,13 @@ +version: "3.0" + +services: + chaturbate-dvr-web: + container_name: chaturbate-dvr-web + build: + context: . + dockerfile: web.Dockerfile + environment: + - GUI_USERNAME=johndoe + - GUI_PASSWORD=password + ports: + - "8080:8080" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0ae7cae..4c217e6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,10 @@ version: "3.0" services: - chaturbate-dvr: - build: . - environment: - - USERNAME=CHANNEL_USERNAME - volumes: - - ./videos:/usr/src/app/videos + chaturbate-dvr: + container_name: chaturbate-dvr + build: . + environment: + - USERNAME=CHANNEL_USERNAME + volumes: + - ./videos:/usr/src/app/videos diff --git a/main.go b/main.go index 461a308..66014f2 100644 --- a/main.go +++ b/main.go @@ -40,6 +40,18 @@ func main() { Usage: "channel username to record.", Value: "", }, + &cli.StringFlag{ + Name: "gui-username", + Aliases: []string{"gui-u"}, + Usage: "username for auth web.", + Value: "", + }, + &cli.StringFlag{ + Name: "gui-password", + Aliases: []string{"gui-p"}, + Usage: "password for auth web.", + Value: "", + }, &cli.IntFlag{ Name: "framerate", Aliases: []string{"f"}, @@ -140,18 +152,33 @@ func startWeb(c *cli.Context) error { if err != nil { log.Fatalln(err) } - r.StaticFS("/static", http.FS(fe)) - r.StaticFileFS("/", "/", http.FS(fe)) - r.POST("/api/get_channel", handler.NewGetChannelHandler(m, c).Handle) - r.POST("/api/create_channel", handler.NewCreateChannelHandler(m, c).Handle) - r.POST("/api/list_channels", handler.NewListChannelsHandler(m, c).Handle) - r.POST("/api/delete_channel", handler.NewDeleteChannelHandler(m, c).Handle) - r.POST("/api/pause_channel", handler.NewPauseChannelHandler(m, c).Handle) - r.POST("/api/resume_channel", handler.NewResumeChannelHandler(m, c).Handle) - r.GET("/api/listen_update", handler.NewListenUpdateHandler(m, c).Handle) - r.POST("/api/get_settings", handler.NewGetSettingsHandler(c).Handle) - r.POST("/api/terminate_program", handler.NewTerminateProgramHandler(c).Handle) + guiUsername := c.String("gui-username") + guiPassword := c.String("gui-password") + + var authorized = r.Group("/") + var authorizedApi = r.Group("/api") + + if guiUsername != "" && guiPassword != "" { + ginBasicAuth := gin.BasicAuth(gin.Accounts{ + guiUsername: guiPassword, + }) + authorized.Use(ginBasicAuth) + authorizedApi.Use(ginBasicAuth) + } + + authorized.StaticFS("/static", http.FS(fe)) + authorized.StaticFileFS("/", "/", http.FS(fe)) + + authorizedApi.POST("/get_channel", handler.NewGetChannelHandler(m, c).Handle) + authorizedApi.POST("/create_channel", handler.NewCreateChannelHandler(m, c).Handle) + authorizedApi.POST("/list_channels", handler.NewListChannelsHandler(m, c).Handle) + authorizedApi.POST("/delete_channel", handler.NewDeleteChannelHandler(m, c).Handle) + authorizedApi.POST("/pause_channel", handler.NewPauseChannelHandler(m, c).Handle) + authorizedApi.POST("/resume_channel", handler.NewResumeChannelHandler(m, c).Handle) + authorizedApi.GET("/listen_update", handler.NewListenUpdateHandler(m, c).Handle) + authorizedApi.POST("/get_settings", handler.NewGetSettingsHandler(c).Handle) + authorizedApi.POST("/terminate_program", handler.NewTerminateProgramHandler(c).Handle) fmt.Printf("👋 Visit http://localhost:%s to use the Web UI\n", c.String("port")) diff --git a/web.Dockerfile b/web.Dockerfile new file mode 100644 index 0000000..575ba9b --- /dev/null +++ b/web.Dockerfile @@ -0,0 +1,11 @@ +FROM golang:latest + +WORKDIR /usr/src/app + +COPY go.mod go.sum ./ +RUN go mod download && go mod verify + +COPY . . +RUN go build + +CMD [ "sh", "-c", "./chaturbate-dvr -gui-username ${GUI_USERNAME} -gui-password ${GUI_PASSWORD}" ] \ No newline at end of file